On Fri, 10 Jan 2025 16:40:04 +0100 "Christoph Schlameuss" <schlameuss@xxxxxxxxxxxxx> wrote: > On Wed Jan 8, 2025 at 7:14 PM CET, Claudio Imbrenda wrote: > > Create fake memslots for ucontrol VMs. The fake memslots identity-map > > userspace. > > > > Now memslots will always be present, and ucontrol is not a special case > > anymore. > > > > Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx> > > --- > > arch/s390/kvm/kvm-s390.c | 42 ++++++++++++++++++++++++++++++++++++---- > > 1 file changed, 38 insertions(+), 4 deletions(-) > > > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > > index ecbdd7d41230..797b8503c162 100644 > > --- a/arch/s390/kvm/kvm-s390.c > > +++ b/arch/s390/kvm/kvm-s390.c > > @@ -59,6 +59,7 @@ > > #define LOCAL_IRQS 32 > > #define VCPU_IRQS_MAX_BUF (sizeof(struct kvm_s390_irq) * \ > > (KVM_MAX_VCPUS + LOCAL_IRQS)) > > +#define UCONTROL_SLOT_SIZE SZ_4T > > > > const struct _kvm_stats_desc kvm_vm_stats_desc[] = { > > KVM_GENERIC_VM_STATS(), > > @@ -3326,6 +3327,23 @@ void kvm_arch_free_vm(struct kvm *kvm) > > __kvm_arch_free_vm(kvm); > > } > > > > +static void kvm_s390_ucontrol_ensure_memslot(struct kvm *kvm, unsigned long addr) > > +{ > > + struct kvm_userspace_memory_region2 region = { > > + .slot = addr / UCONTROL_SLOT_SIZE, > > + .memory_size = UCONTROL_SLOT_SIZE, > > + .guest_phys_addr = ALIGN_DOWN(addr, UCONTROL_SLOT_SIZE), > > + .userspace_addr = ALIGN_DOWN(addr, UCONTROL_SLOT_SIZE), > > + }; > > + struct kvm_memory_slot *slot; > > + > > + mutex_lock(&kvm->slots_lock); > > + slot = gfn_to_memslot(kvm, addr); > > + if (!slot) > > + __kvm_set_memory_region(kvm, ®ion); > > This will call into kvm_arch_commit_memory_region() where > kvm->arch.gmap will still be NULL! Oops! will fix