* [PATCH 1/4] X86: make EFER_RESERVED_BITS configurable for architecture code
[not found] ` <1201787860-20159-1-git-send-email-joerg.roedel-5C7GfCeVMHo@public.gmane.org>
@ 2008-01-31 13:57 ` Joerg Roedel
2008-01-31 13:57 ` [PATCH 2/4] X86: align valid EFER bits with the features of the host system Joerg Roedel
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2008-01-31 13:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Joerg Roedel
This patch give the SVM and VMX implementations the ability to add some bits
the guest can set in its EFER register.
Signed-off-by: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
---
arch/x86/kvm/x86.c | 9 ++++++++-
include/asm-x86/kvm_host.h | 1 +
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8f94a0b..55841a4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -41,7 +41,7 @@
| X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-#define EFER_RESERVED_BITS 0xfffffffffffff2fe
+static u64 __read_mostly EFER_RESERVED_BITS = 0xfffffffffffff2fe;
#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
@@ -449,6 +449,13 @@ static void set_efer(struct kvm_vcpu *vcpu, u64 efer)
#endif
+void kvm_enable_efer_bits(u64 mask)
+{
+ EFER_RESERVED_BITS &= ~mask;
+}
+EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
+
+
/*
* Writes msr value into into the appropriate "register".
* Returns 0 on success, non-0 otherwise.
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 67ae307..92668fa 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -429,6 +429,7 @@ void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr);
void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value,
unsigned long *rflags);
+void kvm_enable_efer_bits(u64);
int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data);
int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] X86: align valid EFER bits with the features of the host system
[not found] ` <1201787860-20159-1-git-send-email-joerg.roedel-5C7GfCeVMHo@public.gmane.org>
2008-01-31 13:57 ` [PATCH 1/4] X86: make EFER_RESERVED_BITS configurable for architecture code Joerg Roedel
@ 2008-01-31 13:57 ` Joerg Roedel
2008-01-31 13:57 ` [PATCH 3/4] VMX: unifdef the EFER specific code Joerg Roedel
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2008-01-31 13:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Joerg Roedel
This patch aligns the bits the guest can set in the EFER register with the
features in the host processor. Currently it lets EFER.NX disabled if the
processor does not support it and enables EFER.LME and EFER.LMA only for KVM on
64 bit hosts.
Signed-off-by: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
---
arch/x86/kvm/svm.c | 3 +++
arch/x86/kvm/vmx.c | 4 ++++
arch/x86/kvm/x86.c | 10 +++++++++-
3 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index d1c7fcb..df9cae3 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -403,6 +403,9 @@ static __init int svm_hardware_setup(void)
set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_ESP, 1, 1);
set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_EIP, 1, 1);
+ if (boot_cpu_has(X86_FEATURE_NX))
+ kvm_enable_efer_bits(EFER_NX);
+
for_each_online_cpu(cpu) {
r = svm_cpu_init(cpu);
if (r)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3d8949a..f66283a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1119,6 +1119,10 @@ static __init int hardware_setup(void)
{
if (setup_vmcs_config(&vmcs_config) < 0)
return -EIO;
+
+ if (boot_cpu_has(X86_FEATURE_NX))
+ kvm_enable_efer_bits(EFER_NX);
+
return alloc_kvm_area();
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 55841a4..76a0149 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -41,7 +41,15 @@
| X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-static u64 __read_mostly EFER_RESERVED_BITS = 0xfffffffffffff2fe;
+/* EFER defaults:
+ * - enable syscall per default because its emulated by KVM
+ * - enable LME and LMA per default on 64 bit KVM
+ */
+#ifdef CONFIG_X86_64
+static u64 __read_mostly EFER_RESERVED_BITS = 0xfffffffffffffafeULL;
+#else
+static u64 __read_mostly EFER_RESERVED_BITS = 0xfffffffffffffffeULL;
+#endif
#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] VMX: unifdef the EFER specific code
[not found] ` <1201787860-20159-1-git-send-email-joerg.roedel-5C7GfCeVMHo@public.gmane.org>
2008-01-31 13:57 ` [PATCH 1/4] X86: make EFER_RESERVED_BITS configurable for architecture code Joerg Roedel
2008-01-31 13:57 ` [PATCH 2/4] X86: align valid EFER bits with the features of the host system Joerg Roedel
@ 2008-01-31 13:57 ` Joerg Roedel
2008-01-31 13:57 ` [PATCH 4/4] X86: allow access to EFER in 32bit KVM Joerg Roedel
2008-01-31 16:16 ` [PATCH 0/4 try #2] Fix PAE guests on KVM 32 bit host Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2008-01-31 13:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Joerg Roedel
To allow access to the EFER register in 32bit KVM the EFER specific code has to
be exported to the x86 generic code. This patch does this in a backwards
compatible manner.
Signed-off-by: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
---
arch/x86/kvm/vmx.c | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f66283a..8496dbe 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1336,8 +1336,6 @@ static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
vcpu->arch.cr4 = cr4;
}
-#ifdef CONFIG_X86_64
-
static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -1360,8 +1358,6 @@ static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer)
setup_msrs(vmx);
}
-#endif
-
static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)
{
struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg];
@@ -1776,9 +1772,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
vmx->vcpu.arch.cr0 = 0x60000010;
vmx_set_cr0(&vmx->vcpu, vmx->vcpu.arch.cr0); /* enter rmode */
vmx_set_cr4(&vmx->vcpu, 0);
-#ifdef CONFIG_X86_64
vmx_set_efer(&vmx->vcpu, 0);
-#endif
vmx_fpu_activate(&vmx->vcpu);
update_exception_bitmap(&vmx->vcpu);
@@ -2666,9 +2660,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
.set_cr0 = vmx_set_cr0,
.set_cr3 = vmx_set_cr3,
.set_cr4 = vmx_set_cr4,
-#ifdef CONFIG_X86_64
.set_efer = vmx_set_efer,
-#endif
.get_idt = vmx_get_idt,
.set_idt = vmx_set_idt,
.get_gdt = vmx_get_gdt,
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] X86: allow access to EFER in 32bit KVM
[not found] ` <1201787860-20159-1-git-send-email-joerg.roedel-5C7GfCeVMHo@public.gmane.org>
` (2 preceding siblings ...)
2008-01-31 13:57 ` [PATCH 3/4] VMX: unifdef the EFER specific code Joerg Roedel
@ 2008-01-31 13:57 ` Joerg Roedel
2008-01-31 16:16 ` [PATCH 0/4 try #2] Fix PAE guests on KVM 32 bit host Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2008-01-31 13:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Joerg Roedel
This patch makes the EFER register accessible on a 32bit KVM host. This is
necessary to boot 32 bit PAE guests under SVM.
Signed-off-by: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
---
arch/x86/kvm/x86.c | 10 ----------
1 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 76a0149..ab01243 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -429,8 +429,6 @@ static u32 emulated_msrs[] = {
MSR_IA32_MISC_ENABLE,
};
-#ifdef CONFIG_X86_64
-
static void set_efer(struct kvm_vcpu *vcpu, u64 efer)
{
if (efer & EFER_RESERVED_BITS) {
@@ -455,8 +453,6 @@ static void set_efer(struct kvm_vcpu *vcpu, u64 efer)
vcpu->arch.shadow_efer = efer;
}
-#endif
-
void kvm_enable_efer_bits(u64 mask)
{
EFER_RESERVED_BITS &= ~mask;
@@ -486,11 +482,9 @@ static int do_set_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
{
switch (msr) {
-#ifdef CONFIG_X86_64
case MSR_EFER:
set_efer(vcpu, data);
break;
-#endif
case MSR_IA32_MC0_STATUS:
pr_unimpl(vcpu, "%s: MSR_IA32_MC0_STATUS 0x%llx, nop\n",
__FUNCTION__, data);
@@ -563,11 +557,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
case MSR_IA32_MISC_ENABLE:
data = vcpu->arch.ia32_misc_enable_msr;
break;
-#ifdef CONFIG_X86_64
case MSR_EFER:
data = vcpu->arch.shadow_efer;
break;
-#endif
default:
pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
return 1;
@@ -2868,9 +2860,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
set_cr8(vcpu, sregs->cr8);
mmu_reset_needed |= vcpu->arch.shadow_efer != sregs->efer;
-#ifdef CONFIG_X86_64
kvm_x86_ops->set_efer(vcpu, sregs->efer);
-#endif
kvm_set_apic_base(vcpu, sregs->apic_base);
kvm_x86_ops->decache_cr4_guest_bits(vcpu);
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4 try #2] Fix PAE guests on KVM 32 bit host
[not found] ` <1201787860-20159-1-git-send-email-joerg.roedel-5C7GfCeVMHo@public.gmane.org>
` (3 preceding siblings ...)
2008-01-31 13:57 ` [PATCH 4/4] X86: allow access to EFER in 32bit KVM Joerg Roedel
@ 2008-01-31 16:16 ` Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2008-01-31 16:16 UTC (permalink / raw)
To: Joerg Roedel; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Joerg Roedel wrote:
> This series of patches fixes a boot problem with PAE guests on a 32 bit
> KVM host. These guests try to access the EFER register when running on AMD, get
> an GP and crashing very soon in the boot process. These patches fix that. They
> were tested with 32 bit legacy and PAE Linux and Vista 32 bit.
>
Applied this (decapitalising EFER_RESERVED_BITS, ugh), thanks. I still
expect problems from the EFER-less processors, we'll have to watch out
for them.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 6+ messages in thread