File x86-Spectre-CPUID.patch of Package xen.7314

References: bsc#1086039

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@suse.com>

--- sle12sp2.orig/xen/arch/x86/hvm/hvm.c	2018-03-28 16:33:59.000000000 +0200
+++ sle12sp2/xen/arch/x86/hvm/hvm.c	2018-03-29 17:04:06.972311642 +0200
@@ -3497,6 +3497,9 @@ void hvm_cpuid(unsigned int input, unsig
 
             *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, unsig
         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;
     }
--- sle12sp2.orig/xen/arch/x86/traps.c	2018-03-28 16:33:59.000000000 +0200
+++ sle12sp2/xen/arch/x86/traps.c	2018-03-29 17:04:54.253483324 +0200
@@ -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;
 
--- sle12sp2.orig/xen/include/asm-x86/cpuid.h	2018-03-29 00:00:00.000000000 +0200
+++ sle12sp2/xen/include/asm-x86/cpuid.h	2018-03-29 17:09:06.767682016 +0200
@@ -17,6 +17,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>
openSUSE Build Service is sponsored by