From: sashiko-bot@kernel.org
To: "Christoph Schlameuss" <schlameuss@linux.ibm.com>
Cc: linux-s390@vger.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>,
kvm@vger.kernel.org
Subject: Re: [PATCH v5 16/21] KVM: s390: vsie: Shadow VSIE SCA in guest-1
Date: Wed, 26 Aug 2026 15:25:45 +0000 [thread overview]
Message-ID: <20260826152545.E24201F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826-vsie-sigpi-v5-16-cf471edb46b2@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] `get_vsie_page_cpu_nr()` incorrectly wraps positive return codes (like 1 for validity intercepts) in `ERR_PTR()`, bypassing `IS_ERR()` checks and causing a host kernel panic.
- [High] Stale `sca_gpa` in reused `vsie_sca` causes incorrect `xa_erase()` of valid shadow SCAs.
- [High] `get_vsie_sca()` incorrectly translates guest validity intercepts or unbacked SCA errors into KVM_RUN `-EINVAL` exits, abruptly crashing the VM.
- [Medium] Guest-triggerable `WARN_ON_ONCE` if `xa_store()` fails due to memory pressure.
--
commit 763d66e9883805b058573509abca88b10cdfb124
Author: Christoph Schlameuss <schlameuss@linux.ibm.com>
KVM: s390: vsie: Shadow VSIE SCA in guest-1
This commit restructures kvm_s390_handle_vsie() to create a guest-1 shadow
of the SCA if guest-2 attempts to enter SIE with an SCA. The original SCA
is pinned in guest-2 memory, and references to existing shadow SCAs are
stored in a map to efficiently reuse them.
> diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c
> index 3c94faa35b44e..4bd11eaa7d81d 100644
> --- a/arch/s390/kvm/s390/vsie.c
> +++ b/arch/s390/kvm/s390/vsie.c
[ ... ]
> @@ -958,6 +1051,128 @@ static struct vsie_sca *alloc_vsie_sca(void)
> return vsie_sca;
> }
>
> +/* Clear the vsie_sca struct but keep the vsie_page references, mutex and ref_count */
> +static void clear_vsie_sca(struct vsie_sca *vsie_sca)
[ ... ]
> +/* Pin and get an existing or new guest-3 system control area.*/
> +static struct vsie_sca *get_vsie_sca(struct kvm_vcpu *vcpu, struct kvm_s390_sie_block *scb_o)
> +{
[ ... ]
> + /* validate scb_o as we do not unshadow on error here */
> + rc = validate_scao(vcpu, scb_o, sca_gpa);
> + if (rc)
> + return ERR_PTR(-EINVAL);
[Severity: High]
Does this code incorrectly translate a guest validity intercept into a fatal
host KVM error?
When validate_scao() fails, it returns a positive validity intercept value
(like 1). Returning ERR_PTR(-EINVAL) here overrides that intercept and
returns -EINVAL instead.
> +
> + down_read(&kvm->arch.vsie.vsie_sca_lock);
> + vsie_sca = get_vsie_sca_existing(kvm, sca_gpa, is_esca);
> + up_read(&kvm->arch.vsie.vsie_sca_lock);
> + if (vsie_sca)
> + return vsie_sca;
[ ... ]
> + /* check again under write lock if we are still under our vsie_sca limit */
> + if (vsie_sca_new && kvm->arch.vsie.sca_count < max_vsie_sca) {
[ ... ]
> + } else {
> + /* reuse previously created vsie_sca allocation for different osca */
> + vsie_sca = get_vsie_sca_unused(kvm);
> + /* with nr_vcpus scas one must be reusable */
> + if (IS_ERR(vsie_sca))
> + goto out;
> +
> + xa_erase(&kvm->arch.vsie.osca_to_sca, vsie_sca->sca_gpa >> SCA_ALIGNMENT_SHIFT);
[Severity: High]
If we are reusing an orphaned vsie_sca, does its sca_gpa still hold the old,
stale address? If so, does this xa_erase() inadvertently remove a valid
active shadow SCA from the osca_to_sca xarray?
[ ... ]
> + rc = pin_sca(kvm, vsie_sca);
> + if (rc) {
> + vsie_sca->sca_gpa = ULONG_MAX;
> + put_vsie_sca(vsie_sca);
> + vsie_sca = ERR_PTR(rc);
> + goto out;
> + }
> +
> + WARN_ON_ONCE(xa_store(&kvm->arch.vsie.osca_to_sca, vsie_sca->sca_gpa >> SCA_ALIGNMENT_SHIFT,
> + vsie_sca, GFP_KERNEL_ACCOUNT));
[Severity: Medium]
If xa_store() fails due to memory pressure, it returns an error pointer.
Since this is a non-null value, will this WARN_ON_ONCE trigger?
Guest-reachable warnings can be exploited for log spam or DoS.
> +
> +out:
> + up_write(&kvm->arch.vsie.vsie_sca_lock);
> + if (vsie_sca_new)
> + free_vsie_sca(kvm, vsie_sca_new);
> + return vsie_sca;
> +}
[ ... ]
> @@ -1815,11 +2027,165 @@ static struct vsie_page *get_vsie_page(struct kvm_vcpu *vcpu, unsigned long addr
[ ... ]
> +static struct vsie_page *get_vsie_page_cpu_nr(struct kvm_vcpu *vcpu, struct vsie_sca *vsie_sca,
> + gpa_t scb_gpa, u16 cpu_nr)
> +{
[ ... ]
> + if (vsie_page->scb_gpa != scb_gpa || vsie_page->sca_gpa != vsie_sca->sca_gpa) {
> + scoped_guard(mutex, &vcpu->kvm->arch.vsie.mutex) {
> + unpin_scb(vcpu->kvm, vsie_page);
> + rc = init_vsie_page(vcpu, vsie_page, scb_gpa);
> + }
> + if (rc) {
> + put_vsie_page(vsie_page);
> + return ERR_PTR(rc);
> + }
[Severity: Critical]
If init_vsie_page() returns a positive validity intercept (such as 1), does
wrapping it in ERR_PTR(rc) return (void *)1?
Since 1 is not >= -MAX_ERRNO, IS_ERR() downstream will evaluate to false,
treating this as a valid pointer.
> +
> + reset_vsie_page(vcpu->kvm, vsie_page);
> + }
> +
> + return vsie_page;
> +}
[ ... ]
> +static int _shadow_sca_cpu(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,
> + struct vsie_sca *vsie_sca, hpa_t sca_o_entry_hpa,
> + unsigned int cpu_nr, bool is_esca)
> +{
[ ... ]
> + vsie_page_n = get_vsie_page_cpu_nr(vcpu, vsie_sca, scb_o_gpa, cpu_nr);
> + if (!vsie_page_n)
> + return -EAGAIN;
> + if (IS_ERR(vsie_page_n))
> + return PTR_ERR(vsie_page_n);
> +
> + rc = shadow_scb(vcpu, vsie_page_n);
[Severity: Critical]
Because IS_ERR(vsie_page_n) evaluates to false for (void *)1, does this allow
the invalid pointer 0x1 to be dereferenced in shadow_scb(), leading to a host
kernel panic?
[ ... ]
> @@ -1838,33 +2204,71 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
[ ... ]
> + } else {
> + /* get the vsie_sca with pinned original sca */
> + vsie_sca = get_vsie_sca(vcpu, scb_o);
> + if (IS_ERR(vsie_sca)) {
> + rc = PTR_ERR(vsie_sca);
> + goto out_unpin;
> + }
[Severity: High]
If get_vsie_sca() returned ERR_PTR(-EINVAL) due to validate_scao() failing
above, rc becomes -EINVAL here.
Does returning -EINVAL abort the KVM_RUN ioctl entirely, abruptly crashing
the VM instead of gracefully reflecting an error to the guest?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-vsie-sigpi-v5-0-cf471edb46b2@linux.ibm.com?part=16
next prev parent reply other threads:[~2026-08-26 15:25 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 15:05 [PATCH v5 00/21] KVM: s390: vsie: Add VSIE SIGP ECALL and SRSI Interpretation Christoph Schlameuss
2026-08-26 15:05 ` [PATCH v5 01/21] KVM: s390: vsie: Add SCAO read and write helpers Christoph Schlameuss
2026-08-26 15:12 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 02/21] KVM: s390: vsie: Move SCAO validation into a function Christoph Schlameuss
2026-08-26 15:15 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 03/21] KVM: s390: vsie: Add vsie_interp_extf detection Christoph Schlameuss
2026-08-26 15:12 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 04/21] KVM: s390: vsie: Add ssca_block and ssca_entry structs Christoph Schlameuss
2026-08-26 15:09 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 05/21] KVM: s390: vsie: Move pin/unpin guest page Christoph Schlameuss
2026-08-26 15:17 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 06/21] KVM: s390: vsie: Move pin/unpin_scb methods Christoph Schlameuss
2026-08-26 15:10 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 07/21] KVM: s390: vsie: Move release/acquire gmap shadow Christoph Schlameuss
2026-08-26 15:14 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 08/21] KVM: s390: vsie: Create helpers to alloc and free vsie_pages Christoph Schlameuss
2026-08-26 15:10 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 09/21] KVM: s390: vsie: Replace radix_tree with xarray addr_to_page Christoph Schlameuss
2026-08-26 15:14 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 10/21] KVM: s390: vsie: Refactor kvm_s390_vsie_destroy and extract reusable methods Christoph Schlameuss
2026-08-26 15:19 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 11/21] KVM: s390: vsie: Add helper reset_vsie_page() and unshadow_intercept() Christoph Schlameuss
2026-08-26 15:18 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 12/21] KVM: s390: vsie: Add helper unshadow_intercept() Christoph Schlameuss
2026-08-26 15:14 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 13/21] KVM: s390: vsie: Lazily keep original scb pinned after vsie exit Christoph Schlameuss
2026-08-26 15:25 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 14/21] KVM: s390: vsie: Add helper to pin and unpin multiple guest pages Christoph Schlameuss
2026-08-26 15:15 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 15/21] KVM: s390: vsie: Add struct vsie_sca with pin and unpin methods Christoph Schlameuss
2026-08-26 15:26 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 16/21] KVM: s390: vsie: Shadow VSIE SCA in guest-1 Christoph Schlameuss
2026-08-26 15:25 ` sashiko-bot [this message]
2026-08-26 15:05 ` [PATCH v5 17/21] KVM: s390: vsie: Allow guest-3 cpu add and remove with ssca Christoph Schlameuss
2026-08-26 15:23 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 18/21] KVM: s390: vsie: Add VSIE max shadow configuration Christoph Schlameuss
2026-08-26 15:24 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 19/21] KVM: s390: vsie: Add VSIE shadow stat counters Christoph Schlameuss
2026-08-26 15:19 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 20/21] KVM: s390: vsie: Create minimal scb shadows for not running g3 blocks Christoph Schlameuss
2026-08-26 15:35 ` sashiko-bot
2026-08-26 15:05 ` [PATCH v5 21/21] KVM: s390: vsie: Enable use of VSIE SSCA Christoph Schlameuss
2026-08-26 15:33 ` 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=20260826152545.E24201F000E9@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=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=schlameuss@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 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.