Commit 7b875025 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Yu Zhang
Browse files

KVM: Raise the maximum number of user memslots

mainline inclusion
from mainline-v5.12-rc1
commit 4fc096a9
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I7S3VQ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4fc096a99e01dd06dc55bef76ade7f8d76653245



This commit also removes the risc-v's and loongarch's version of
KVM_USER_MEM_SLOTS, which never appeared in the upstream code,
yet was added in backporting commit e91613ae ("RISC-V: Add
initial skeletal KVM support"), and commit 622f37d3 ("LoongArch:
kvm: add initial kvm support"). The reason should be due to lack of
this current commit. So just also do it for risc-v and loongarch, to
use the generic definition of KVM_USER_MEM_SLOTS.

----------------------------------------------------------------------

Current KVM_USER_MEM_SLOTS limits are arch specific (512 on Power, 509 on x86,
32 on s390, 16 on MIPS) but they don't really need to be. 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 have any other
KVM_MEM_SLOTS_NUM/KVM_USER_MEM_SLOTS-sized statically defined structures.

Low KVM_USER_MEM_SLOTS 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).

Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20210127175731.2020089-3-vkuznets@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent 32390924
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@

#define __KVM_HAVE_ARCH_INTC_INITIALIZED

#define KVM_USER_MEM_SLOTS 512
#define KVM_HALT_POLL_NS_DEFAULT 500000

#include <kvm/arm_vgic.h>
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@

#define LOONGSON_VIRT_REG_BASE	0x1f000000
#define KVM_MAX_VCPUS		256
#define KVM_USER_MEM_SLOTS	256
/* memory slots that does not exposed to userspace */
#define KVM_PRIVATE_MEM_SLOTS	0

+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@


#define KVM_MAX_VCPUS		16
#define KVM_USER_MEM_SLOTS	16
/* memory slots that does not exposed to userspace */
#define KVM_PRIVATE_MEM_SLOTS	0

+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@

#define KVM_MAX_VCPUS		NR_CPUS
#define KVM_MAX_VCORES		NR_CPUS
#define KVM_USER_MEM_SLOTS	512

#include <asm/cputhreads.h>

+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#define KVM_MAX_VCPUS			(1U << 9)
#endif

#define KVM_USER_MEM_SLOTS		512
#define KVM_HALT_POLL_NS_DEFAULT	500000

#define KVM_VCPU_MAX_FEATURES		0
Loading