* [PATCH] KVM: nVMX: Provide EFER.LMA saving support
@ 2013-03-13 15:06 Jan Kiszka
2013-03-13 16:31 ` Paolo Bonzini
2013-03-14 8:01 ` Gleb Natapov
0 siblings, 2 replies; 3+ messages in thread
From: Jan Kiszka @ 2013-03-13 15:06 UTC (permalink / raw)
To: Gleb Natapov, Marcelo Tosatti
Cc: kvm, Paolo Bonzini, Nadav Har'El, Nakajima, Jun
We will need EFER.LMA saving to provide unrestricted guest mode. All
what is missing for this is picking up EFER.LMA from VM_ENTRY_CONTROLS
on L2->L1 switches. If the host does not support EFER.LMA saving,
no change is performed, otherwise we properly emulate for L1 what the
hardware does for L0. Advertise the support, depending on the host
feature.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
It's not yet very helpful for upstream - due to lacking nEPT, but it is
also minimal invasive and helps cleaning my queue. Finally some bits
are needed also for the preemption timer support posted earlier today.
arch/x86/include/asm/vmx.h | 2 ++
arch/x86/kvm/vmx.c | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 5fb6e24..e1cc048c 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -93,6 +93,8 @@
#define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff
+#define VMX_MISC_SAVE_EFER_LMA 0x00000020
+
/* VMCS Encodings */
enum vmcs_field {
VIRTUAL_PROCESSOR_ID = 0x00000000,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b73989d..d4a747f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2022,6 +2022,7 @@ static u32 nested_vmx_secondary_ctls_low, nested_vmx_secondary_ctls_high;
static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high;
static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high;
static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high;
+static u32 nested_vmx_misc_low, nested_vmx_misc_high;
static __init void nested_vmx_setup_ctls_msrs(void)
{
/*
@@ -2104,6 +2105,11 @@ static __init void nested_vmx_setup_ctls_msrs(void)
nested_vmx_secondary_ctls_high &=
SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
SECONDARY_EXEC_WBINVD_EXITING;
+
+ /* miscellaneous data */
+ rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high);
+ nested_vmx_misc_low &= VMX_MISC_SAVE_EFER_LMA;
+ nested_vmx_misc_high = 0;
}
static inline bool vmx_control_verify(u32 control, u32 low, u32 high)
@@ -2174,7 +2180,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
nested_vmx_entry_ctls_high);
break;
case MSR_IA32_VMX_MISC:
- *pdata = 0;
+ *pdata = vmx_control_msr(nested_vmx_misc_low,
+ nested_vmx_misc_high);
break;
/*
* These MSRs specify bits which the guest must keep fixed (on or off)
@@ -7397,6 +7404,10 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
vmcs12->guest_pending_dbg_exceptions =
vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS);
+ vmcs12->vm_entry_controls =
+ (vmcs12->vm_entry_controls & ~VM_ENTRY_IA32E_MODE) |
+ (vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_IA32E_MODE);
+
/* TODO: These cannot have changed unless we have MSR bitmaps and
* the relevant bit asks not to trap the change */
vmcs12->guest_ia32_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Provide EFER.LMA saving support
2013-03-13 15:06 [PATCH] KVM: nVMX: Provide EFER.LMA saving support Jan Kiszka
@ 2013-03-13 16:31 ` Paolo Bonzini
2013-03-14 8:01 ` Gleb Natapov
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2013-03-13 16:31 UTC (permalink / raw)
To: Jan Kiszka
Cc: Gleb Natapov, Marcelo Tosatti, kvm, Nadav Har'El,
Nakajima, Jun
Il 13/03/2013 16:06, Jan Kiszka ha scritto:
> We will need EFER.LMA saving to provide unrestricted guest mode. All
> what is missing for this is picking up EFER.LMA from VM_ENTRY_CONTROLS
> on L2->L1 switches. If the host does not support EFER.LMA saving,
> no change is performed, otherwise we properly emulate for L1 what the
> hardware does for L0. Advertise the support, depending on the host
> feature.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> It's not yet very helpful for upstream - due to lacking nEPT, but it is
> also minimal invasive and helps cleaning my queue. Finally some bits
> are needed also for the preemption timer support posted earlier today.
>
> arch/x86/include/asm/vmx.h | 2 ++
> arch/x86/kvm/vmx.c | 13 ++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index 5fb6e24..e1cc048c 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -93,6 +93,8 @@
>
> #define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff
>
> +#define VMX_MISC_SAVE_EFER_LMA 0x00000020
> +
> /* VMCS Encodings */
> enum vmcs_field {
> VIRTUAL_PROCESSOR_ID = 0x00000000,
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index b73989d..d4a747f 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2022,6 +2022,7 @@ static u32 nested_vmx_secondary_ctls_low, nested_vmx_secondary_ctls_high;
> static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high;
> static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high;
> static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high;
> +static u32 nested_vmx_misc_low, nested_vmx_misc_high;
> static __init void nested_vmx_setup_ctls_msrs(void)
> {
> /*
> @@ -2104,6 +2105,11 @@ static __init void nested_vmx_setup_ctls_msrs(void)
> nested_vmx_secondary_ctls_high &=
> SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
> SECONDARY_EXEC_WBINVD_EXITING;
> +
> + /* miscellaneous data */
> + rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high);
> + nested_vmx_misc_low &= VMX_MISC_SAVE_EFER_LMA;
> + nested_vmx_misc_high = 0;
> }
>
> static inline bool vmx_control_verify(u32 control, u32 low, u32 high)
> @@ -2174,7 +2180,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
> nested_vmx_entry_ctls_high);
> break;
> case MSR_IA32_VMX_MISC:
> - *pdata = 0;
> + *pdata = vmx_control_msr(nested_vmx_misc_low,
> + nested_vmx_misc_high);
> break;
> /*
> * These MSRs specify bits which the guest must keep fixed (on or off)
> @@ -7397,6 +7404,10 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
> vmcs12->guest_pending_dbg_exceptions =
> vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS);
>
> + vmcs12->vm_entry_controls =
> + (vmcs12->vm_entry_controls & ~VM_ENTRY_IA32E_MODE) |
> + (vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_IA32E_MODE);
> +
> /* TODO: These cannot have changed unless we have MSR bitmaps and
> * the relevant bit asks not to trap the change */
> vmcs12->guest_ia32_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Provide EFER.LMA saving support
2013-03-13 15:06 [PATCH] KVM: nVMX: Provide EFER.LMA saving support Jan Kiszka
2013-03-13 16:31 ` Paolo Bonzini
@ 2013-03-14 8:01 ` Gleb Natapov
1 sibling, 0 replies; 3+ messages in thread
From: Gleb Natapov @ 2013-03-14 8:01 UTC (permalink / raw)
To: Jan Kiszka
Cc: Marcelo Tosatti, kvm, Paolo Bonzini, Nadav Har'El,
Nakajima, Jun
On Wed, Mar 13, 2013 at 04:06:41PM +0100, Jan Kiszka wrote:
> We will need EFER.LMA saving to provide unrestricted guest mode. All
> what is missing for this is picking up EFER.LMA from VM_ENTRY_CONTROLS
> on L2->L1 switches. If the host does not support EFER.LMA saving,
> no change is performed, otherwise we properly emulate for L1 what the
> hardware does for L0. Advertise the support, depending on the host
> feature.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Applied, thanks.
> ---
>
> It's not yet very helpful for upstream - due to lacking nEPT, but it is
> also minimal invasive and helps cleaning my queue. Finally some bits
> are needed also for the preemption timer support posted earlier today.
>
> arch/x86/include/asm/vmx.h | 2 ++
> arch/x86/kvm/vmx.c | 13 ++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index 5fb6e24..e1cc048c 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -93,6 +93,8 @@
>
> #define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff
>
> +#define VMX_MISC_SAVE_EFER_LMA 0x00000020
> +
> /* VMCS Encodings */
> enum vmcs_field {
> VIRTUAL_PROCESSOR_ID = 0x00000000,
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index b73989d..d4a747f 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2022,6 +2022,7 @@ static u32 nested_vmx_secondary_ctls_low, nested_vmx_secondary_ctls_high;
> static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high;
> static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high;
> static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high;
> +static u32 nested_vmx_misc_low, nested_vmx_misc_high;
> static __init void nested_vmx_setup_ctls_msrs(void)
> {
> /*
> @@ -2104,6 +2105,11 @@ static __init void nested_vmx_setup_ctls_msrs(void)
> nested_vmx_secondary_ctls_high &=
> SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
> SECONDARY_EXEC_WBINVD_EXITING;
> +
> + /* miscellaneous data */
> + rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high);
> + nested_vmx_misc_low &= VMX_MISC_SAVE_EFER_LMA;
> + nested_vmx_misc_high = 0;
> }
>
> static inline bool vmx_control_verify(u32 control, u32 low, u32 high)
> @@ -2174,7 +2180,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
> nested_vmx_entry_ctls_high);
> break;
> case MSR_IA32_VMX_MISC:
> - *pdata = 0;
> + *pdata = vmx_control_msr(nested_vmx_misc_low,
> + nested_vmx_misc_high);
> break;
> /*
> * These MSRs specify bits which the guest must keep fixed (on or off)
> @@ -7397,6 +7404,10 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
> vmcs12->guest_pending_dbg_exceptions =
> vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS);
>
> + vmcs12->vm_entry_controls =
> + (vmcs12->vm_entry_controls & ~VM_ENTRY_IA32E_MODE) |
> + (vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_IA32E_MODE);
> +
> /* TODO: These cannot have changed unless we have MSR bitmaps and
> * the relevant bit asks not to trap the change */
> vmcs12->guest_ia32_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
> --
> 1.7.3.4
--
Gleb.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-14 8:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 15:06 [PATCH] KVM: nVMX: Provide EFER.LMA saving support Jan Kiszka
2013-03-13 16:31 ` Paolo Bonzini
2013-03-14 8:01 ` Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox