From: Liang Li Date: Mon, 11 Jan 2016 08:52:10 +0000 (+0800) Subject: libxc: Expose the MPX cpuid flag to guest X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=53c5ee1eabedceb53d470d255d2b1f0626262507;p=people%2Fliuw%2Fxen.git libxc: Expose the MPX cpuid flag to guest If hardware support memory protect externsion, expose this feature to guest by default. Users don't have to use a 'cpuid= ' option in config file to turn it on. Signed-off-by: Liang Li Reviewed-by: Andrew Cooper --- diff --git a/tools/libxc/xc_cpufeature.h b/tools/libxc/xc_cpufeature.h index 866cf0b8e7..01dbeecfff 100644 --- a/tools/libxc/xc_cpufeature.h +++ b/tools/libxc/xc_cpufeature.h @@ -137,6 +137,7 @@ #define X86_FEATURE_ERMS 9 /* Enhanced REP MOVSB/STOSB */ #define X86_FEATURE_INVPCID 10 /* Invalidate Process Context ID */ #define X86_FEATURE_RTM 11 /* Restricted Transactional Memory */ +#define X86_FEATURE_MPX 14 /* Memory Protection Extensions */ #define X86_FEATURE_RDSEED 18 /* RDSEED instruction */ #define X86_FEATURE_ADX 19 /* ADCX, ADOX instructions */ #define X86_FEATURE_SMAP 20 /* Supervisor Mode Access Protection */ diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 5408dd016a..733add4a50 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -423,6 +423,8 @@ static void xc_cpuid_hvm_policy(xc_interface *xch, bitmaskof(X86_FEATURE_ERMS) | bitmaskof(X86_FEATURE_INVPCID) | bitmaskof(X86_FEATURE_RTM) | + ((info->xfeature_mask != 0) ? + bitmaskof(X86_FEATURE_MPX) : 0) | bitmaskof(X86_FEATURE_RDSEED) | bitmaskof(X86_FEATURE_ADX) | bitmaskof(X86_FEATURE_SMAP) | @@ -543,6 +545,7 @@ static void xc_cpuid_pv_policy(xc_interface *xch, case 0x00000007: if ( input[1] == 0 ) + { regs[1] &= (bitmaskof(X86_FEATURE_BMI1) | bitmaskof(X86_FEATURE_HLE) | bitmaskof(X86_FEATURE_AVX2) | @@ -552,6 +555,9 @@ static void xc_cpuid_pv_policy(xc_interface *xch, bitmaskof(X86_FEATURE_RDSEED) | bitmaskof(X86_FEATURE_ADX) | bitmaskof(X86_FEATURE_FSGSBASE)); + if ( info->xfeature_mask == 0 ) + clear_bit(X86_FEATURE_MPX, regs[1]); + } else regs[1] = 0; regs[0] = regs[2] = regs[3] = 0;