linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xiaoyao Li <xiaoyao.li@intel.com>
Subject: Re: [PATCH 05/10] KVM: VMX: Convert local exit_reason to u16 in vmx_handle_exit()
Date: Fri, 13 Mar 2020 14:48:18 +0100	[thread overview]
Message-ID: <87sgicnz6l.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20200312184521.24579-6-sean.j.christopherson@intel.com>

Sean Christopherson <sean.j.christopherson@intel.com> writes:

> Convert the local "exit_reason" in vmx_handle_exit() from a u32 to a u16
> as most references expect to encounter only the basic exit reason.  Use
> vmx->exit_reason directly for paths that expect the full exit reason,
> i.e. to avoid having to figure out a decent name for a second local
> variable.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/vmx/vmx.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index c7715c880ea7..d43e1d28bb58 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -5844,10 +5844,10 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>  	enum exit_fastpath_completion exit_fastpath)
>  {
>  	struct vcpu_vmx *vmx = to_vmx(vcpu);
> -	u32 exit_reason = vmx->exit_reason;
>  	u32 vectoring_info = vmx->idt_vectoring_info;
> +	u16 exit_reason;
>  
> -	trace_kvm_exit(exit_reason, vcpu, KVM_ISA_VMX);
> +	trace_kvm_exit(vmx->exit_reason, vcpu, KVM_ISA_VMX);
>  
>  	/*
>  	 * Flush logged GPAs PML buffer, this will make dirty_bitmap more
> @@ -5866,11 +5866,11 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>  	if (is_guest_mode(vcpu) && nested_vmx_reflect_vmexit(vcpu))
>  		return 1;
>  
> -	if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
> +	if (vmx->exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
>  		dump_vmcs();
>  		vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
>  		vcpu->run->fail_entry.hardware_entry_failure_reason
> -			= exit_reason;
> +			= vmx->exit_reason;
>  		return 0;
>  	}
>  
> @@ -5882,6 +5882,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>  		return 0;
>  	}
>  
> +	exit_reason = vmx->exit_reason;
> +
>  	/*
>  	 * Note:
>  	 * Do not try to fix EXIT_REASON_EPT_MISCONFIG if it caused by
> @@ -5898,7 +5900,7 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>  		vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_DELIVERY_EV;
>  		vcpu->run->internal.ndata = 3;
>  		vcpu->run->internal.data[0] = vectoring_info;
> -		vcpu->run->internal.data[1] = exit_reason;
> +		vcpu->run->internal.data[1] = vmx->exit_reason;
>  		vcpu->run->internal.data[2] = vcpu->arch.exit_qualification;
>  		if (exit_reason == EXIT_REASON_EPT_MISCONFIG) {
>  			vcpu->run->internal.ndata++;
> @@ -5957,13 +5959,14 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>  	return kvm_vmx_exit_handlers[exit_reason](vcpu);
>  
>  unexpected_vmexit:
> -	vcpu_unimpl(vcpu, "vmx: unexpected exit reason 0x%x\n", exit_reason);
> +	vcpu_unimpl(vcpu, "vmx: unexpected exit reason 0x%x\n",
> +		    vmx->exit_reason);
>  	dump_vmcs();
>  	vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>  	vcpu->run->internal.suberror =
>  			KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON;
>  	vcpu->run->internal.ndata = 1;
> -	vcpu->run->internal.data[0] = exit_reason;
> +	vcpu->run->internal.data[0] = vmx->exit_reason;
>  	return 0;
>  }

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


  reply	other threads:[~2020-03-13 13:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 18:45 [PATCH 00/10] KVM: VMX: Unionize vcpu_vmx.exit_reason Sean Christopherson
2020-03-12 18:45 ` [PATCH 01/10] KVM: nVMX: Move reflection check into nested_vmx_reflect_vmexit() Sean Christopherson
2020-03-13 12:12   ` Vitaly Kuznetsov
2020-03-17  5:33     ` Sean Christopherson
2020-03-17 16:16       ` Sean Christopherson
2020-03-17 17:00         ` Vitaly Kuznetsov
2020-03-17 17:38           ` Paolo Bonzini
2020-03-17 18:01             ` Sean Christopherson
2020-03-12 18:45 ` [PATCH 02/10] KVM: nVMX: Drop a superfluous WARN on reflecting EXTERNAL_INTERRUPT Sean Christopherson
2020-03-13 12:14   ` Vitaly Kuznetsov
2020-03-12 18:45 ` [PATCH 03/10] KVM: nVMX: Pull exit_reason from vcpu_vmx in nested_vmx_exit_reflected() Sean Christopherson
2020-03-13 12:38   ` Vitaly Kuznetsov
2020-03-12 18:45 ` [PATCH 04/10] KVM: VMX: Convert local exit_reason to u16 " Sean Christopherson
2020-03-13 12:47   ` Vitaly Kuznetsov
2020-03-12 18:45 ` [PATCH 05/10] KVM: VMX: Convert local exit_reason to u16 in vmx_handle_exit() Sean Christopherson
2020-03-13 13:48   ` Vitaly Kuznetsov [this message]
2020-03-12 18:45 ` [PATCH 06/10] KVM: nVMX: Convert local exit_reason to u16 in ...enter_non_root_mode() Sean Christopherson
2020-03-13 13:55   ` Vitaly Kuznetsov
2020-03-13 14:00     ` David Laight
2020-03-17  5:29     ` Sean Christopherson
2020-03-17 17:40       ` Paolo Bonzini
2020-03-12 18:45 ` [PATCH 07/10] KVM: nVMX: Cast exit_reason to u16 to check for nested EXTERNAL_INTERRUPT Sean Christopherson
2020-03-13 13:56   ` Vitaly Kuznetsov
2020-03-12 18:45 ` [PATCH 08/10] KVM: nVMX: Rename exit_reason to vm_exit_reason for nested VM-Exit Sean Christopherson
2020-03-13 14:01   ` Vitaly Kuznetsov
2020-03-13 16:17     ` Sean Christopherson
2020-03-12 18:45 ` [PATCH 09/10] KVM: VMX: Cache vmx->exit_reason in local u16 in vmx_handle_exit_irqoff() Sean Christopherson
2020-03-13 14:09   ` Vitaly Kuznetsov
2020-03-17 17:50     ` Paolo Bonzini
2020-03-12 18:45 ` [PATCH 10/10] KVM: VMX: Convert vcpu_vmx.exit_reason to a union Sean Christopherson
2020-03-13 14:18   ` Vitaly Kuznetsov
2020-03-17  5:28     ` Sean Christopherson
2020-03-17 17:51       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgicnz6l.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=wanpengli@tencent.com \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).