Skip to contentSkip to conversation

libxc: Expose the MPX cpuid flag to guest

PATCH In review Liang Li 6 participants 9 messages Jan 11, 2016 – Mar 1, 2016

lore
Share & tools
lore

Liang Li

author
#0 lore raw

PATCH 1/1 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.

---
 tools/libxc/xc_cpufeature.h | 1 +
 tools/libxc/xc_cpuid_x86.c  | 6 ++++++
 2 files changed, 7 insertions(+)
tools/libxc/xc_cpufeature.h +1 -0
index c3ddc80..cda9305 100644
@@ -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 */
tools/libxc/xc_cpuid_x86.c +6 -0
index 8882c01..4c88db4 100644
@@ -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) |
@@ -538,6 +540,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) |
@@ -547,6 +550,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;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Liang Li

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.

I will defer this to the x86 maintainers.

Wei.

Reviewed-by
#2 lore raw
Quoted 7 lines · Wei Liu
Quoted 5 lines · Liang Li

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.

I will defer this to the x86 maintainers.

Looks like the hypervisor side is all present.

~Andrew

#3 lore raw
Quoted 6 lines · Wei Liu
Quoted 5 lines · Liang Li
Quoted 4 lines

If hardware support memory protect extension, expose this feature to guest by default. Users don't have to use a 'cpuid= ' option in config file to turn it on.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

I will defer this to the x86 maintainers.

Looks like the hypervisor side is all present.

Yes, Thanks for reviewing.

Liang

Quoted 1 line

~Andrew

#4 lore raw
In reply to Andrew Cooper
Quoted 13 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Monday, January 11, 2016 5:59 PM
To: Wei Liu; Li, Liang Z
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] libxc: Expose the MPX cpuid flag to guest

Quoted 5 lines · Wei Liu
Quoted 4 lines · Liang Li

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.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

I will defer this to the x86 maintainers.

Looks like the hypervisor side is all present.

~Andrew

Is there anyone who can help to make this patch merged? It's pending for a long time.

Liang

#5 lore raw
Quoted 18 lines · Liang Z
Quoted 18 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Monday, January 11, 2016 5:59 PM
To: Wei Liu; Li, Liang Z
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] libxc: Expose the MPX cpuid flag to guest

Quoted 7 lines · Wei Liu
Quoted 5 lines · Liang Li

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.

I will defer this to the x86 maintainers.

Quoted 8 lines
Quoted 3 lines

Looks like the hypervisor side is all present.

~Andrew

Is there anyone who can help to make this patch merged? It's pending for a long time.

Liang

Ping on the behalf of Liang. This patch still applies cleanly.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
In reply to Liang Li
Quoted 1 line · Liang Li

If hardware support memory protect externsion, expose this feature

extension

Quoted 60 lines

to guest by default. Users don't have to use a 'cpuid= ' option in config file to turn it on.

---
 tools/libxc/xc_cpufeature.h | 1 +
 tools/libxc/xc_cpuid_x86.c  | 6 ++++++
 2 files changed, 7 insertions(+)
tools/libxc/xc_cpufeature.h +1 -0
index c3ddc80..cda9305 100644
@@ -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 */
tools/libxc/xc_cpuid_x86.c +6 -0
index 8882c01..4c88db4 100644
@@ -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) |
@@ -538,6 +540,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) |
@@ -547,6 +550,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;
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#8 lore raw

Li, Liang Z writes ("RE: [Xen-devel] [PATCH] libxc: Expose the MPX cpuid flag to guest"):

Quoted 11 lines
Quoted 9 lines

Cc: [email protected]; [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] libxc: Expose the MPX cpuid flag to guest

Quoted 1 line · Liang Li

If hardware support memory protect externsion, expose this feature

extension

Thanks!

Sorry for the delay. I have queued this patch and assuming that my build test passes it will be pushed shortly.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel