From: sashiko-bot@kernel.org
To: "Steffen Eiden" <seiden@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
kvmarm@lists.linux.dev,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
"Marc Zyngier" <maz@kernel.org>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v8 26/29] KVM: s390: arm64: Implement vCPU IOCTLs
Date: Fri, 18 Sep 2026 17:45:08 +0000 [thread overview]
Message-ID: <20260918174508.C516D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918133107.1042730-27-seiden@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider:
- [Critical] kvm: guest memory corruption due to missing TLB flush on KVM_REQ_TLB_FLUSH
- [High] kvm: host-side hang due to sleepable operation inside SRCU read lock
- [High] kvm: missed IPIs and vCPU requests due to unprotected IN_GUEST_MODE transition
- [High] kvm: silent state corruption due to missing vcpu_load/put in ioctl dispatcher
- [High] kvm: ABBA deadlock via redundant vcpu_load() in kvm_arch_vcpu_ioctl_run
- [High] kvm: sleeping in atomic context in kvm_reset_vcpu()
- [High] kvm: Use-After-Free risk via enabled IRQs inside RCU Extended Quiescent State
- [Medium] kvm: host-userspace DoS via WARN_ONCE on SAE validity intercept
- [Medium] kvm: information leak via uninitialized KVM_EXIT_FAIL_ENTRY fields
--
commit ca6265bd830c0d19959272a1e3c2c5ff1c794f65
Author: Steffen Eiden <seiden@linux.ibm.com>
Subject: KVM: s390: arm64: Implement vCPU IOCTLs
Implement all required vCPU (arch) IOCTLs.
> diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c
> --- a/arch/s390/kvm/arm64/arm.c
> +++ b/arch/s390/kvm/arm64/arm.c
[ ... ]
> +static int check_vcpu_requests(struct kvm_vcpu *vcpu)
> +{
> + if (kvm_request_pending(vcpu)) {
> + if (kvm_check_request(KVM_REQ_VCPU_RESET, vcpu))
> + kvm_reset_vcpu(vcpu);
> + /*
> + * Clear IRQ_PENDING requests that were made to guarantee
> + * that a VCPU sees new virtual interrupts.
> + */
> + kvm_check_request(KVM_REQ_IRQ_PENDING, vcpu);
> + kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu);
[Severity: Critical]
This clears the KVM_REQ_TLB_FLUSH bit, but is the actual hardware TLB flush
instruction or gmap_tlb_flush() missing here? Could this allow the guest to
continue accessing physical memory using stale page table entries?
> + }
> +
> + return 1;
> +}
[ ... ]
> +static void arm_vcpu_run(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_sae_block *sae_block = &vcpu->arch.sae_block;
> +
> + adjust_pc(vcpu);
> +
> + local_irq_disable();
> + guest_timing_enter_irqoff();
> + guest_state_enter_irqoff();
> + local_irq_enable();
> +
> + sae64a(sae_block);
[Severity: High]
Are host interrupts being explicitly enabled right after
guest_state_enter_irqoff() transitions context tracking into an RCU Extended
Quiescent State? If a host interrupt fires here, could its handler execute
while RCU is suspended, risking a Use-After-Free?
> +
> + local_irq_disable();
> + guest_state_exit_irqoff();
> + guest_timing_exit_irqoff();
> + local_irq_enable();
> +}
[ ... ]
> +int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
> +{
> + DECLARE_KERNEL_FPU_ONSTACK32(fpu_save);
> + struct kvm_run *kvm_run = vcpu->run;
> + int ret;
> +
> + if (kvm_run->exit_reason == KVM_EXIT_MMIO) {
> + ret = kvm_handle_mmio_return(vcpu);
> + if (ret <= 0)
> + return ret;
> + }
> +
> + vcpu_load(vcpu);
[Severity: High]
Doesn't the generic KVM core code already acquire vcpu->mutex via
vcpu_load() before calling kvm_arch_vcpu_ioctl_run()? Could calling
vcpu_load() again here cause an immediate self-deadlock on vcpu->mutex?
> +
> + kernel_fpu_begin(&fpu_save, KERNEL_FPC | KERNEL_VXR);
> + load_vx_regs((vcpu->arch.ctxt.vregs));
[ ... ]
> + might_fault();
> +
> + kvm_vcpu_srcu_read_lock(vcpu);
> +
> + ret = 1;
> + while (ret > 0) {
> +
> + ret = kvm_xfer_to_guest_mode_handle_work(vcpu);
[Severity: High]
Does kvm_xfer_to_guest_mode_handle_work() perform sleepable operations
(like processing TIF_NEED_RESCHED or signals) while the SRCU read lock is
held? Might this stall the SRCU grace period indefinitely and hang the host
during VM operations like memslot updates?
> + if (!ret)
> + ret = 1;
> +
> + if (ret > 0)
> + ret = check_vcpu_requests(vcpu);
> +
> + if (ret <= 0)
> + break;
> +
> + vcpu->arch.sae_block.icptr = 0;
> +
> + smp_store_mb(vcpu->mode, IN_GUEST_MODE);
> +
> + if (kvm_request_pending(vcpu)) {
> + vcpu->mode = OUTSIDE_GUEST_MODE;
> + continue;
> + }
[Severity: High]
Is the transition to IN_GUEST_MODE and the check for pending requests
happening before local interrupts are disabled? If a concurrent vCPU kick
occurs immediately after the check, could the host handle the IPI and the
vCPU enter the guest without re-checking requests, thereby missing the kick?
> +
> + kvm_vcpu_srcu_read_unlock(vcpu);
> +
> + arm_vcpu_run(vcpu);
[ ... ]
> +long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
> +{
> + struct kvm_vcpu *vcpu = filp->private_data;
> + void __user *argp = (void __user *)arg;
> + struct kvm_device_attr attr;
> + int ret;
> +
> + switch (ioctl) {
> + case KVM_ARM_VCPU_INIT: {
> + struct kvm_vcpu_init init;
[Severity: High]
Do KVM_ARM_VCPU_INIT and KVM_SET_ONE_REG modify architectural state without
calling vcpu_load() and vcpu_put()? Could this lead to physical CPU state
corruption or leaked preempt notifiers if the vCPU is not properly bound to
the physical CPU during these modifications?
> +
> + ret = -EFAULT;
> + if (copy_from_user(&init, argp, sizeof(init)))
> + break;
[ ... ]
> diff --git a/arch/s390/kvm/arm64/handle_exit.c b/arch/s390/kvm/arm64/handle_exit.c
> --- a/arch/s390/kvm/arm64/handle_exit.c
> +++ b/arch/s390/kvm/arm64/handle_exit.c
[ ... ]
> +int handle_exit(struct kvm_vcpu *vcpu)
> +{
> + u8 icptr = vcpu->arch.sae_block.icptr;
> + int ret = 1;
> +
> + switch (icptr) {
> + case SAE_ICPTR_SPURIOUS:
> + break;
> + case SAE_ICPTR_VALIDITY:
> + WARN_ONCE(true, "SAE: validity intercept. vir: 0x%04x",
> + vcpu->arch.sae_block.vir);
[Severity: Medium]
Could this WARN_ONCE be triggered by an unprivileged host-userspace process
providing malformed VCPU state via ioctls? KVM guidelines generally forbid
userspace-reachable warnings since they can act as a denial of service if
panic_on_warn is set. Should this return an error instead?
> + vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> + ret = 0;
> + break;
[Severity: Medium]
Does this leave the hardware_entry_failure_reason and cpu fields of
vcpu->run->fail_entry uninitialized before returning to userspace? Could
this potentially leak stale kernel memory from the shared kvm_run union?
> + case SAE_ICPTR_GUEST_ADDRESS_SIZE:
[ ... ]
> diff --git a/arch/s390/kvm/arm64/reset.c b/arch/s390/kvm/arm64/reset.c
> --- a/arch/s390/kvm/arm64/reset.c
> +++ b/arch/s390/kvm/arm64/reset.c
[ ... ]
> +void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
> +{
> + struct vcpu_reset_state reset_state;
> + bool loaded;
> +
> + scoped_guard(spinlock, &vcpu->arch.mp_state_lock) {
> + reset_state = vcpu->arch.reset_state;
> + vcpu->arch.reset_state.reset = false;
> + }
> +
> + /*
> + * Disable preemption around the vcpu reset as we might otherwise race with
> + * preempt notifiers which call stiasrm/lasrm from put/load
> + */
> + preempt_disable();
> +
> + /* The reset must run with an unloaded save area */
> + loaded = vcpu_is_loaded(vcpu);
> + if (loaded)
> + vcpu_put(vcpu);
[Severity: High]
Are we calling vcpu_put() and vcpu_load() (which acquire the sleepable
vcpu->mutex) while inside a preempt_disable() block? Could this cause a
BUG: sleeping function called from invalid context panic during a vCPU
reset?
> +
> + kvm_reset_vcpu_core(vcpu);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918133107.1042730-1-seiden@linux.ibm.com?part=26
next prev parent reply other threads:[~2026-09-18 17:45 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 13:30 [PATCH v8 00/29] KVM: s390: Introduce arm64 KVM Steffen Eiden
2026-09-18 13:30 ` [PATCH v8 01/29] KVM: Introduce file_to_kvm_<arch>() infrastructure Steffen Eiden
2026-09-18 13:45 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 02/29] KVM: Add file back-pointer to struct kvm Steffen Eiden
2026-09-18 13:56 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 03/29] KVM: x86: Use file_to_kvm_x86() in SEV Steffen Eiden
2026-09-18 14:02 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 04/29] KVM/vfio: Use file-based reference counting for KVM Steffen Eiden
2026-09-18 14:26 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 05/29] KVM: Restrict kvm_get_kvm/kvm_put_kvm export to internal KVM modules Steffen Eiden
2026-09-18 14:30 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 06/29] KVM: Move export symbol check macros to Makefile.kvm Steffen Eiden
2026-09-18 14:37 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 07/29] KVM: Make device name configurable Steffen Eiden
2026-09-18 14:58 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 08/29] KVM: Move architecture capability Kconfigs to header defines Steffen Eiden
2026-09-18 15:07 ` sashiko-bot
2026-09-21 7:09 ` Steffen Eiden
2026-09-18 13:30 ` [PATCH v8 09/29] KVM: Replace CONFIG_KVM_MMIO with KVM_NO_MMIO Steffen Eiden
2026-09-18 15:15 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 10/29] arm64: Use proper include variant Steffen Eiden
2026-09-18 15:16 ` sashiko-bot
2026-09-28 14:01 ` Catalin Marinas
2026-09-18 13:30 ` [PATCH v8 11/29] arm64: ptrace: Use constants for compat register numbers Steffen Eiden
2026-09-18 15:20 ` sashiko-bot
2026-09-28 14:01 ` Catalin Marinas
2026-09-18 13:30 ` [PATCH v8 12/29] arm64: sysreg: Convert SPSR_ELx to automatic register generation Steffen Eiden
2026-09-18 15:24 ` sashiko-bot
2026-09-28 15:08 ` Catalin Marinas
2026-09-28 15:36 ` Steffen Eiden
2026-09-18 13:30 ` [PATCH v8 13/29] KVM: arm64: Access elements of vcpu_gp_regs individually Steffen Eiden
2026-09-18 15:28 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 14/29] KVM: arm64: Use accessor functions for core regs Steffen Eiden
2026-09-18 15:32 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 15/29] arm64: Prepare sharing arm64 headers with s390 Steffen Eiden
2026-09-18 15:39 ` sashiko-bot
2026-09-28 15:11 ` Catalin Marinas
2026-09-18 13:30 ` [PATCH v8 16/29] arm64: Share " Steffen Eiden
2026-09-18 15:50 ` sashiko-bot
2026-09-28 16:07 ` Catalin Marinas
2026-09-28 16:23 ` Steffen Eiden
2026-09-29 4:19 ` Andreas Grapentin
2026-09-29 17:00 ` Catalin Marinas
2026-09-30 7:28 ` Steffen Eiden
2026-09-30 7:55 ` Marc Zyngier
2026-09-30 8:18 ` Will Deacon
2026-09-30 8:53 ` Steffen Eiden
2026-09-18 13:30 ` [PATCH v8 17/29] KVM: arm64: Share arm64 code " Steffen Eiden
2026-09-18 16:02 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 18/29] s390/tools: Use arm64 headers Steffen Eiden
2026-09-18 16:09 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 19/29] KVM: s390: Use arm64 code Steffen Eiden
2026-09-18 16:14 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 20/29] s390: Introduce Start Arm Execution instruction Steffen Eiden
2026-09-18 16:28 ` sashiko-bot
2026-09-28 15:53 ` Ilya Leoshkevich
2026-09-28 16:15 ` Steffen Eiden
2026-09-28 16:18 ` Ilya Leoshkevich
2026-09-18 13:30 ` [PATCH v8 21/29] KVM: s390: arm64: Introduce host definitions Steffen Eiden
2026-09-18 16:44 ` sashiko-bot
2026-09-18 13:30 ` [PATCH v8 22/29] s390/hwcaps: Report SAE support as hwcap Steffen Eiden
2026-09-18 16:49 ` sashiko-bot
2026-09-28 15:58 ` Ilya Leoshkevich
2026-09-18 13:31 ` [PATCH v8 23/29] KVM: s390: Add basic arm64 kvm module Steffen Eiden
2026-09-18 17:00 ` sashiko-bot
2026-09-28 14:15 ` Hendrik Brueckner
2026-09-28 14:22 ` Steffen Eiden
2026-09-18 13:31 ` [PATCH v8 24/29] KVM: s390: arm64: Implement required functions Steffen Eiden
2026-09-18 17:13 ` sashiko-bot
2026-09-18 13:31 ` [PATCH v8 25/29] KVM: s390: arm64: Implement vm/vcpu create destroy Steffen Eiden
2026-09-18 17:24 ` sashiko-bot
2026-09-18 13:31 ` [PATCH v8 26/29] KVM: s390: arm64: Implement vCPU IOCTLs Steffen Eiden
2026-09-18 17:45 ` sashiko-bot [this message]
2026-09-18 13:31 ` [PATCH v8 27/29] KVM: s390: arm64: Implement basic page fault handler Steffen Eiden
2026-09-18 17:55 ` sashiko-bot
2026-09-18 13:31 ` [PATCH v8 28/29] KVM: s390: arm64: Integrate arm on s390 Steffen Eiden
2026-09-18 18:11 ` sashiko-bot
2026-09-18 13:31 ` [PATCH v8 29/29] KVM: s390: Enforce no unexpected external symbol exports in s390 KVM Steffen Eiden
2026-09-18 18:19 ` sashiko-bot
2026-09-18 13:38 ` [PATCH v8 00/29] KVM: s390: Introduce arm64 KVM Steffen Eiden
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=20260918174508.C516D1F000FF@smtp.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