# HG changeset patch # User Yang, Wei # Date 1308053598 -3600 # Node ID f4a47275aebf383cf565e0a265a56a8c1110d45e # Parent 337520d94cba906e64dbd3089d65cda8cf97d1d0 x86: Pass through ERMS CPUID feature for HVM and PV guests This patch exposes ERMS feature to HVM and PV guests. The REP MOVSB/STOSB instruction can enhance fast strings attempts to move as much of the data with larger size load/stores as possible. Signed-off-by: Yang, Wei --- a/tools/libxc/xc_cpufeature.h +++ b/tools/libxc/xc_cpufeature.h @@ -126,5 +126,6 @@ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */ #define X86_FEATURE_FSGSBASE 0 /* {RD,WR}{FS,GS}BASE instructions */ #define X86_FEATURE_SMEP 7 /* Supervisor Mode Execution Protection */ +#define X86_FEATURE_ERMS 9 /* Enhanced REP MOVSB/STOSB */ #endif /* __LIBXC_CPUFEATURE_H */ --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -303,7 +303,8 @@ static void xc_cpuid_hvm_policy( case 0x00000007: /* Intel-defined CPU features */ if ( input[1] == 0 ) { - regs[1] &= bitmaskof(X86_FEATURE_SMEP); + regs[1] &= (bitmaskof(X86_FEATURE_SMEP) | + bitmaskof(X86_FEATURE_ERMS)); } else regs[1] = 0; regs[0] = regs[2] = regs[3] = 0; @@ -425,7 +426,8 @@ static void xc_cpuid_pv_policy( case 7: if ( input[1] == 0 ) - regs[1] &= bitmaskof(X86_FEATURE_FSGSBASE); + regs[1] &= (bitmaskof(X86_FEATURE_FSGSBASE) | + bitmaskof(X86_FEATURE_ERMS)); else regs[1] = 0; regs[0] = regs[2] = regs[3] = 0; --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -812,7 +812,8 @@ static void pv_cpuid(struct cpu_user_reg break; case 7: if ( regs->ecx == 0 ) - b &= cpufeat_mask(X86_FEATURE_FSGSBASE); + b &= (cpufeat_mask(X86_FEATURE_FSGSBASE) | + cpufeat_mask(X86_FEATURE_ERMS)); else b = 0; a = c = d = 0; --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -144,6 +144,7 @@ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 7 */ #define X86_FEATURE_FSGSBASE (7*32+ 0) /* {RD,WR}{FS,GS}BASE instructions */ #define X86_FEATURE_SMEP (7*32+ 7) /* Supervisor Mode Execution Protection */ +#define X86_FEATURE_ERMS (7*32+ 9) /* Enhanced REP MOVSB/STOSB */ #define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) #define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)