Add support for FFXSR
cover Add support for FFXSR
AMD k10 includes support for the FFXSR feature, which leaves out XMM registers on FXSAVE/FXSAVE when the EFER_FFXSR bit is set in EFER.
This patchset enables support for the FFXSR feature in KVM, allowing the VM to set the bit in EFER when the physical CPU and the guest's CPUID allow it.
Alexander Graf (2):
Add EFER descriptions for FFXSR
Add FFXSR support to KVM
arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kvm/svm.c | 3 +++ arch/x86/kvm/x86.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 0 deletions(-)
PATCH 1/2 Add EFER descriptions for FFXSR
AMD k10 includes support for the FFXSR feature, which leaves out XMM registers on FXSAVE/FXSAVE when the EFER_FFXSR bit is set in EFER.
The CPUID feature bit exists already, but the EFER bit is missing currently, so this patch adds it to the list of known EFER bits.
--- arch/x86/include/asm/msr-index.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/include/asm/msr-index.h +2 -0
@@ -19,12 +19,14 @@#define _EFER_LMA 10/* Long mode active (read-only) */ #define _EFER_NX 11/* No execute enable */ #define _EFER_SVME 12/* Enable virtualization */ +#define _EFER_FFXSR 14/* Enable Fast FXSAVE/FXRSTOR */ #define EFER_SCE (1<<_EFER_SCE)#define EFER_LME (1<<_EFER_LME)#define EFER_LMA (1<<_EFER_LMA)#define EFER_NX (1<<_EFER_NX)#define EFER_SVME (1<<_EFER_SVME) +#define EFER_FFXSR (1<<_EFER_FFXSR)/* Intel MSRs. Some also available on other CPUs */ #define MSR_IA32_PERFCTR0 0x000000c1
Signature · 1 line
1.6.0.2
PATCH 2/2 Add FFXSR support to KVM
AMD K10 CPUs implement the FFXSR feature that gets enabled using EFER. Let's check if the virtual CPU description includes that CPUID feature bit and allow enabling it then.
This is required for Windows Server 2008 in Hyper-V mode.
--- arch/x86/kvm/svm.c | 3 +++ arch/x86/kvm/x86.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
arch/x86/kvm/svm.c +3 -0
@@ -417,6 +417,9 @@ static __init int svm_hardware_setup(void)if (boot_cpu_has (X86_FEATURE_NX ))kvm_enable_efer_bits (EFER_NX ); +if (boot_cpu_has (X86_FEATURE_FXSR_OPT )) +kvm_enable_efer_bits (EFER_FFXSR ); +if (nested) {printk (KERN_INFO "kvm: Nested Virtualization enabled\n" );kvm_enable_efer_bits (EFER_SVME );
arch/x86/kvm/x86.c +11 -0
@@ -490,6 +490,17 @@ static void set_efer(struct kvm_vcpu *vcpu, u64 efer)return ; } +if (efer &EFER_FFXSR ) { +struct kvm_cpuid_entry2 *feat; + + feat =kvm_find_cpuid_entry (vcpu,0x80000001 ,0 ); +if (!feat || !(feat->edx &bit (X86_FEATURE_FXSR_OPT ))) { +printk (KERN_DEBUG "set_efer: #GP, enable FFXSR w/o CPUID capability\n" ); +kvm_inject_gp (vcpu,0 ); +return ; + } + } +if (efer &EFER_SVME ) {struct kvm_cpuid_entry2 *feat;
Signature · 1 line
1.6.0.2
Re: [PATCH 2/2] Add FFXSR support to KVM
Quoted 7 lines · Alexander Graf
AMD K10 CPUs implement the FFXSR feature that gets enabled using EFER. Let's check if the virtual CPU description includes that CPUID feature bit and allow enabling it then.
This is required for Windows Server 2008 in Hyper-V mode.
Need to advertise this in KVM_GET_SUPPORTED_CPUID. Otherwise, looks good.
Signature · 1 line
error compiling committee.c: too many arguments to function