From: sashiko-bot@kernel.org
To: "Steffen Eiden" <seiden@linux.ibm.com>
Cc: "Oliver Upton" <oupton@kernel.org>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v2 18/20] KVM: s390: arm64: Implement SVE for arm guests
Date: Mon, 31 Aug 2026 22:16:54 +0000 [thread overview]
Message-ID: <20260831221655.8478D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831145536.913567-19-seiden@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] SVE register accessors copy fewer bytes than the KVM ABI specifies, failing to zero-pad the remainder of the userspace buffer.
- [Medium] SVE ioctls and vCPU finalization bypass feature gating checks.
- [Low] Unrecognized or invalid SVE register IDs result in a -EFAULT return code instead of -ENOENT or -EINVAL.
--
commit 7e278493890194c05cc617a90bf08952cf400bea
Author: Steffen Eiden <seiden@linux.ibm.com>
KVM: s390: arm64: Implement SVE for arm guests
Add support for Scalable Vector Extension (SVE) in ARM64 guests running
on s390 hardware, providing 128-bit vector operations backed by s390's
Vector Extension (VX).
> diff --git a/arch/s390/kvm/arm64/guest.c b/arch/s390/kvm/arm64/guest.c
> index 0474609759360..63fc4a64ab48f 100644
> --- a/arch/s390/kvm/arm64/guest.c
> +++ b/arch/s390/kvm/arm64/guest.c
[ ... ]
> +static inline int get_sve_ffr_reg(struct kvm_vcpu *vcpu, unsigned int regnum,
> + u16 __user *uptr)
> +{
> + /* ffr is pregmax + 1 */
> + if (regnum != KVM_ARM64_SVE_NUM_PREGS)
> + return -EINVAL;
> +
> + if (put_user(vcpu->arch.sae_block.sve_ffr, uptr))
[Severity: Medium]
The ARM64 KVM ABI defines FFR and PREG registers as 32 bytes
(KVM_REG_SIZE_U256), but this only writes 2 bytes via the u16 pointer. Will
this leave 30 bytes of the userspace buffer uninitialized, potentially
leaking memory contents into the migration stream when QEMU reads it?
> + return -EFAULT;
> + return 0;
> +}
> +
> +static inline int get_sve_preg(struct kvm_vcpu *vcpu, unsigned int regnum,
> + u16 __user *uptr)
> +{
> + if (regnum < 0 || regnum >= KVM_ARM64_SVE_NUM_PREGS)
> + return -EINVAL;
> +
> + if (put_user(vcpu->arch.sae_block.sve_pregs[regnum], uptr))
[Severity: Medium]
Similar to get_sve_ffr_reg(), this only copies 2 bytes for a register size
defined as 32 bytes. Should this zero-pad the rest of the buffer according to
the ABI?
> + return -EFAULT;
> + return 0;
> +}
> +
> +static inline int get_sve_zreg(struct kvm_vcpu *vcpu, unsigned int regnum,
> + __vector128 __user *uptr)
> +{
> + if (regnum < 0 || regnum >= KVM_ARM64_SVE_NUM_ZREGS)
> + return -EINVAL;
> +
> + /* vreg and svreg overlap and zreg is also just 128 bit so we reuse the vreg space */
> + if (copy_to_user(uptr, &vcpu->arch.ctxt.vregs[regnum],
> + sizeof(vcpu->arch.ctxt.vregs[regnum])))
[Severity: Medium]
The ZREG size is defined as 256 bytes (KVM_REG_SIZE_U2048) by the ABI, but
this only copies 16 bytes. Does this leave the remaining 240 bytes of the
userspace buffer untouched, breaking ABI expectations?
> + return -EFAULT;
> + return 0;
> +}
[ ... ]
> +static int get_sve_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> +{
> + void __user *uptr = (void __user *)reg->addr;
> + unsigned int regnum;
> + int ret = -EFAULT;
> +
> + if (reg->id == KVM_REG_ARM64_SVE_VLS)
> + ret = get_sve_vls(vcpu, uptr);
> + else if (sve_ffr_index(reg->id, ®num) >= 0)
> + ret = get_sve_ffr_reg(vcpu, regnum, uptr);
> + else if (sve_preg_index(reg->id, ®num) >= 0)
> + ret = get_sve_preg(vcpu, regnum, uptr);
> + else if (sve_zreg_index(reg->id, ®num) >= 0)
> + ret = get_sve_zreg(vcpu, regnum, uptr);
[Severity: Medium]
Does this function need to enforce the vcpu_has_sve() and
kvm_arm_vcpu_sve_finalized() constraints before delegating to the register
accessors, as required by the ABI?
[Severity: Low]
If an unrecognized or invalid SVE register ID is passed, the index validators
(e.g. sve_zreg_index()) return negative error codes like -ENOENT or -EINVAL,
but this function ignores them and falls through to returning the default
initialized ret = -EFAULT. Is it intentional to return -EFAULT instead of
propagating the specific error codes, which userspace like QEMU might rely
on to detect the end of slices?
> +
> + return ret;
> +}
> +
> +static int set_sve_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> +{
> + const void __user *uptr = (const void __user *)reg->addr;
> + int ret = -EFAULT;
> + unsigned int regnum;
> +
> + if (reg->id == KVM_REG_ARM64_SVE_VLS)
> + ret = set_sve_vls(vcpu, uptr);
> + else if (sve_ffr_index(reg->id, ®num) >= 0)
> + ret = set_sve_ffr_reg(vcpu, regnum, uptr);
> + else if (sve_preg_index(reg->id, ®num) >= 0)
> + ret = set_sve_preg(vcpu, regnum, uptr);
> + else if (sve_zreg_index(reg->id, ®num) >= 0)
> + ret = set_sve_zreg(vcpu, regnum, uptr);
[Severity: Medium]
Like get_sve_reg(), should this also check if the vCPU has the SVE feature
enabled and finalized before allowing state modifications to vector registers?
> +
> + return ret;
> +}
> +
> diff --git a/arch/s390/kvm/arm64/reset.c b/arch/s390/kvm/arm64/reset.c
> index bc7bcee75779e..754c4d4a70b6b 100644
> --- a/arch/s390/kvm/arm64/reset.c
> +++ b/arch/s390/kvm/arm64/reset.c
[ ... ]
> int kvm_arm_vcpu_finalize(struct kvm_vcpu *vcpu, int feature)
> {
> - return 0;
> + switch (feature) {
> + case KVM_ARM_VCPU_SVE:
> + if (!cpu_has_vx())
> + return -EINVAL;
> + if (vcpu_get_flag(vcpu, VCPU_SVE_FINALIZED))
> + return -EPERM;
[Severity: Medium]
Should this function verify that the KVM_ARM_VCPU_SVE feature is actually
enabled for this vCPU (e.g. via vcpu_has_feature()) before allowing
finalization? Without this check, userspace could potentially finalize SVE
on non-SVE vCPUs.
> + vcpu_set_flag(vcpu, VCPU_SVE_FINALIZED);
> + return 0;
> + }
> +
> + return -EINVAL;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831145536.913567-1-seiden@linux.ibm.com?part=18
next prev parent reply other threads:[~2026-08-31 22:16 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 14:55 [PATCH v2 00/20] KVM: arm64 on s390 System Register Handling Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 01/20] KVM: arm64: Refactor idreg caching into dedicated structure Steffen Eiden
2026-08-31 18:06 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 02/20] KVM: arm64: Extract number of sys_reg_desc into a constant Steffen Eiden
2026-08-31 18:08 ` sashiko-bot
2026-09-01 7:48 ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 03/20] arm64: sysreg: Define OSLSR_EL1_OSLK_MASK Steffen Eiden
2026-08-31 18:18 ` sashiko-bot
2026-09-01 7:51 ` Marc Zyngier
2026-09-01 9:25 ` Steffen Eiden
2026-09-02 7:49 ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 04/20] arm64: Share more arm64 headers with s390 Steffen Eiden
2026-08-31 18:31 ` sashiko-bot
2026-09-01 8:08 ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 05/20] KVM: s390: arm64: Prepare for sharing more arm64 code Steffen Eiden
2026-08-31 18:42 ` sashiko-bot
2026-09-01 8:15 ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 06/20] KVM: arm64: Prepare sys_regs.c for sharing with s390 Steffen Eiden
2026-08-31 18:45 ` sashiko-bot
2026-09-01 8:17 ` Marc Zyngier
2026-09-01 9:29 ` Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 07/20] KVM: arm64: Share more arm64 code " Steffen Eiden
2026-08-31 19:01 ` sashiko-bot
2026-09-01 8:30 ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 08/20] s390: tools: Allow sharing arm64/kvm headers Steffen Eiden
2026-08-31 19:03 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 09/20] s390: Introduce read/write ARM sysreg instructions Steffen Eiden
2026-08-31 19:16 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 10/20] s390: Add functions to query arm guest time Steffen Eiden
2026-08-31 19:24 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 11/20] KVM: s390: arm64: Query Available Arm features Steffen Eiden
2026-08-31 19:46 ` sashiko-bot
2026-09-01 11:44 ` Janosch Frank
2026-09-01 14:25 ` Steffen Eiden
2026-09-01 16:36 ` Janosch Frank
2026-08-31 14:55 ` [PATCH v2 12/20] KVM: s390: arm64: Implement feature sanitisation Steffen Eiden
2026-08-31 20:11 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 13/20] KVM: s390: arm64: Implement arm sysreg managing infrastructure Steffen Eiden
2026-08-31 20:33 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 14/20] KVM: s390: arm64: Integrate sysreg into the host Steffen Eiden
2026-08-31 21:15 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 15/20] KVM: s390: arm64: Use QAAF init save area Steffen Eiden
2026-08-31 21:32 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 16/20] KVM: s390: arm64: Implement exception injection Steffen Eiden
2026-08-31 21:38 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 17/20] KVM: s390: arm64: Finalize page fault handling Steffen Eiden
2026-08-31 21:52 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 18/20] KVM: s390: arm64: Implement SVE for arm guests Steffen Eiden
2026-08-31 22:16 ` sashiko-bot [this message]
2026-08-31 14:55 ` [PATCH v2 19/20] KVM: s390: arm64: Promote PTRAUTH capability Steffen Eiden
2026-08-31 22:35 ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 20/20] s390: Report AEF features to sysfs Steffen Eiden
2026-08-31 22:43 ` 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=20260831221655.8478D1F000E9@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