Skip to contentSkip to conversation

Add support for FFXSR v2

PATCH Applied Alexander Graf 2 participants 4 messages Feb 2, 2009 – Feb 4, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add support for FFXSR v2

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.

v2 adds CPUID capability exposure

Alexander Graf (2):
Add EFER descriptions for FFXSR
Add FFXSR support to KVM v2

 arch/x86/include/asm/msr-index.h |    2 ++
 arch/x86/kvm/svm.c               |    3 +++
 arch/x86/kvm/x86.c               |   12 ++++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)
#1 lore raw

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
index 1890032..42378af 100644
@@ -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
#2 lore raw

PATCH 2/2 Add FFXSR support to KVM v2

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.

v2 adds CPUID capability exposure

---
 arch/x86/kvm/svm.c |    3 +++
 arch/x86/kvm/x86.c |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/x86/kvm/svm.c +3 -0
index db5021b..1c4a018 100644
@@ -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 +12 -0
index e96edda..8cb6e3f 100644
@@ -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;
 
@@ -1238,6 +1249,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 #ifdef CONFIG_X86_64
 		bit(X86_FEATURE_LM) |
 #endif
+		bit(X86_FEATURE_FXSR_OPT) |
 		bit(X86_FEATURE_MMXEXT) |
 		bit(X86_FEATURE_3DNOWEXT) |
 		bit(X86_FEATURE_3DNOW);
Signature · 1 line
1.6.0.2
Applied
#3 lore raw
In reply to Alexander Graf
Quoted 8 lines · Alexander Graf

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.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function