aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-06-02 14:45:00 +0100
committerKeir Fraser <keir@xen.org>2011-06-02 14:45:00 +0100
commit8e3850ae166ca19d7c5449c8d04ac6d2346c9d03 (patch)
tree704aa17f2294464a2f092a63b36ed6c7eb320bf1
parent9d78da3acbd231a7e824a97851920d0a05040042 (diff)
downloadxen-8e3850ae166ca19d7c5449c8d04ac6d2346c9d03.tar.gz
xen-8e3850ae166ca19d7c5449c8d04ac6d2346c9d03.tar.bz2
xen-8e3850ae166ca19d7c5449c8d04ac6d2346c9d03.zip
x86: Hide CPUID leaf 7 from PV guests.
Except for the whitelisted FSGSBASE feature. Signed-off-by: Keir Fraser <keir@xen.org> xen-unstable changeset: 23461:5839e797a130 xen-unstable date: Thu Jun 02 14:39:50 2011 +0100
-rw-r--r--tools/libxc/xc_cpufeature.h3
-rw-r--r--tools/libxc/xc_cpuid_x86.c10
-rw-r--r--xen/arch/x86/traps.c7
3 files changed, 19 insertions, 1 deletions
diff --git a/tools/libxc/xc_cpufeature.h b/tools/libxc/xc_cpufeature.h
index 5263774ab3..d8bb6cb27f 100644
--- a/tools/libxc/xc_cpufeature.h
+++ b/tools/libxc/xc_cpufeature.h
@@ -141,4 +141,7 @@
#define X86_FEATURE_TBM (6*32+21) /* trailing bit manipulations */
#define X86_FEATURE_TOPOEXT (6*32+22) /* topology extensions CPUID leafs */
+/* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
+#define X86_FEATURE_FSGSBASE (7*32+ 0) /* {RD,WR}{FS,GS}BASE instructions */
+
#endif /* __LIBXC_CPUFEATURE_H */
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 44cc8398b3..a30d9a89e6 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -414,6 +414,14 @@ static void xc_cpuid_pv_policy(
set_bit(X86_FEATURE_HYPERVISOR, regs[2]);
break;
+ case 7:
+ if ( input[1] == 0 )
+ regs[1] &= bitmaskof(X86_FEATURE_FSGSBASE);
+ else
+ regs[1] = 0;
+ regs[0] = regs[2] = regs[3] = 0;
+ break;
+
case 0x0000000d:
xc_cpuid_config_xsave(xch, domid, xfeature_mask, input, regs);
break;
@@ -553,7 +561,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, domid_t domid)
input[0] = 0x80000000u;
input[1] = XEN_CPUID_INPUT_UNUSED;
- if ( (input[0] == 4) || (input[0] == 0xd) )
+ if ( (input[0] == 4) || (input[0] == 7) || (input[0] == 0xd) )
input[1] = 0;
if ( (input[0] & 0x80000000u) && (input[0] > ext_max) )
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 61ee6da7cb..e86776ab5d 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -780,6 +780,13 @@ static void pv_cpuid(struct cpu_user_regs *regs)
__clear_bit(X86_FEATURE_X2APIC % 32, &c);
__set_bit(X86_FEATURE_HYPERVISOR % 32, &c);
break;
+ case 7:
+ if ( regs->ecx == 0 )
+ b &= cpufeat_mask(X86_FEATURE_FSGSBASE);
+ else
+ b = 0;
+ a = c = d = 0;
+ break;
case 0x80000001:
/* Modify Feature Information. */
if ( is_pv_32bit_vcpu(current) )