This is a successor of previously sent "[PATCH RFC 0/4] KVM: x86: Drastically raise KVM_USER_MEM_SLOTS limit". Changes since RFC: - Re-wrote everything [Sean]. The maximum number of slots is now a per-VM thing controlled by an ioctl. Original description: Current KVM_USER_MEM_SLOTS limit on x86 (509) can be a limiting factor for some configurations. In particular, when QEMU tries to start a Windows guest with Hyper-V SynIC enabled and e.g. 256 vCPUs the limit is hit as SynIC requires two pages per vCPU and the guest is free to pick any GFN for each of them, this fragments memslots as QEMU wants to have a separate memslot for each of these pages (which are supposed to act as 'overlay' pages). Memory slots are allocated dynamically in KVM when added so the only real limitation is 'id_to_index' array which is 'short'. We don't seem to have any other KVM_MEM_SLOTS_NUM/KVM_USER_MEM_SLOTS-sized statically defined structures. We could've just raised the limit to e.g. '1021' (we have 3 private memslots on x86) and this should be enough for now as KVM_MAX_VCPUS is '288' but AFAIK there are plans to raise this limit as well. Raise the default value to 32768 - KVM_PRIVATE_MEM_SLOTS and introduce a new ioctl to set the limit per-VM. Vitaly Kuznetsov (5): KVM: Make the maximum number of user memslots a per-VM thing KVM: Raise the maximum number of user memslots KVM: Make the maximum number of user memslots configurable selftests: kvm: Test the newly introduced KVM_CAP_MEMSLOTS_LIMIT selftests: kvm: Raise the default timeout to 120 seconds Documentation/virt/kvm/api.rst | 16 +++++++ arch/arm64/include/asm/kvm_host.h | 1 - arch/mips/include/asm/kvm_host.h | 1 - arch/powerpc/include/asm/kvm_host.h | 1 - arch/powerpc/kvm/book3s_hv.c | 2 +- arch/s390/include/asm/kvm_host.h | 1 - arch/s390/kvm/kvm-s390.c | 2 +- arch/x86/include/asm/kvm_host.h | 2 - include/linux/kvm_host.h | 6 +-- include/uapi/linux/kvm.h | 1 + .../testing/selftests/kvm/include/kvm_util.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 30 ++++++++++++- .../selftests/kvm/set_memory_region_test.c | 43 ++++++++++++++++--- tools/testing/selftests/kvm/settings | 1 + virt/kvm/dirty_ring.c | 2 +- virt/kvm/kvm_main.c | 42 +++++++++++++++--- 16 files changed, 128 insertions(+), 24 deletions(-) create mode 100644 tools/testing/selftests/kvm/settings -- 2.29.2