public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Add a helper to dedup reporting of unhandled VM-Exits
Date: Tue, 4 Nov 2025 09:16:08 -0800	[thread overview]
Message-ID: <aQo02LpJ5IfNzVD3@google.com> (raw)
In-Reply-To: <ojg5bq2guzb6hk7q7n2przo2ygkra6boavhhq7u5kptygu6jij@5nvgdi3preqg>

On Mon, Nov 03, 2025, Yosry Ahmed wrote:
> On Thu, Oct 30, 2025 at 11:50:03AM -0700, Sean Christopherson wrote:
> > Add and use a helper, kvm_prepare_unexpected_reason_exit(), to dedup the
> > code that fills the exit reason and CPU when KVM encounters a VM-Exit that
> > KVM doesn't know how to handle.
> > 
> > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > ---
> >  arch/x86/include/asm/kvm_host.h |  1 +
> >  arch/x86/kvm/svm/svm.c          |  7 +------
> >  arch/x86/kvm/vmx/tdx.c          |  6 +-----
> >  arch/x86/kvm/vmx/vmx.c          |  9 +--------
> >  arch/x86/kvm/x86.c              | 12 ++++++++++++
> >  5 files changed, 16 insertions(+), 19 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index 48598d017d6f..4fbe4b7ce1da 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -2167,6 +2167,7 @@ void __kvm_prepare_emulation_failure_exit(struct kvm_vcpu *vcpu,
> >  void kvm_prepare_emulation_failure_exit(struct kvm_vcpu *vcpu);
> >  
> >  void kvm_prepare_event_vectoring_exit(struct kvm_vcpu *vcpu, gpa_t gpa);
> > +void kvm_prepare_unexpected_reason_exit(struct kvm_vcpu *vcpu, u64 exit_reason);
> >  
> >  void kvm_enable_efer_bits(u64);
> >  bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> > index f14709a511aa..83e0d4d5f4c5 100644
> > --- a/arch/x86/kvm/svm/svm.c
> > +++ b/arch/x86/kvm/svm/svm.c
> > @@ -3451,13 +3451,8 @@ static bool svm_check_exit_valid(u64 exit_code)
> >  
> >  static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)
> >  {
> > -	vcpu_unimpl(vcpu, "svm: unexpected exit reason 0x%llx\n", exit_code);
> >  	dump_vmcb(vcpu);
> > -	vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> > -	vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON;
> > -	vcpu->run->internal.ndata = 2;
> > -	vcpu->run->internal.data[0] = exit_code;
> > -	vcpu->run->internal.data[1] = vcpu->arch.last_vmentry_cpu;
> > +	kvm_prepare_unexpected_reason_exit(vcpu, exit_code);
> >  	return 0;
> >  }
> 
> We can probably drop svm_handle_invalid_exit() entirely now

Hmm, yeah.  I'll do so in a separate follow-up, as I want to do more than just
fold svm_handle_invalid_exit() into svm_invoke_exit_handler().

  reply	other threads:[~2025-11-04 17:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-30 18:50 [PATCH] KVM: x86: Add a helper to dedup reporting of unhandled VM-Exits Sean Christopherson
2025-10-31  5:44 ` Yao Yuan
2025-10-31 17:01   ` Sean Christopherson
2025-11-01  1:49     ` Yao Yuan
2025-10-31 10:10 ` Huang, Kai
2025-10-31 11:18 ` Gupta, Pankaj
2025-11-03 17:37 ` Yosry Ahmed
2025-11-04 17:16   ` Sean Christopherson [this message]
2025-11-04  2:00 ` Xiaoyao Li
2025-11-04  3:03 ` Binbin Wu
2025-11-04 17:45 ` Sean Christopherson

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=aQo02LpJ5IfNzVD3@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yosry.ahmed@linux.dev \
    /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