public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add support for FFXSR v2
@ 2009-02-02 15:23 Alexander Graf
  2009-02-02 15:23 ` [PATCH 1/2] Add EFER descriptions for FFXSR Alexander Graf
  2009-02-04 13:50 ` [PATCH 0/2] Add support for FFXSR v2 Avi Kivity
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Graf @ 2009-02-02 15:23 UTC (permalink / raw)
  To: kvm; +Cc: avi

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(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Add EFER descriptions for FFXSR
  2009-02-02 15:23 [PATCH 0/2] Add support for FFXSR v2 Alexander Graf
@ 2009-02-02 15:23 ` Alexander Graf
  2009-02-02 15:23   ` [PATCH 2/2] Add FFXSR support to KVM v2 Alexander Graf
  2009-02-04 13:50 ` [PATCH 0/2] Add support for FFXSR v2 Avi Kivity
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2009-02-02 15:23 UTC (permalink / raw)
  To: kvm; +Cc: avi, Joerg Roedel

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.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/include/asm/msr-index.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 1890032..42378af 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -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
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Add FFXSR support to KVM v2
  2009-02-02 15:23 ` [PATCH 1/2] Add EFER descriptions for FFXSR Alexander Graf
@ 2009-02-02 15:23   ` Alexander Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2009-02-02 15:23 UTC (permalink / raw)
  To: kvm; +Cc: avi

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

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/x86/kvm/svm.c |    3 +++
 arch/x86/kvm/x86.c |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index db5021b..1c4a018 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -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);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e96edda..8cb6e3f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -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);
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Add support for FFXSR v2
  2009-02-02 15:23 [PATCH 0/2] Add support for FFXSR v2 Alexander Graf
  2009-02-02 15:23 ` [PATCH 1/2] Add EFER descriptions for FFXSR Alexander Graf
@ 2009-02-04 13:50 ` Avi Kivity
  1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2009-02-04 13:50 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm

Alexander Graf wrote:
> 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.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-04 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-02 15:23 [PATCH 0/2] Add support for FFXSR v2 Alexander Graf
2009-02-02 15:23 ` [PATCH 1/2] Add EFER descriptions for FFXSR Alexander Graf
2009-02-02 15:23   ` [PATCH 2/2] Add FFXSR support to KVM v2 Alexander Graf
2009-02-04 13:50 ` [PATCH 0/2] Add support for FFXSR v2 Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox