]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: s390: Enable 1M pages for gmap
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Wed, 4 Feb 2026 15:02:56 +0000 (16:02 +0100)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Wed, 4 Feb 2026 16:00:10 +0000 (17:00 +0100)
While userspace is allowed to have pages of any size, the new gmap
would always use 4k pages to back the guest.

Enable 1M pages for gmap.

This allows 1M pages to be used to back a guest when userspace is using
1M pages for the corresponding addresses (e.g. THP or hugetlbfs).

Remove the limitation that disallowed having nested guests and
hugepages at the same time.

Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
arch/s390/kvm/gmap.c
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/pv.c

index fea1c66fcabee2ed9abfa72a11d9412ee6f41936..da222962ef6d124a56df0b97276ff6ba4be3ad25 100644 (file)
@@ -620,7 +620,7 @@ static inline bool gmap_2g_allowed(struct gmap *gmap, gfn_t gfn)
 
 static inline bool gmap_1m_allowed(struct gmap *gmap, gfn_t gfn)
 {
-       return false;
+       return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags);
 }
 
 int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f)
index bde55761bf8a2c682a33072affb509bf6aeaa347..ac7b5f56f0b57d562eb2ed7b02fe027e9e3070f3 100644 (file)
@@ -851,6 +851,7 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
                        r = -EINVAL;
                else {
                        r = 0;
+                       set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &kvm->arch.gmap->flags);
                        /*
                         * We might have to create fake 4k page
                         * tables. To avoid that the hardware works on
@@ -5729,11 +5730,6 @@ static int __init kvm_s390_init(void)
                return -ENODEV;
        }
 
-       if (nested && hpage) {
-               pr_info("A KVM host that supports nesting cannot back its KVM guests with huge pages\n");
-               return -EINVAL;
-       }
-
        for (i = 0; i < 16; i++)
                kvm_s390_fac_base[i] |=
                        stfle_fac_list[i] & nonhyp_mask(i);
index a48a8afd40df5dff8c9167899a7ea20213d784b1..461b413c76a36c6e8d6820fbd3c1633dc7af0546 100644 (file)
@@ -721,6 +721,9 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
        uvcb.flags.ap_allow_instr = kvm->arch.model.uv_feat_guest.ap;
        uvcb.flags.ap_instr_intr = kvm->arch.model.uv_feat_guest.ap_intr;
 
+       clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &kvm->arch.gmap->flags);
+       gmap_split_huge_pages(kvm->arch.gmap);
+
        cc = uv_call_sched(0, (u64)&uvcb);
        *rc = uvcb.header.rc;
        *rrc = uvcb.header.rrc;