[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.7] x86: further CPUID handling adjustments



commit 62b1879693e0b560fb68dace4e02c3b32d4a30dd
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Apr 18 16:53:40 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Apr 18 16:53:40 2018 +0200

    x86: further CPUID handling adjustments
    
    In particular for Dom0 we need to make sure to surface Spectre related
    feature flags.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c      | 4 ++++
 xen/arch/x86/traps.c        | 8 ++++++--
 xen/include/asm-x86/cpuid.h | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 2596597b3a..5211c23fb2 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3497,6 +3497,9 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, 
unsigned int *ebx,
 
             *ecx &= hvm_featureset[FEATURESET_7c0];
 
+            *edx |= cpufeat_mask(X86_FEATURE_STIBP);
+            *edx &= hvm_featureset[FEATURESET_7d0];
+
             /* Don't expose HAP-only features to non-hap guests. */
             if ( !hap_enabled(d) )
             {
@@ -3654,6 +3657,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, 
unsigned int *ebx,
         hvm_cpuid(0x80000001, NULL, NULL, NULL, &_edx);
         *eax |= (_edx & cpufeat_mask(X86_FEATURE_LM) ? vaddr_bits : 32) << 8;
 
+        *ebx |= cpufeat_mask(X86_FEATURE_IBPB);
         *ebx &= hvm_featureset[FEATURESET_e8b];
         break;
     }
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index e5884039bf..e96a5d3642 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1089,6 +1089,9 @@ void pv_cpuid(struct cpu_user_regs *regs)
 
             c &= pv_featureset[FEATURESET_7c0];
 
+            d |= cpufeat_mask(X86_FEATURE_STIBP);
+            d &= pv_featureset[FEATURESET_7d0];
+
             if ( !is_pvh_domain(currd) )
             {
                 /*
@@ -1102,8 +1105,8 @@ void pv_cpuid(struct cpu_user_regs *regs)
             }
         }
         else
-            b = c = 0;
-        a = d = 0;
+            b = c = d = 0;
+        a = 0;
         break;
 
     case XSTATE_CPUID:
@@ -1185,6 +1188,7 @@ void pv_cpuid(struct cpu_user_regs *regs)
 
     case 0x80000008:
         a = paddr_bits | (vaddr_bits << 8);
+        b |= cpufeat_mask(X86_FEATURE_IBPB);
         b &= pv_featureset[FEATURESET_e8b];
         break;
 
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 9a21c25ec1..abe2874eb9 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -16,6 +16,7 @@
 #define FEATURESET_7c0    6 /* 0x00000007:0.ecx    */
 #define FEATURESET_e7d    7 /* 0x80000007.edx      */
 #define FEATURESET_e8b    8 /* 0x80000008.ebx      */
+#define FEATURESET_7d0    9 /* 0x00000007:0.edx    */
 
 #ifndef __ASSEMBLY__
 #include <xen/types.h>
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.7

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.