From: sashiko-bot@kernel.org
To: "Dan Carpenter" <dan@pereq.eu>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
"Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 8/9] KVM: arm64: nv: Re-inject a stored SError after the exit is handled
Date: Fri, 04 Dec 2026 09:22:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-249495@kernel.org> (raw)
In-Reply-To: <20261204-double_exception_v4-v4-8-523921511673@pereq.eu>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: arm64: premature SError flush on aborted KVM_RUN entry
--
commit 7423847623949f2a8f284b19a9a62edd87bac9cd
Author: Dan Carpenter <dan@pereq.eu>
KVM: arm64: nv: Re-inject a stored SError after the exit is handled
This commit defers re-injecting a stored nested SError from
kvm_nested_sync_hwstate() to kvm_nested_flush_hwstate(), committing any
pending exit-handler exception or PC increment first via __kvm_adjust_pc().
It also updates kvm_arch_vcpu_runnable() so a deliverable stored SError wakes
the vCPU.
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 78d5b18dbd2d6..f063c01c565a0 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -2213,8 +2213,11 @@ void kvm_nested_flush_hwstate(struct kvm_vcpu *vcpu)
> if (!vcpu_has_nv(vcpu))
> return;
>
> - if (unlikely(vcpu_test_and_clear_flag(vcpu, NESTED_SERROR_PENDING)))
> + if (unlikely(vcpu_test_and_clear_flag(vcpu, NESTED_SERROR_PENDING))) {
> + /* Commit the exit handler's exception first */
> + __kvm_adjust_pc(vcpu);
> kvm_inject_serror_esr(vcpu, vcpu_get_vsesr(vcpu));
> + }
>
> vgic_v3_nested_update_mi(vcpu);
[Severity: Medium]
Can kvm_nested_flush_hwstate() consume NESTED_SERROR_PENDING and inject the
SError even when guest entry is aborted?
kvm_arch_vcpu_ioctl_run() calls kvm_nested_flush_hwstate() unconditionally
before checking ret <= 0 or kvm_vcpu_exit_request():
arch/arm64/kvm/arm.c:kvm_arch_vcpu_ioctl_run() {
...
if (ret > 0)
ret = check_vcpu_requests(vcpu);
...
kvm_nested_flush_hwstate(vcpu);
local_irq_disable();
...
if (ret <= 0 || kvm_vcpu_exit_request(vcpu, &ret)) {
...
}
If a signal makes kvm_xfer_to_guest_mode_handle_work() return -EINTR on a
suspended vCPU with an unmasked or EL2-routed NESTED_SERROR_PENDING,
check_vcpu_requests() is skipped, yet kvm_nested_flush_hwstate() still clears
NESTED_SERROR_PENDING and injects the SError.
The out: path then commits that exception via __kvm_adjust_pc() into the
still-suspended vCPU. On the next KVM_RUN, kvm_vcpu_suspend() sees neither
HCR_EL2_VSE nor NESTED_SERROR_PENDING set and blocks indefinitely instead of
reporting KVM_SYSTEM_EVENT_WAKEUP.
Even without a signal, kvm_vcpu_suspend() returns 0 for
KVM_SYSTEM_EVENT_WAKEUP while keeping the vCPU suspended, so
kvm_nested_flush_hwstate() still consumes NESTED_SERROR_PENDING and mutates
the suspended vCPU's registers before returning to userspace.
Deferring the NESTED_SERROR_PENDING injection until after the ret <= 0 and
kvm_vcpu_exit_request() check would avoid mutating vCPU state on aborted
entries.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-double_exception_v4-v4-0-523921511673@pereq.eu?part=8
next prev parent reply other threads:[~2026-12-04 9:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:48 [PATCH v4 0/9] KVM: arm64: Fix kvm_reset_vcpu() and SError handling for nested virt Dan Carpenter
2026-12-04 8:48 ` [PATCH v4 1/9] KVM: arm64: nv: Use a vcpu request to reprogram the PMU Dan Carpenter
2026-12-04 8:48 ` [PATCH v4 2/9] KVM: arm64: Drop an incomplete MMIO access when resetting a vcpu Dan Carpenter
2026-12-04 9:24 ` Steffen Eiden
2026-12-04 8:48 ` [PATCH v4 3/9] KVM: arm64: Reset SP_EL1, ELR_EL1 and SPSR_EL1 " Dan Carpenter
2026-12-04 8:48 ` [PATCH v4 4/9] KVM: arm64: Discard a pending SError " Dan Carpenter
2026-12-04 9:03 ` sashiko-bot
2026-12-04 8:48 ` [PATCH v4 5/9] KVM: arm64: nv: Discard nested SError in kvm_reset_vcpu() Dan Carpenter
2026-12-04 9:03 ` sashiko-bot
2026-12-04 8:48 ` [PATCH v4 6/9] KVM: arm64: nv: Replace a pending SError when injecting a new one Dan Carpenter
2026-12-04 8:48 ` [PATCH v4 7/9] KVM: arm64: nv: Don't deliver a pending SError to the wrong guest Dan Carpenter
2026-12-04 9:17 ` sashiko-bot
2026-12-04 8:48 ` [PATCH v4 8/9] KVM: arm64: nv: Re-inject a stored SError after the exit is handled Dan Carpenter
2026-12-04 9:22 ` sashiko-bot [this message]
2026-12-04 14:23 ` Dan Carpenter
2026-12-04 8:48 ` [PATCH v4 9/9] KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state Dan Carpenter
2026-12-04 9:20 ` sashiko-bot
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=sashiko-outbox-249495@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dan@pereq.eu \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.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 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.