Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1718632 > unrolled thread

[PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2017-08-23 22:50 +0200
Last post2017-08-23 23:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode Paolo Bonzini <pbonzini@redhat.com> - 2017-08-23 22:50 +0200
    Re: [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode Jim Mattson <jmattson@google.com> - 2017-08-23 23:30 +0200
      Re: [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to  enter_vmx_non_root_mode Paolo Bonzini <pbonzini@redhat.com> - 2017-08-23 23:50 +0200

#1718632 — [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode

FromPaolo Bonzini <pbonzini@redhat.com>
Date2017-08-23 22:50 +0200
Subject[PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode
Message-ID<uhKL8-5jQ-11@gated-at.bofh.it>
Setting the VMCS12 to launched and clearing the vm_entry_intr_info_field
was done as part of L0->L1 exit in prepare_vmcs12.  In order to simplify
prepare_vmcs12, move this to enter_vmx_non_root_mode since at this point
we've already committed to vmentry.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/vmx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 19aa69af7c2d..01c29b6af254 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -10752,6 +10752,13 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
 	 * returned as far as L1 is concerned. It will only return (and set
 	 * the success flag) when L2 exits (see nested_vmx_vmexit()).
 	 */
+	if (from_vmentry) {
+		vmcs12->launch_state = 1;
+
+		/* vm_entry_intr_info_field is cleared on exit. Emulate this
+		 * instead of reading the real value. */
+		vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;
+	}
 	return 0;
 }
 
@@ -11121,12 +11128,6 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
 	vmcs12->vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
 
 	if (!(vmcs12->vm_exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY)) {
-		vmcs12->launch_state = 1;
-
-		/* vm_entry_intr_info_field is cleared on exit. Emulate this
-		 * instead of reading the real value. */
-		vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;
-
 		/*
 		 * Transfer the event that L0 or L1 may wanted to inject into
 		 * L2 to IDT_VECTORING_INFO_FIELD.
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1718658

FromJim Mattson <jmattson@google.com>
Date2017-08-23 23:30 +0200
Message-ID<uhLnQ-5N6-19@gated-at.bofh.it>
In reply to#1718632
On Wed, Aug 23, 2017 at 1:43 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Setting the VMCS12 to launched and clearing the vm_entry_intr_info_field
> was done as part of L0->L1 exit in prepare_vmcs12.  In order to simplify
> prepare_vmcs12, move this to enter_vmx_non_root_mode since at this point
> we've already committed to vmentry.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 19aa69af7c2d..01c29b6af254 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -10752,6 +10752,13 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
>          * returned as far as L1 is concerned. It will only return (and set
>          * the success flag) when L2 exits (see nested_vmx_vmexit()).
>          */
> +       if (from_vmentry) {
> +               vmcs12->launch_state = 1;

Because we defer most guest state validity checks to the hardware
vmlaunch of the vmcs02, it is too early to set the vmcs12 launched
state here. If the exit reason has the high bit set,
vmcs12->launch_state should not be modified.

> +
> +               /* vm_entry_intr_info_field is cleared on exit. Emulate this
> +                * instead of reading the real value. */
> +               vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;
> +       }
>         return 0;
>  }
>
> @@ -11121,12 +11128,6 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
>         vmcs12->vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
>
>         if (!(vmcs12->vm_exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY)) {
> -               vmcs12->launch_state = 1;
> -
> -               /* vm_entry_intr_info_field is cleared on exit. Emulate this
> -                * instead of reading the real value. */
> -               vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;
> -
>                 /*
>                  * Transfer the event that L0 or L1 may wanted to inject into
>                  * L2 to IDT_VECTORING_INFO_FIELD.
> --
> 1.8.3.1
>
>

[toc] | [prev] | [next] | [standalone]


#1718666 — Re: [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode

FromPaolo Bonzini <pbonzini@redhat.com>
Date2017-08-23 23:50 +0200
SubjectRe: [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode
Message-ID<uhLHb-5Vg-1@gated-at.bofh.it>
In reply to#1718658
On 23/08/2017 23:25, Jim Mattson wrote:
>> +       if (from_vmentry) {
>> +               vmcs12->launch_state = 1;
> Because we defer most guest state validity checks to the hardware
> vmlaunch of the vmcs02, it is too early to set the vmcs12 launched
> state here. If the exit reason has the high bit set,
> vmcs12->launch_state should not be modified.

Thanks---I'll do my homework and add a testcase then. :)  The launched
state cannot be discovered with VMREAD, but I can test that a
VMLAUNCH;VMLAUNCH works and a VMLAUNCH;VMRESUME fails.

The same applies for the next instruction, which is part of step 6 of
the vmentry ("An event may be injected in the guest context").  This one
can be tested with VMREAD.

Paolo

>> +
>> +               /* vm_entry_intr_info_field is cleared on exit. Emulate this
>> +                * instead of reading the real value. */
>> +               vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web