Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Steffen Eiden" <seiden@linux.ibm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-s390@vger.kernel.org, "Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 12/12] KVM: s390: arm64: Add IRQ line
Date: Wed, 02 Dec 2026 14:54:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-246014@kernel.org> (raw)
In-Reply-To: <20261202-smccc-v1-12-48340e2737b6@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: s390: arm64: non-atomic hcr_el2 RMW races with
  vcpu_interrupt_line()
--

commit d464d208b63e74e278a80c66b1b80eba93db96f6
Author: Andreas Grapentin <gra@linux.ibm.com>

KVM: s390: arm64: Add IRQ line

This commit implements KVM_IRQ_LINE support for arm64 guests on s390
with a userspace interrupt controller, exposing KVM_CAP_ARM_USER_IRQ,
updating kvm_arch_vcpu_runnable(), and preserving HCR_EL2 interrupt lines
across vCPU resets.

> diff --git a/arch/s390/kvm/arm64/reset.c b/arch/s390/kvm/arm64/reset.c
> index feec5009d2cbc..891fe4b4fc168 100644
> --- a/arch/s390/kvm/arm64/reset.c
> +++ b/arch/s390/kvm/arm64/reset.c
[ ... ]
> @@ -105,12 +105,14 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
>  	kvm_timer_vcpu_reset(vcpu);
>  
>  	/* Reset special registers */
> -	vcpu_reset_hcr(vcpu);
>  	vcpu_reset_hcrx(vcpu);
>  	vcpu_reset_cptr(vcpu);
>  	vcpu_reset_cnthctl(vcpu);
>  	vcpu_reset_icc(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
vcpu_interrupt_line() and drop a concurrent HCR_EL2_VI or HCR_EL2_VF
update?

KVM_IRQ_LINE is a VM ioctl that runs without vcpu->mutex and updates
HCR_EL2_VI and HCR_EL2_VF in vcpu->arch.hcr_el2 via test_and_set_bit()
and test_and_clear_bit().  Both kvm_reset_vcpu() here and
kvm_arch_vcpu_load() -> vcpu_set_pauth_traps() modify vcpu->arch.hcr_el2
with plain bitwise operations:

arch/s390/kvm/arm64/arm.c:vcpu_set_pauth_traps() {
	if (vcpu_has_ptrauth(vcpu))
		vcpu->arch.hcr_el2 |= (HCR_EL2_API | HCR_EL2_APK);
}

CPU0                              CPU1
kvm_arch_vcpu_load()
  vcpu_set_pauth_traps()
    tmp = vcpu->arch.hcr_el2
                                  kvm_vm_ioctl_irq_line()
                                    vcpu_interrupt_line()
                                      test_and_set_bit(..., hcr)
    vcpu->arch.hcr_el2 =
      tmp | HCR_EL2_API | ...  <-- overwrites HCR_EL2_VI/VF

When CPU0 writes back the stale value during vcpu_load() or a PSCI
CPU_ON reset, the guest can miss an asserted interrupt (for example when
waking from WFI) or keep a deasserted line asserted.  Using atomic bit
operations on vcpu_hcr(vcpu) (or setting static trap bits such as
HCR_EL2_API | HCR_EL2_APK in vcpu_reset_hcr()) would avoid clobbering
concurrent VI/VF updates.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-smccc-v1-0-48340e2737b6@linux.ibm.com?part=12

  reply	other threads:[~2026-12-02 14:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 14:11 [PATCH 00/12] KVM: s390: arm64: SMCCC, timers and IRQ line Steffen Eiden
2026-12-02 14:11 ` [PATCH 01/12] arm64: Prepare for sharing with s390 Steffen Eiden
2026-12-02 14:11 ` [PATCH 02/12] arm64: Share timer and smccc functionality " Steffen Eiden
2026-12-02 14:11 ` [PATCH 03/12] KVM: arm64: Share timer and smccc code " Steffen Eiden
2026-12-02 14:11 ` [PATCH 04/12] KVM: s390: arm64: Use register shadow helper Steffen Eiden
2026-12-02 14:11 ` [PATCH 05/12] KVM: s390: arm64: Shadow the guest timer CVAL registers Steffen Eiden
2026-12-02 14:11 ` [PATCH 06/12] KVM: s390: arm64: Use mpstate for guests Steffen Eiden
2026-12-02 14:11 ` [PATCH 07/12] KVM: s390: arm64: Enable full smccc support Steffen Eiden
2026-12-02 14:35   ` sashiko-bot
2026-12-02 14:11 ` [PATCH 08/12] KVM: s390: arm64: Report fwregs to userspace Steffen Eiden
2026-12-02 14:11 ` [PATCH 09/12] KVM: s390: arm64: Provide timer infrastructure Steffen Eiden
2026-12-02 14:26   ` sashiko-bot
2026-12-02 14:11 ` [PATCH 10/12] KVM: s390: arm64: Integrate guest timer Steffen Eiden
2026-12-02 14:34   ` sashiko-bot
2026-12-02 14:11 ` [PATCH 11/12] KVM: s390: arm64: Trap WFx Steffen Eiden
2026-12-02 14:11 ` [PATCH 12/12] KVM: s390: arm64: Add IRQ line Steffen Eiden
2026-12-02 14:54   ` sashiko-bot [this message]
2026-12-02 14:54 ` [PATCH 00/12] KVM: s390: arm64: SMCCC, timers and " 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-246014@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-s390@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seiden@linux.ibm.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