[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k13opi6m.fsf@vitty.brq.redhat.com>
Date: Fri, 13 Mar 2020 13:12:33 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Xiaoyao Li <xiaoyao.li@...el.com>
Subject: Re: [PATCH 01/10] KVM: nVMX: Move reflection check into nested_vmx_reflect_vmexit()
Sean Christopherson <sean.j.christopherson@...el.com> writes:
> Move the call to nested_vmx_exit_reflected() from vmx_handle_exit() into
> nested_vmx_reflect_vmexit() and change the semantics of the return value
> for nested_vmx_reflect_vmexit() to indicate whether or not the exit was
> reflected into L1. nested_vmx_exit_reflected() and
> nested_vmx_reflect_vmexit() are intrinsically tied together, calling one
> without simultaneously calling the other makes little sense.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@...el.com>
> ---
> arch/x86/kvm/vmx/nested.h | 16 +++++++++++-----
> arch/x86/kvm/vmx/vmx.c | 4 ++--
> 2 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.h b/arch/x86/kvm/vmx/nested.h
> index 21d36652f213..6bc379cf4755 100644
> --- a/arch/x86/kvm/vmx/nested.h
> +++ b/arch/x86/kvm/vmx/nested.h
> @@ -72,12 +72,16 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)
> }
>
> /*
> - * Reflect a VM Exit into L1.
> + * Conditionally reflect a VM-Exit into L1. Returns %true if the VM-Exit was
> + * reflected into L1.
> */
> -static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
> - u32 exit_reason)
> +static inline bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
> + u32 exit_reason)
> {
> - u32 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
> + u32 exit_intr_info;
> +
> + if (!nested_vmx_exit_reflected(vcpu, exit_reason))
> + return false;
(unrelated to your patch)
It's probably just me but 'nested_vmx_exit_reflected()' name always
makes me thinkg 'the vmexit WAS [already] reflected' and not 'the vmexit
NEEDS to be reflected'. 'nested_vmx_exit_needs_reflecting()' maybe?
>
> /*
> * At this point, the exit interruption info in exit_intr_info
> @@ -85,6 +89,8 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
> * we need to query the in-kernel LAPIC.
> */
> WARN_ON(exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT);
> +
> + exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
> if ((exit_intr_info &
> (INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) ==
> (INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) {
> @@ -96,7 +102,7 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
>
> nested_vmx_vmexit(vcpu, exit_reason, exit_intr_info,
> vmcs_readl(EXIT_QUALIFICATION));
> - return 1;
> + return true;
> }
>
> /*
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 57742ddfd854..c1caac7e8f57 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -5863,8 +5863,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
> if (vmx->emulation_required)
> return handle_invalid_guest_state(vcpu);
>
> - if (is_guest_mode(vcpu) && nested_vmx_exit_reflected(vcpu, exit_reason))
> - return nested_vmx_reflect_vmexit(vcpu, exit_reason);
> + if (is_guest_mode(vcpu) && nested_vmx_reflect_vmexit(vcpu, exit_reason))
> + return 1;
>
> if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
> dump_vmcs();
Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>
--
Vitaly
Powered by blists - more mailing lists