mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
KVM: s390: Add capability to support 2G hugepages
Add KVM_CAP_S390_HPAGE_2G to signal to userspace that 2G hugepages may be used to back the guest; restrictions apply similar to 1M hugepages. Enable the (for now still ignored) GMAP_FLAG_ALLOW_HPAGE_2G flag for the guest gmap, and propagate / disable it as necessary. Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-ID: <20260609150930.665370-3-imbrenda@linux.ibm.com>
This commit is contained in:
parent
782fec4ab9
commit
103ff3a50e
|
|
@ -105,6 +105,11 @@ static void gmap_add_child(struct gmap *parent, struct gmap *child)
|
|||
else
|
||||
clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
|
||||
|
||||
if (test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags))
|
||||
set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
|
||||
else
|
||||
clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
|
||||
|
||||
if (kvm_is_ucontrol(parent->kvm))
|
||||
clear_bit(GMAP_FLAG_OWNS_PAGETABLES, &child->flags);
|
||||
list_add(&child->list, &parent->children);
|
||||
|
|
|
|||
|
|
@ -646,6 +646,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
|
|||
if (hpage && !(kvm && kvm_is_ucontrol(kvm)))
|
||||
r = 1;
|
||||
break;
|
||||
case KVM_CAP_S390_HPAGE_2G:
|
||||
r = 0;
|
||||
if (hpage_2g && !(kvm && kvm_is_ucontrol(kvm)))
|
||||
r = 1;
|
||||
break;
|
||||
case KVM_CAP_S390_MEM_OP:
|
||||
r = MEM_OP_MAX_SIZE;
|
||||
break;
|
||||
|
|
@ -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)) {
|
||||
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);
|
||||
VM_EVENT(kvm, 3, "ENABLE: CAP_S390_HPAGE_2G %s",
|
||||
r ? "(not available)" : "(success)");
|
||||
break;
|
||||
case KVM_CAP_S390_USER_STSI:
|
||||
VM_EVENT(kvm, 3, "%s", "ENABLE: CAP_S390_USER_STSI");
|
||||
kvm->arch.user_stsi = 1;
|
||||
|
|
|
|||
|
|
@ -721,7 +721,10 @@ 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);
|
||||
scoped_guard(write_lock, &kvm->mmu_lock) {
|
||||
clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &kvm->arch.gmap->flags);
|
||||
clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &kvm->arch.gmap->flags);
|
||||
}
|
||||
gmap_split_huge_pages(kvm->arch.gmap);
|
||||
|
||||
cc = uv_call_sched(0, (u64)&uvcb);
|
||||
|
|
|
|||
|
|
@ -996,6 +996,7 @@ struct kvm_enable_cap {
|
|||
#define KVM_CAP_S390_USER_OPEREXEC 246
|
||||
#define KVM_CAP_S390_KEYOP 247
|
||||
#define KVM_CAP_S390_VSIE_ESAMODE 248
|
||||
#define KVM_CAP_S390_HPAGE_2G 249
|
||||
|
||||
struct kvm_irq_routing_irqchip {
|
||||
__u32 irqchip;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user