[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] hvm: Clean up CPUID 0x80000001 emulation. Filter out RDTSCP feature
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1195727590 0 # Node ID 93d129d27f6998302874afba3367c9f28affa23e # Parent 05cbf512b82b2665d407395bac73b9cca0c396b4 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/arch/x86/hvm/svm/emulate.c | 4 ---- xen/arch/x86/hvm/svm/svm.c | 29 +++++++++++------------------ xen/arch/x86/hvm/vmx/vmx.c | 8 ++++++++ xen/include/asm-x86/hvm/svm/emulate.h | 2 -- 4 files changed, 19 insertions(+), 24 deletions(-) diff -r 05cbf512b82b -r 93d129d27f69 xen/arch/x86/hvm/svm/emulate.c --- a/xen/arch/x86/hvm/svm/emulate.c Wed Nov 21 14:36:07 2007 +0000 +++ b/xen/arch/x86/hvm/svm/emulate.c Thu Nov 22 10:33:10 2007 +0000 @@ -348,8 +348,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); @@ -383,8 +381,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 05cbf512b82b -r 93d129d27f69 xen/arch/x86/hvm/svm/svm.c --- a/xen/arch/x86/hvm/svm/svm.c Wed Nov 21 14:36:07 2007 +0000 +++ b/xen/arch/x86/hvm/svm/svm.c Thu Nov 22 10:33:10 2007 +0000 @@ -996,6 +996,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) { @@ -1022,32 +1023,23 @@ static void svm_vmexit_do_cpuid(struct v break; case 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); - __clear_bit(X86_FEATURE_SKINIT & 31, &ecx); - - __clear_bit(X86_FEATURE_OSVW & 31, &ecx); - __clear_bit(X86_FEATURE_WDT & 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); + /* 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) | + bitmaskof(X86_FEATURE_FFXSR)); break; case 0x80000007: @@ -2293,6 +2285,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 05cbf512b82b -r 93d129d27f69 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Wed Nov 21 14:36:07 2007 +0000 +++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Nov 22 10:33:10 2007 +0000 @@ -1298,6 +1298,14 @@ static void vmx_do_cpuid(struct cpu_user case 0x0000000A: eax = ebx = ecx = edx = 0; break; + + case 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)); + break; } regs->eax = eax; diff -r 05cbf512b82b -r 93d129d27f69 xen/include/asm-x86/hvm/svm/emulate.h --- a/xen/include/asm-x86/hvm/svm/emulate.h Wed Nov 21 14:36:07 2007 +0000 +++ b/xen/include/asm-x86/hvm/svm/emulate.h Thu Nov 22 10:33:10 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |