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 4/9] KVM: arm64: Discard a pending SError when resetting a vcpu
Date: Fri, 04 Dec 2026 09:03:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-249459@kernel.org> (raw)
In-Reply-To: <20261204-double_exception_v4-v4-4-523921511673@pereq.eu>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: arm64: non-atomic hcr_el2 RMW in kvm_reset_vcpu() races
with KVM_IRQ_LINE
--
commit 410049e49c865f69ca46cd29eb464dfffe46ce36
Author: Dan Carpenter <dan@pereq.eu>
KVM: arm64: Discard a pending SError when resetting a vcpu
This commit clears HCR_EL2_VSE in kvm_reset_vcpu() so a pending SError is
discarded when resetting a vCPU.
> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> index 26081d2734087..4b1917b48edcb 100644
> --- a/arch/arm64/kvm/reset.c
> +++ b/arch/arm64/kvm/reset.c
> @@ -204,6 +204,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
> /* Reset system registers */
> kvm_reset_sys_regs(vcpu);
>
> + /* Discard a pending SError */
> + vcpu->arch.hcr_el2 &= ~HCR_EL2_VSE;
[Severity: Medium]
Can this non-atomic read-modify-write on vcpu->arch.hcr_el2 race with
KVM_IRQ_LINE?
For a VM with a userspace irqchip, kvm_vm_ioctl_irq_line() calls
vcpu_interrupt_line() without holding vcpu->mutex and updates HCR_EL2_VI
or HCR_EL2_VF in vcpu->arch.hcr_el2 via test_and_set_bit() or
test_and_clear_bit().
CPU0 CPU1
kvm_reset_vcpu() kvm_vm_ioctl_irq_line()
val = vcpu->arch.hcr_el2 vcpu_interrupt_line()
test_and_set_bit(VI, hcr)
vcpu->arch.hcr_el2 = val & ~VSE <-- overwrites HCR_EL2_VI
If KVM_IRQ_LINE runs between the load and store in kvm_reset_vcpu(), the
store writes back stale HCR_EL2_VI or HCR_EL2_VF bits and the guest can
miss a virtual IRQ or FIQ transition.
Using clear_bit(__ffs(HCR_EL2_VSE), vcpu_hcr(vcpu)) would match
vcpu_interrupt_line() and avoid this data race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-double_exception_v4-v4-0-523921511673@pereq.eu?part=4
next prev parent reply other threads:[~2026-12-04 9:03 UTC|newest]
Thread overview: 15+ 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 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 [this message]
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
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-249459@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox