WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.2-testing] hvm: Clean up CPUID_0000_0001 return v

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.2-testing] hvm: Clean up CPUID_0000_0001 return values.
From: "Xen patchbot-3.2-testing" <patchbot-3.2-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Feb 2008 07:11:54 -0800
Delivery-date: Fri, 22 Feb 2008 07:47:01 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1203343447 0
# Node ID 1d9487ed5e6f22fe0ca727caa6fc256fc75f15f4
# Parent  20b20c4532825a74ff3f3c087d9d56152fdbec72
hvm: Clean up CPUID_0000_0001 return values.
The fix to EBX.ApicID was pointed out by Andre Przywara
<andre.przywara@xxxxxxx>.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   16990:199f81c4b882467aac41d9d53ed69184f7c7a393
xen-unstable date:        Thu Feb 07 10:31:48 2008 +0000
---
 xen/include/asm-x86/hvm/vmx/cpu.h  |   45 -------------------------------------
 xen/arch/x86/hvm/hvm.c             |   37 +++++++++++++++++++++++++++---
 xen/arch/x86/hvm/svm/svm.c         |   19 +++------------
 xen/arch/x86/hvm/vmx/realmode.c    |    1 
 xen/arch/x86/hvm/vmx/vmx.c         |   17 ++-----------
 xen/include/asm-x86/hvm/vmx/vmcs.h |    1 
 6 files changed, 40 insertions(+), 80 deletions(-)

diff -r 20b20c453282 -r 1d9487ed5e6f xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Mon Feb 18 14:01:05 2008 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Mon Feb 18 14:04:07 2008 +0000
@@ -1403,6 +1403,7 @@ void hvm_print_line(struct vcpu *v, cons
     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)
 {
@@ -1416,16 +1417,44 @@ void hvm_cpuid(unsigned int input, unsig
     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:
diff -r 20b20c453282 -r 1d9487ed5e6f xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Mon Feb 18 14:01:05 2008 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c        Mon Feb 18 14:04:07 2008 +0000
@@ -967,11 +967,6 @@ static void svm_do_no_device_fault(struc
         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)
@@ -986,16 +981,10 @@ static void svm_vmexit_do_cpuid(struct v
     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:
diff -r 20b20c453282 -r 1d9487ed5e6f xen/arch/x86/hvm/vmx/realmode.c
--- a/xen/arch/x86/hvm/vmx/realmode.c   Mon Feb 18 14:01:05 2008 +0000
+++ b/xen/arch/x86/hvm/vmx/realmode.c   Mon Feb 18 14:04:07 2008 +0000
@@ -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 {
diff -r 20b20c453282 -r 1d9487ed5e6f xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Mon Feb 18 14:01:05 2008 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Mon Feb 18 14:04:07 2008 +0000
@@ -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>
@@ -1285,23 +1284,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 -r 20b20c453282 -r 1d9487ed5e6f xen/include/asm-x86/hvm/vmx/cpu.h
--- a/xen/include/asm-x86/hvm/vmx/cpu.h Mon Feb 18 14:01:05 2008 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +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__
-
-/*
- * Virtual CPU
- */
-struct arch_state_struct {
-    unsigned long       mode_flags; /* vm86, 32-bit, 64-bit, etc. */
-    /* debug registers */
-    /* MSRs */
-};
-
-#define VMX_MF_VM86     0
-#define VMX_MF_32       1
-#define VMX_MF_64       2
-
-#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__ */
diff -r 20b20c453282 -r 1d9487ed5e6f xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h        Mon Feb 18 14:01:05 2008 +0000
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h        Mon Feb 18 14:04:07 2008 +0000
@@ -21,7 +21,6 @@
 
 #include <asm/config.h>
 #include <asm/hvm/io.h>
-#include <asm/hvm/vmx/cpu.h>
 
 #ifdef VMXASSIST
 #include <public/hvm/vmx_assist.h>

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.2-testing] hvm: Clean up CPUID_0000_0001 return values., Xen patchbot-3.2-testing <=