Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751061AbdHWVZT (ORCPT ); Wed, 23 Aug 2017 17:25:19 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35782 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbdHWVZR (ORCPT ); Wed, 23 Aug 2017 17:25:17 -0400 X-Google-Smtp-Source: ADKCNb7+Ypf1Pz+w31E8u24v9OCyf09T+eF6D14OVo23EnxTHZaMHp1yMiOe38AEZgMmWLNGe0HAteyht2PH+HzLQ4I= MIME-Version: 1.0 In-Reply-To: <1503521038-21073-2-git-send-email-pbonzini@redhat.com> References: <1503521038-21073-1-git-send-email-pbonzini@redhat.com> <1503521038-21073-2-git-send-email-pbonzini@redhat.com> From: Jim Mattson Date: Wed, 23 Aug 2017 14:25:15 -0700 Message-ID: Subject: Re: [PATCH 1/4] KVM: nVMX: move vmentry tasks from prepare_vmcs12 to enter_vmx_non_root_mode To: Paolo Bonzini Cc: LKML , kvm list , Wanpeng Li , David Hildenbrand , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2173 Lines: 52 On Wed, Aug 23, 2017 at 1:43 PM, Paolo Bonzini 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 > --- > 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 > >