ia64/xen-unstable

changeset 17000:199f81c4b882

hvm: Clean up CPUID_0000_0001 return values.
The fix to EBX.ApicID was pointed out by Andre Przywara
<andre.przywara@amd.com>.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 07 10:31:48 2008 +0000 (2008-02-07)
parents 58e5e9ae0f8d
children 2adf154d17c2
files 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 xen/include/asm-x86/hvm/vmx/vmcs.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Feb 07 09:28:55 2008 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Feb 07 10:31:48 2008 +0000
     1.3 @@ -1400,6 +1400,7 @@ void hvm_print_line(struct vcpu *v, cons
     1.4      spin_unlock(&hd->pbuf_lock);
     1.5  }
     1.6  
     1.7 +#define bitmaskof(idx)  (1U << ((idx) & 31))
     1.8  void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
     1.9                                     unsigned int *ecx, unsigned int *edx)
    1.10  {
    1.11 @@ -1413,16 +1414,44 @@ void hvm_cpuid(unsigned int input, unsig
    1.12      switch ( input )
    1.13      {
    1.14      case 0x00000001:
    1.15 -        __clear_bit(X86_FEATURE_MWAIT & 31, ecx);
    1.16 +        /* Clear #threads count and poke initial VLAPIC ID. */
    1.17 +        *ebx &= 0x0000FFFFu;
    1.18 +        *ebx |= (current->vcpu_id * 2) << 24;
    1.19 +
    1.20 +        *ecx &= (bitmaskof(X86_FEATURE_XMM3) |
    1.21 +                 bitmaskof(X86_FEATURE_SSSE3) |
    1.22 +                 bitmaskof(X86_FEATURE_CX16) |
    1.23 +                 bitmaskof(X86_FEATURE_SSE4_1) |
    1.24 +                 bitmaskof(X86_FEATURE_SSE4_2) |
    1.25 +                 bitmaskof(X86_FEATURE_POPCNT));
    1.26  
    1.27 +        *edx &= (bitmaskof(X86_FEATURE_FPU) |
    1.28 +                 bitmaskof(X86_FEATURE_VME) |
    1.29 +                 bitmaskof(X86_FEATURE_DE) |
    1.30 +                 bitmaskof(X86_FEATURE_PSE) |
    1.31 +                 bitmaskof(X86_FEATURE_TSC) |
    1.32 +                 bitmaskof(X86_FEATURE_MSR) |
    1.33 +                 bitmaskof(X86_FEATURE_PAE) |
    1.34 +                 bitmaskof(X86_FEATURE_MCE) |
    1.35 +                 bitmaskof(X86_FEATURE_CX8) |
    1.36 +                 bitmaskof(X86_FEATURE_APIC) |
    1.37 +                 bitmaskof(X86_FEATURE_SEP) |
    1.38 +                 bitmaskof(X86_FEATURE_MTRR) |
    1.39 +                 bitmaskof(X86_FEATURE_PGE) |
    1.40 +                 bitmaskof(X86_FEATURE_MCA) |
    1.41 +                 bitmaskof(X86_FEATURE_CMOV) |
    1.42 +                 bitmaskof(X86_FEATURE_PAT) |
    1.43 +                 bitmaskof(X86_FEATURE_CLFLSH) |
    1.44 +                 bitmaskof(X86_FEATURE_MMX) |
    1.45 +                 bitmaskof(X86_FEATURE_FXSR) |
    1.46 +                 bitmaskof(X86_FEATURE_XMM) |
    1.47 +                 bitmaskof(X86_FEATURE_XMM2));
    1.48          if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
    1.49              __clear_bit(X86_FEATURE_APIC & 31, edx);
    1.50 -
    1.51  #if CONFIG_PAGING_LEVELS >= 3
    1.52          if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_PAE_ENABLED] )
    1.53  #endif
    1.54              __clear_bit(X86_FEATURE_PAE & 31, edx);
    1.55 -        __clear_bit(X86_FEATURE_PSE36 & 31, edx);
    1.56          break;
    1.57  
    1.58      case 0x80000001:
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Thu Feb 07 09:28:55 2008 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Thu Feb 07 10:31:48 2008 +0000
     2.3 @@ -986,11 +986,6 @@ static void svm_do_no_device_fault(struc
     2.4          vmcb->cr0 &= ~X86_CR0_TS;
     2.5  }
     2.6  
     2.7 -/* Reserved bits ECX: [31:14], [12:4], [2:1]*/
     2.8 -#define SVM_VCPU_CPUID_L1_ECX_RESERVED 0xffffdff6
     2.9 -/* Reserved bits EDX: [31:29], [27], [22:20], [18], [10] */
    2.10 -#define SVM_VCPU_CPUID_L1_EDX_RESERVED 0xe8740400
    2.11 -
    2.12  #define bitmaskof(idx)  (1U << ((idx) & 31))
    2.13  static void svm_vmexit_do_cpuid(struct vmcb_struct *vmcb,
    2.14                                  struct cpu_user_regs *regs)
    2.15 @@ -1005,16 +1000,10 @@ static void svm_vmexit_do_cpuid(struct v
    2.16      switch ( input )
    2.17      {
    2.18      case 0x00000001:
    2.19 -        /* Clear out reserved bits. */
    2.20 -        ecx &= ~SVM_VCPU_CPUID_L1_ECX_RESERVED;
    2.21 -        edx &= ~SVM_VCPU_CPUID_L1_EDX_RESERVED;
    2.22 -
    2.23 -        /* Guest should only see one logical processor.
    2.24 -         * See details on page 23 of AMD CPUID Specification.
    2.25 -         */
    2.26 -        __clear_bit(X86_FEATURE_HT & 31, &edx);
    2.27 -        ebx &= 0xFF00FFFF;  /* clear the logical processor count when HTT=0 */
    2.28 -        ebx |= 0x00010000;  /* set to 1 just for precaution */
    2.29 +        /* Mask Intel-only features. */
    2.30 +        ecx &= ~(bitmaskof(X86_FEATURE_SSSE3) |
    2.31 +                 bitmaskof(X86_FEATURE_SSE4_1) |
    2.32 +                 bitmaskof(X86_FEATURE_SSE4_2));
    2.33          break;
    2.34  
    2.35      case 0x80000001:
     3.1 --- a/xen/arch/x86/hvm/vmx/realmode.c	Thu Feb 07 09:28:55 2008 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmx/realmode.c	Thu Feb 07 10:31:48 2008 +0000
     3.3 @@ -18,7 +18,6 @@
     3.4  #include <asm/hvm/support.h>
     3.5  #include <asm/hvm/vmx/vmx.h>
     3.6  #include <asm/hvm/vmx/vmcs.h>
     3.7 -#include <asm/hvm/vmx/cpu.h>
     3.8  #include <asm/x86_emulate.h>
     3.9  
    3.10  struct realmode_emulate_ctxt {
     4.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 07 09:28:55 2008 +0000
     4.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 07 10:31:48 2008 +0000
     4.3 @@ -41,7 +41,6 @@
     4.4  #include <asm/hvm/support.h>
     4.5  #include <asm/hvm/vmx/vmx.h>
     4.6  #include <asm/hvm/vmx/vmcs.h>
     4.7 -#include <asm/hvm/vmx/cpu.h>
     4.8  #include <public/sched.h>
     4.9  #include <public/hvm/ioreq.h>
    4.10  #include <asm/hvm/vpic.h>
    4.11 @@ -1267,23 +1266,13 @@ void vmx_cpuid_intercept(
    4.12      switch ( input )
    4.13      {
    4.14      case 0x00000001:
    4.15 -        *ecx &= ~VMX_VCPU_CPUID_L1_ECX_RESERVED;
    4.16 -        *ebx &= NUM_THREADS_RESET_MASK;
    4.17 -        *ecx &= ~(bitmaskof(X86_FEATURE_VMXE) |
    4.18 -                  bitmaskof(X86_FEATURE_EST)  |
    4.19 -                  bitmaskof(X86_FEATURE_TM2)  |
    4.20 -                  bitmaskof(X86_FEATURE_CID)  |
    4.21 -                  bitmaskof(X86_FEATURE_PDCM) |
    4.22 -                  bitmaskof(X86_FEATURE_DSCPL));
    4.23 -        *edx &= ~(bitmaskof(X86_FEATURE_HT)   |
    4.24 -                  bitmaskof(X86_FEATURE_ACPI) |
    4.25 -                  bitmaskof(X86_FEATURE_ACC)  |
    4.26 -                  bitmaskof(X86_FEATURE_DS));
    4.27 +        /* Mask AMD-only features. */
    4.28 +        *ecx &= ~(bitmaskof(X86_FEATURE_POPCNT));
    4.29          break;
    4.30  
    4.31      case 0x00000004:
    4.32          cpuid_count(input, count, eax, ebx, ecx, edx);
    4.33 -        *eax &= NUM_CORES_RESET_MASK;
    4.34 +        *eax &= 0x3FFF; /* one core */
    4.35          break;
    4.36  
    4.37      case 0x00000006:
     5.1 --- a/xen/include/asm-x86/hvm/vmx/cpu.h	Thu Feb 07 09:28:55 2008 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,32 +0,0 @@
     5.4 -/*
     5.5 - * cpu.h: Virtual CPU state
     5.6 - * Copyright (c) 2004, Intel Corporation.
     5.7 - *
     5.8 - * This program is free software; you can redistribute it and/or modify it
     5.9 - * under the terms and conditions of the GNU General Public License,
    5.10 - * version 2, as published by the Free Software Foundation.
    5.11 - *
    5.12 - * This program is distributed in the hope it will be useful, but WITHOUT
    5.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    5.15 - * more details.
    5.16 - *
    5.17 - * You should have received a copy of the GNU General Public License along with
    5.18 - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    5.19 - * Place - Suite 330, Boston, MA 02111-1307 USA.
    5.20 - *
    5.21 - */
    5.22 -#ifndef __ASM_X86_HVM_VMX_CPU_H__
    5.23 -#define __ASM_X86_HVM_VMX_CPU_H__
    5.24 -
    5.25 -#define NUM_CORES_RESET_MASK                 0x00003FFF
    5.26 -#define NUM_THREADS_RESET_MASK               0xFF00FFFF
    5.27 -
    5.28 -#define VMX_VCPU_CPUID_L1_ECX_RESERVED_18    0x00040000
    5.29 -#define VMX_VCPU_CPUID_L1_ECX_RESERVED_6     0x00000040
    5.30 -
    5.31 -#define VMX_VCPU_CPUID_L1_ECX_RESERVED              \
    5.32 -            ( VMX_VCPU_CPUID_L1_ECX_RESERVED_18 |   \
    5.33 -              VMX_VCPU_CPUID_L1_ECX_RESERVED_6 )
    5.34 -
    5.35 -#endif /* __ASM_X86_HVM_VMX_CPU_H__ */
     6.1 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Thu Feb 07 09:28:55 2008 +0000
     6.2 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Thu Feb 07 10:31:48 2008 +0000
     6.3 @@ -21,7 +21,6 @@
     6.4  
     6.5  #include <asm/config.h>
     6.6  #include <asm/hvm/io.h>
     6.7 -#include <asm/hvm/vmx/cpu.h>
     6.8  #include <asm/hvm/vmx/vpmu.h>
     6.9  
    6.10  extern void start_vmx(void);