]> xenbits.xensource.com Git - xen.git/commitdiff
hvm: Clean up CPUID_0000_0001 return values.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 7 Feb 2008 10:31:48 +0000 (10:31 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 7 Feb 2008 10:31:48 +0000 (10:31 +0000)
The fix to EBX.ApicID was pointed out by Andre Przywara
<andre.przywara@amd.com>.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/realmode.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vmx/cpu.h [deleted file]
xen/include/asm-x86/hvm/vmx/vmcs.h

index cdfdec984ffd6beaa454322a31682da25aafcf1d..14c965cef9804a85bd93f2498761cd94f99de895 100644 (file)
@@ -1400,6 +1400,7 @@ void hvm_print_line(struct vcpu *v, const char c)
     spin_unlock(&hd->pbuf_lock);
 }
 
+#define bitmaskof(idx)  (1U << ((idx) & 31))
 void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
                                    unsigned int *ecx, unsigned int *edx)
 {
@@ -1413,16 +1414,44 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
     switch ( input )
     {
     case 0x00000001:
-        __clear_bit(X86_FEATURE_MWAIT & 31, ecx);
-
+        /* Clear #threads count and poke initial VLAPIC ID. */
+        *ebx &= 0x0000FFFFu;
+        *ebx |= (current->vcpu_id * 2) << 24;
+
+        *ecx &= (bitmaskof(X86_FEATURE_XMM3) |
+                 bitmaskof(X86_FEATURE_SSSE3) |
+                 bitmaskof(X86_FEATURE_CX16) |
+                 bitmaskof(X86_FEATURE_SSE4_1) |
+                 bitmaskof(X86_FEATURE_SSE4_2) |
+                 bitmaskof(X86_FEATURE_POPCNT));
+
+        *edx &= (bitmaskof(X86_FEATURE_FPU) |
+                 bitmaskof(X86_FEATURE_VME) |
+                 bitmaskof(X86_FEATURE_DE) |
+                 bitmaskof(X86_FEATURE_PSE) |
+                 bitmaskof(X86_FEATURE_TSC) |
+                 bitmaskof(X86_FEATURE_MSR) |
+                 bitmaskof(X86_FEATURE_PAE) |
+                 bitmaskof(X86_FEATURE_MCE) |
+                 bitmaskof(X86_FEATURE_CX8) |
+                 bitmaskof(X86_FEATURE_APIC) |
+                 bitmaskof(X86_FEATURE_SEP) |
+                 bitmaskof(X86_FEATURE_MTRR) |
+                 bitmaskof(X86_FEATURE_PGE) |
+                 bitmaskof(X86_FEATURE_MCA) |
+                 bitmaskof(X86_FEATURE_CMOV) |
+                 bitmaskof(X86_FEATURE_PAT) |
+                 bitmaskof(X86_FEATURE_CLFLSH) |
+                 bitmaskof(X86_FEATURE_MMX) |
+                 bitmaskof(X86_FEATURE_FXSR) |
+                 bitmaskof(X86_FEATURE_XMM) |
+                 bitmaskof(X86_FEATURE_XMM2));
         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);
         break;
 
     case 0x80000001:
index 5a94de6d9625311bbcd287476d57c0467f15b398..38459466331070464dda1d54bd5e6d31ac8f7190 100644 (file)
@@ -986,11 +986,6 @@ static void svm_do_no_device_fault(struct vmcb_struct *vmcb)
         vmcb->cr0 &= ~X86_CR0_TS;
 }
 
-/* Reserved bits ECX: [31:14], [12:4], [2:1]*/
-#define SVM_VCPU_CPUID_L1_ECX_RESERVED 0xffffdff6
-/* 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)
@@ -1005,16 +1000,10 @@ static void svm_vmexit_do_cpuid(struct vmcb_struct *vmcb,
     switch ( input )
     {
     case 0x00000001:
-        /* Clear out reserved bits. */
-        ecx &= ~SVM_VCPU_CPUID_L1_ECX_RESERVED;
-        edx &= ~SVM_VCPU_CPUID_L1_EDX_RESERVED;
-
-        /* Guest should only see one logical processor.
-         * See details on page 23 of AMD CPUID Specification.
-         */
-        __clear_bit(X86_FEATURE_HT & 31, &edx);
-        ebx &= 0xFF00FFFF;  /* clear the logical processor count when HTT=0 */
-        ebx |= 0x00010000;  /* set to 1 just for precaution */
+        /* Mask Intel-only features. */
+        ecx &= ~(bitmaskof(X86_FEATURE_SSSE3) |
+                 bitmaskof(X86_FEATURE_SSE4_1) |
+                 bitmaskof(X86_FEATURE_SSE4_2));
         break;
 
     case 0x80000001:
index 74838d0680fda9e0e04f15161a5fb637192b3164..6c591d1f1600b1b1d8c526ff8069cf459142a5e3 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/hvm/support.h>
 #include <asm/hvm/vmx/vmx.h>
 #include <asm/hvm/vmx/vmcs.h>
-#include <asm/hvm/vmx/cpu.h>
 #include <asm/x86_emulate.h>
 
 struct realmode_emulate_ctxt {
index 6bd496f8d757ff4fd9d8af5c19828413b8439965..50efb4fcd934b34563229110cf70e3b488b474cd 100644 (file)
@@ -41,7 +41,6 @@
 #include <asm/hvm/support.h>
 #include <asm/hvm/vmx/vmx.h>
 #include <asm/hvm/vmx/vmcs.h>
-#include <asm/hvm/vmx/cpu.h>
 #include <public/sched.h>
 #include <public/hvm/ioreq.h>
 #include <asm/hvm/vpic.h>
@@ -1267,23 +1266,13 @@ void vmx_cpuid_intercept(
     switch ( input )
     {
     case 0x00000001:
-        *ecx &= ~VMX_VCPU_CPUID_L1_ECX_RESERVED;
-        *ebx &= NUM_THREADS_RESET_MASK;
-        *ecx &= ~(bitmaskof(X86_FEATURE_VMXE) |
-                  bitmaskof(X86_FEATURE_EST)  |
-                  bitmaskof(X86_FEATURE_TM2)  |
-                  bitmaskof(X86_FEATURE_CID)  |
-                  bitmaskof(X86_FEATURE_PDCM) |
-                  bitmaskof(X86_FEATURE_DSCPL));
-        *edx &= ~(bitmaskof(X86_FEATURE_HT)   |
-                  bitmaskof(X86_FEATURE_ACPI) |
-                  bitmaskof(X86_FEATURE_ACC)  |
-                  bitmaskof(X86_FEATURE_DS));
+        /* Mask AMD-only features. */
+        *ecx &= ~(bitmaskof(X86_FEATURE_POPCNT));
         break;
 
     case 0x00000004:
         cpuid_count(input, count, eax, ebx, ecx, edx);
-        *eax &= NUM_CORES_RESET_MASK;
+        *eax &= 0x3FFF; /* one core */
         break;
 
     case 0x00000006:
diff --git a/xen/include/asm-x86/hvm/vmx/cpu.h b/xen/include/asm-x86/hvm/vmx/cpu.h
deleted file mode 100644 (file)
index decd01e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * cpu.h: Virtual CPU state
- * Copyright (c) 2004, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- */
-#ifndef __ASM_X86_HVM_VMX_CPU_H__
-#define __ASM_X86_HVM_VMX_CPU_H__
-
-#define NUM_CORES_RESET_MASK                 0x00003FFF
-#define NUM_THREADS_RESET_MASK               0xFF00FFFF
-
-#define VMX_VCPU_CPUID_L1_ECX_RESERVED_18    0x00040000
-#define VMX_VCPU_CPUID_L1_ECX_RESERVED_6     0x00000040
-
-#define VMX_VCPU_CPUID_L1_ECX_RESERVED              \
-            ( VMX_VCPU_CPUID_L1_ECX_RESERVED_18 |   \
-              VMX_VCPU_CPUID_L1_ECX_RESERVED_6 )
-
-#endif /* __ASM_X86_HVM_VMX_CPU_H__ */
index a8d5e4d12b286959c7b0daedc0ee4d4ae59b1a3a..e73cbad7e07f9750768c0f98fe68080e4fc11966 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <asm/config.h>
 #include <asm/hvm/io.h>
-#include <asm/hvm/vmx/cpu.h>
 #include <asm/hvm/vmx/vpmu.h>
 
 extern void start_vmx(void);