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

[Xen-changelog] [xen-3.1-testing] hvm: Clean up CPUID 0x80000001 emulation. Filter out RDTSCP feature



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1196960421 0
# Node ID a4b96d2204fe65d7a58877b1405900e35715eca3
# Parent  ced4b58578aaf388b0742306bc2575c52d45f2c2
hvm: Clean up CPUID 0x80000001 emulation. Filter out RDTSCP feature
and emulate with #UD on AMD.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
xen-unstable changeset:   16411:93d129d27f6998302874afba3367c9f28affa23e
xen-unstable date:        Thu Nov 22 10:33:10 2007 +0000
---
 xen/arch/x86/hvm/svm/emulate.c        |    4 ----
 xen/arch/x86/hvm/svm/svm.c            |   26 ++++++++++----------------
 xen/arch/x86/hvm/vmx/vmx.c            |    9 +++++++++
 xen/include/asm-x86/hvm/svm/emulate.h |    2 --
 4 files changed, 19 insertions(+), 22 deletions(-)

diff -r ced4b58578aa -r a4b96d2204fe xen/arch/x86/hvm/svm/emulate.c
--- a/xen/arch/x86/hvm/svm/emulate.c    Thu Dec 06 16:55:41 2007 +0000
+++ b/xen/arch/x86/hvm/svm/emulate.c    Thu Dec 06 17:00:21 2007 +0000
@@ -347,8 +347,6 @@ MAKE_INSTR(CPUID,  2, 0x0f, 0xa2);
 MAKE_INSTR(CPUID,  2, 0x0f, 0xa2);
 MAKE_INSTR(RDMSR,  2, 0x0f, 0x32);
 MAKE_INSTR(WRMSR,  2, 0x0f, 0x30);
-MAKE_INSTR(RDTSC,  2, 0x0f, 0x31);
-MAKE_INSTR(RDTSCP, 3, 0x0f, 0x01, 0xf9);
 MAKE_INSTR(CLI,    1, 0xfa);
 MAKE_INSTR(STI,    1, 0xfb);
 MAKE_INSTR(RDPMC,  2, 0x0f, 0x33);
@@ -382,8 +380,6 @@ static const u8 *opc_bytes[INSTR_MAX_COU
     [INSTR_CPUID]  = OPCODE_CPUID,
     [INSTR_RDMSR]  = OPCODE_RDMSR,
     [INSTR_WRMSR]  = OPCODE_WRMSR,
-    [INSTR_RDTSC]  = OPCODE_RDTSC,
-    [INSTR_RDTSCP] = OPCODE_RDTSCP,
     [INSTR_CLI]    = OPCODE_CLI,
     [INSTR_STI]    = OPCODE_STI,
     [INSTR_RDPMC]  = OPCODE_RDPMC,
diff -r ced4b58578aa -r a4b96d2204fe xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Thu Dec 06 16:55:41 2007 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c        Thu Dec 06 17:00:21 2007 +0000
@@ -1117,6 +1117,7 @@ static void svm_do_no_device_fault(struc
 /* Reserved bits EDX: [31:29], [27], [22:20], [18], [10] */
 #define SVM_VCPU_CPUID_L1_EDX_RESERVED 0xe8740400
 
+#define bitmaskof(idx)  (1U << ((idx) & 31))
 static void svm_vmexit_do_cpuid(struct vmcb_struct *vmcb,
                                 struct cpu_user_regs *regs)
 {
@@ -1142,30 +1143,22 @@ static void svm_vmexit_do_cpuid(struct v
     }
     else if ( input == 0x80000001 )
     {
+        /* Filter features which are shared with 0x00000001:EDX. */
         if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
             clear_bit(X86_FEATURE_APIC & 31, &edx);
-
 #if CONFIG_PAGING_LEVELS >= 3
         if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_PAE_ENABLED] )
 #endif
             clear_bit(X86_FEATURE_PAE & 31, &edx);
-
         clear_bit(X86_FEATURE_PSE36 & 31, &edx);
 
-        /* Clear the Cmp_Legacy bit
-         * This bit is supposed to be zero when HTT = 0.
-         * See details on page 23 of AMD CPUID Specification.
-         */
-        clear_bit(X86_FEATURE_CMP_LEGACY & 31, &ecx);
-
-        /* Make SVM feature invisible to the guest. */
-        clear_bit(X86_FEATURE_SVME & 31, &ecx);
-
-        /* So far, we do not support 3DNow for the guest. */
-        clear_bit(X86_FEATURE_3DNOW & 31, &edx);
-        clear_bit(X86_FEATURE_3DNOWEXT & 31, &edx);
-        /* no FFXSR instructions feature. */
-        clear_bit(X86_FEATURE_FFXSR & 31, &edx);
+        /* Filter all other features according to a whitelist. */
+        edx &= (0x0183f3ff | /* features shared with 0x00000001:EDX */
+                bitmaskof(X86_FEATURE_NX) |
+                bitmaskof(X86_FEATURE_LM) |
+                bitmaskof(X86_FEATURE_SYSCALL) |
+                bitmaskof(X86_FEATURE_MP) |
+                bitmaskof(X86_FEATURE_MMXEXT));
     }
     else if ( input == 0x80000007 || input == 0x8000000A )
     {
@@ -2607,6 +2600,7 @@ asmlinkage void svm_vmexit_handler(struc
         hvm_triple_fault();
         break;
 
+    case VMEXIT_RDTSCP:
     case VMEXIT_MONITOR:
     case VMEXIT_MWAIT:
     case VMEXIT_VMRUN:
diff -r ced4b58578aa -r a4b96d2204fe xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Thu Dec 06 16:55:41 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Thu Dec 06 17:00:21 2007 +0000
@@ -1423,6 +1423,15 @@ static void vmx_do_cpuid(struct cpu_user
                      bitmaskof(X86_FEATURE_ACC));
         }
 
+        if ( input == 0x80000001 )
+        {
+            /* Only a few features are advertised in Intel's 0x80000001. */
+            ecx &= (bitmaskof(X86_FEATURE_LAHF_LM));
+            edx &= (bitmaskof(X86_FEATURE_NX) |
+                    bitmaskof(X86_FEATURE_LM) |
+                    bitmaskof(X86_FEATURE_SYSCALL));
+        }
+
         if ( input == 0x00000006 || input == 0x00000009 || input == 0x0000000A 
)
             eax = ebx = ecx = edx = 0x0;
     }
diff -r ced4b58578aa -r a4b96d2204fe xen/include/asm-x86/hvm/svm/emulate.h
--- a/xen/include/asm-x86/hvm/svm/emulate.h     Thu Dec 06 16:55:41 2007 +0000
+++ b/xen/include/asm-x86/hvm/svm/emulate.h     Thu Dec 06 17:00:21 2007 +0000
@@ -47,8 +47,6 @@ enum instruction_index {
     INSTR_CPUID,
     INSTR_RDMSR,
     INSTR_WRMSR,
-    INSTR_RDTSC,
-    INSTR_RDTSCP,
     INSTR_CLI,
     INSTR_STI,
     INSTR_RDPMC,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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