]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
libxc: Expose the MPX cpuid flag to guest
authorLiang Li <liang.z.li@intel.com>
Mon, 11 Jan 2016 08:52:10 +0000 (16:52 +0800)
committerWei Liu <wei.liu2@citrix.com>
Tue, 15 Mar 2016 16:32:32 +0000 (16:32 +0000)
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 <liang.z.li@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxc/xc_cpufeature.h
tools/libxc/xc_cpuid_x86.c

index 866cf0b8e714f96b05ce8b27ecc81ee4c4c3c283..01dbeecfffd7d4157aa504eead4cdd8ba563ca9a 100644 (file)
 #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 */
index 5408dd016af54ea168c2b3d1f30a7ba3cdd974ed..733add4a502d35c195b514a2a874859878ff3efe 100644 (file)
@@ -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;