From: Sean Christopherson <seanjc@google.com>
To: Yosry Ahmed <yosry@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Kevin Cheng <chengkev@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Drop redundant call to kvm_deliver_exception_payload()
Date: Mon, 2 Mar 2026 07:51:59 -0800 [thread overview]
Message-ID: <aaWyHyB91OolxRD7@google.com> (raw)
In-Reply-To: <20260302154249.784529-1-yosry@kernel.org>
On Mon, Mar 02, 2026, Yosry Ahmed wrote:
> In kvm_check_and_inject_events(), kvm_deliver_exception_payload() is
> called for pending #DB exceptions. However, shortly after, the
> per-vendor inject_exception callbacks are made. Both
> vmx_inject_exception() and svm_inject_exception() unconditionally call
> kvm_deliver_exception_payload(), so the call in
> kvm_check_and_inject_events() is redundant.
>
> Note that the extra call for pending #DB exceptions is harmless, as
> kvm_deliver_exception_payload() clears exception.has_payload after the
> first call.
>
> The call in kvm_check_and_inject_events() was added in commit
> f10c729ff965 ("kvm: vmx: Defer setting of DR6 until #DB delivery"). At
> that point, the call was likely needed because svm_queue_exception()
> checked whether an exception for L2 is intercepted by L1 before calling
> kvm_deliver_exception_payload(), as SVM did not have a
> check_nested_events callback. Since DR6 is updated before the #DB
> intercept in SVM (unlike VMX), it was necessary to deliver the DR6
> payload before calling svm_queue_exception().
>
> After that, commit 7c86663b68ba ("KVM: nSVM: inject exceptions via
> svm_check_nested_events") added a check_nested_events callback for SVM,
> which checked for L1 intercepts for L2's exceptions, and delivered the
> the payload appropriately before the intercept. At that point,
> svm_queue_exception() started calling kvm_deliver_exception_payload()
> unconditionally, and the call to kvm_deliver_exception_payload() from
> its caller became redundant.
Nice! I vaguely remember staring at this code when working on 5623f751bd9c
("KVM: x86: Treat #DBs from the emulator as fault-like (code and DR7.GD=1)"),
but never pieced together that it was redundant.
next prev parent reply other threads:[~2026-03-02 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 15:42 [PATCH] KVM: x86: Drop redundant call to kvm_deliver_exception_payload() Yosry Ahmed
2026-03-02 15:51 ` Sean Christopherson [this message]
2026-03-02 15:55 ` Yosry Ahmed
2026-03-05 17:07 ` 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=aaWyHyB91OolxRD7@google.com \
--to=seanjc@google.com \
--cc=chengkev@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yosry@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.