Skip to content

Commit 0fdd5c1

Browse files
author
Claudio Imbrenda
committed
KVM: s390: Enable 1M pages for gmap
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>
1 parent 728b0e2 commit 0fdd5c1

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

arch/s390/kvm/gmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static inline bool gmap_2g_allowed(struct gmap *gmap, gfn_t gfn)
620620

621621
static inline bool gmap_1m_allowed(struct gmap *gmap, gfn_t gfn)
622622
{
623-
return false;
623+
return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags);
624624
}
625625

626626
int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f)

arch/s390/kvm/kvm-s390.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
851851
r = -EINVAL;
852852
else {
853853
r = 0;
854+
set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &kvm->arch.gmap->flags);
854855
/*
855856
* We might have to create fake 4k page
856857
* tables. To avoid that the hardware works on
@@ -5729,11 +5730,6 @@ static int __init kvm_s390_init(void)
57295730
return -ENODEV;
57305731
}
57315732

5732-
if (nested && hpage) {
5733-
pr_info("A KVM host that supports nesting cannot back its KVM guests with huge pages\n");
5734-
return -EINVAL;
5735-
}
5736-
57375733
for (i = 0; i < 16; i++)
57385734
kvm_s390_fac_base[i] |=
57395735
stfle_fac_list[i] & nonhyp_mask(i);

arch/s390/kvm/pv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,9 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
721721
uvcb.flags.ap_allow_instr = kvm->arch.model.uv_feat_guest.ap;
722722
uvcb.flags.ap_instr_intr = kvm->arch.model.uv_feat_guest.ap_intr;
723723

724+
clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &kvm->arch.gmap->flags);
725+
gmap_split_huge_pages(kvm->arch.gmap);
726+
724727
cc = uv_call_sched(0, (u64)&uvcb);
725728
*rc = uvcb.header.rc;
726729
*rrc = uvcb.header.rrc;

0 commit comments

Comments
 (0)