[PATCH 8/9] KVM: selftests: Support large VMs in demand paging test

Ben Gardon
2019-09-27T16:19:00Z

Move memslot 0 past 4 GiB to support the large page tables required to
map several TiB of memory.

Signed-off-by: Ben Gardon <bgardon@google.com>
---
tools/testing/selftests/kvm/demand_paging_test.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
index eb1f7e4b83de3..a733bb3c91fd4 100644
--- a/tools/testing/selftests/kvm/demand_paging_test.c
+++ b/tools/testing/selftests/kvm/demand_paging_test.c
@@ -24,6 +24,12 @@
#include "kvm_util.h"
#include "processor.h"

+/*
+ * Put slot 0 past the first 4G of guest physical address to avoid collision
+ * with KVM-internal memslots.
+ */
+#define SLOT_0_GPA (4UL << 30)
+
/* The memory slot index demand page */
#define TEST_MEM_SLOT_INDEX 1

@@ -171,7 +177,7 @@ static struct kvm_vm *create_vm(enum vm_guest_mode mode, int vcpus,
pages += (2 * pages) / PTES_PER_PT;
pages += ((2 * vcpus * vcpu_wss) >> PAGE_SHIFT_4K) / PTES_PER_PT;

- vm = vm_create(mode, pages, O_RDWR);
+ vm = _vm_create(mode, SLOT_0_GPA, pages, O_RDWR);
kvm_vm_elf_load(vm, program_invocation_name, 0, 0);
#ifdef __x86_64__
vm_create_irqchip(vm);
--
2.23.0.444.g18eeb5a265-goog