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

[Xen-devel] [PATCH] libxc/x86: don't hand through CPUID leaf 0x80000008 as is



Just like for HVM the feature set should be used for EBX output, while
EAX should be restricted to the low 16 bits and ECX/EDX should be zero.

Short of there being white listing in place just like on the HVM side,
also zap leaves 6, 9, and 0x80000007 as well as unknown / reserved ones.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -575,12 +575,26 @@ static void xc_cpuid_pv_policy(xc_interf
         break;
     }
 
+    case 0x80000008:
+        regs[0] &= 0x0000ffffu;
+        regs[1] = info->featureset[featureword_of(X86_FEATURE_CLZERO)];
+        regs[2] = regs[3] = 0;
+        break;
+
     case 0x00000005: /* MONITOR/MWAIT */
+    case 0x00000006: /* Thermal and Power Management */
+    case 0x00000008: /* reserved */
+    case 0x00000009: /* Direct Cache Access */
     case 0x0000000b: /* Extended Topology Enumeration */
+    case 0x0000000c: /* reserved */
+    case DEF_MAX_BASE + 1 ... 0x0000ffff: /* unknown / reserved */
+    case 0x80000007: /* Power Management / RAS */
+    case 0x80000009: /* reserved */
     case 0x8000000a: /* SVM revision and features */
+    case 0x8000000b ... 0x80000018: /* reserved */
     case 0x8000001b: /* Instruction Based Sampling */
     case 0x8000001c: /* Light Weight Profiling */
-    case 0x8000001e: /* Extended topology reporting */
+    case max_c(DEF_MAX_INTELEXT, DEF_MAX_AMDEXT) + 1 ... 0x8000ffff:
         regs[0] = regs[1] = regs[2] = regs[3] = 0;
         break;
     }
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -408,6 +408,10 @@ int xc_ffs64(uint64_t x);
 #define max_t(type,x,y) \
         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 
+/* Use these only in places where constant expressions are required. */
+#define min_c(x, y) ((x) < (y) ? (x) : (y))
+#define max_c(x, y) ((x) > (y) ? (x) : (y))
+
 #define DOMPRINTF(fmt, args...) xc_dom_printf(dom->xch, fmt, ## args)
 #define DOMPRINTF_CALLED(xch) xc_dom_printf((xch), "%s: called", __FUNCTION__)
 





_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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