From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [GIT PULL v1 07/17] KVM: s390: Add capability to support 2G hugepages
Date: Mon, 15 Jun 2026 13:05:23 +0000 [thread overview]
Message-ID: <20260615130523.E00D21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260615124243.187614-8-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Userspace can simultaneously enable both CMMA and huge pages (1M and 2G), bypassing mutual exclusivity, because KVM_S390_VM_MEM_ENABLE_CMMA does not check if huge pages are already enabled.
--
commit 98eba733f54412a163121c369883f11ed5ca35db
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: Add capability to support 2G hugepages
This commit adds the KVM_CAP_S390_HPAGE_2G capability to signal to userspace
that 2G hugepages may be used to back the guest. It also implements the
necessary gmap flag enablement and propagation for the new hugepage size.
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 49c330580dc88..35e5971a474f6 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
[ ... ]
> @@ -902,6 +907,27 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
> VM_EVENT(kvm, 3, "ENABLE: CAP_S390_HPAGE %s",
> r ? "(not available)" : "(success)");
> break;
> + case KVM_CAP_S390_HPAGE_2G:
> + mutex_lock(&kvm->lock);
> + if (kvm->created_vcpus) {
> + r = -EBUSY;
> + } else if (!hpage_2g || kvm->arch.use_cmma || kvm_is_ucontrol(kvm)) {
[Severity: High]
This is a pre-existing issue, but could userspace bypass this mutual
exclusivity check between CMMA and huge pages?
When enabling huge pages via KVM_CAP_S390_HPAGE_1M or KVM_CAP_S390_HPAGE_2G,
KVM correctly rejects the operation if kvm->arch.use_cmma is already set.
However, if userspace enables huge pages first, and then enables CMMA,
kvm_s390_set_mem_control() does not appear to verify if huge pages are
already active:
arch/s390/kvm/kvm-s390.c:kvm_s390_set_mem_control() {
...
case KVM_S390_VM_MEM_ENABLE_CMMA:
...
mutex_lock(&kvm->lock);
if (kvm->created_vcpus)
ret = -EBUSY;
else {
kvm->arch.use_cmma = 1;
/* Not compatible with cmma. */
kvm->arch.use_pfmfi = 0;
ret = 0;
}
mutex_unlock(&kvm->lock);
...
}
Does this sequence allow the guest to run with both kvm->arch.use_cmma
and GMAP_FLAG_ALLOW_HPAGE_2G (or 1M) enabled simultaneously?
If so, and the guest executes the ESSA instruction on a huge page, would
this lead to KVM entering an infinite intercept loop that stalls the vCPU,
or cause undefined hardware behavior if migration mode is inactive?
> + r = -EINVAL;
> + } else {
> + r = 0;
> + set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &kvm->arch.gmap->flags);
> + /*
> + * We might have to create fake 4k page
> + * tables. To avoid that the hardware works on
> + * stale PGSTEs, we emulate these instructions.
> + */
> + kvm->arch.use_skf = 0;
> + kvm->arch.use_pfmfi = 0;
> + }
> + mutex_unlock(&kvm->lock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260615124243.187614-1-imbrenda@linux.ibm.com?part=7
next prev parent reply other threads:[~2026-06-15 13:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 12:42 [GIT PULL v1 00/17] KVM: s390: New features for 7.2 Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 01/17] KVM: s390: Track page size in struct guest_fault Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 02/17] KVM: s390: Implement KVM_PRE_FAULT_MEMORY Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 03/17] KVM: s390: Update KVM_PRE_FAULT_MEMORY API documentation Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 04/17] KVM: selftests: Fix pre_fault_memory_test to run on s390 Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 05/17] KVM: selftests: Enable pre_fault_memory_test for s390 Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 06/17] KVM: s390: Add module parameter to fence 2G hugepages Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 07/17] KVM: s390: Add capability to support " Claudio Imbrenda
2026-06-15 13:05 ` sashiko-bot [this message]
2026-06-15 12:42 ` [GIT PULL v1 08/17] KVM: s390: Allow for " Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 09/17] KVM: s390: Document the KVM_CAP_S390_HPAGE_2G capability Claudio Imbrenda
2026-06-15 13:03 ` sashiko-bot
2026-06-15 12:42 ` [GIT PULL v1 10/17] KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory Claudio Imbrenda
2026-06-15 13:07 ` sashiko-bot
2026-06-15 12:42 ` [GIT PULL v1 11/17] KVM: s390: Minor refactor of base/ext facility lists Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 12/17] s390/sclp: Detect ASTFLEIE 2 facility Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 13/17] KVM: s390: vsie: Refactor handle_stfle Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 14/17] KVM: s390: vsie: Implement ASTFLEIE facility 2 Claudio Imbrenda
2026-06-15 12:42 ` [GIT PULL v1 15/17] KVM: s390: Add map/unmap ioctl and clean mappings post-guest Claudio Imbrenda
2026-06-15 13:21 ` sashiko-bot
2026-06-15 12:42 ` [GIT PULL v1 16/17] KVM: s390: Enable adapter_indicators_set to use mapped pages Claudio Imbrenda
2026-06-15 13:21 ` sashiko-bot
2026-06-15 12:42 ` [GIT PULL v1 17/17] KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject Claudio Imbrenda
2026-06-15 13:23 ` 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=20260615130523.E00D21F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.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