[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241030134912.515725-7-roypat@amazon.co.uk>
Date: Wed, 30 Oct 2024 13:49:10 +0000
From: Patrick Roy <roypat@...zon.co.uk>
To: <tabba@...gle.com>, <quic_eberman@...cinc.com>, <david@...hat.com>,
<seanjc@...gle.com>, <pbonzini@...hat.com>, <jthoughton@...gle.com>,
<ackerleytng@...gle.com>, <vannapurve@...gle.com>, <rppt@...nel.org>
CC: Patrick Roy <roypat@...zon.co.uk>, <graf@...zon.com>,
<jgowans@...zon.com>, <derekmn@...zon.com>, <kalyazin@...zon.com>,
<xmarcalx@...zon.com>, <linux-mm@...ck.org>, <corbet@....net>,
<catalin.marinas@....com>, <will@...nel.org>, <chenhuacai@...nel.org>,
<kernel@...0n.name>, <paul.walmsley@...ive.com>, <palmer@...belt.com>,
<aou@...s.berkeley.edu>, <hca@...ux.ibm.com>, <gor@...ux.ibm.com>,
<agordeev@...ux.ibm.com>, <borntraeger@...ux.ibm.com>, <svens@...ux.ibm.com>,
<gerald.schaefer@...ux.ibm.com>, <tglx@...utronix.de>, <mingo@...hat.com>,
<bp@...en8.de>, <dave.hansen@...ux.intel.com>, <x86@...nel.org>,
<hpa@...or.com>, <luto@...nel.org>, <peterz@...radead.org>,
<rostedt@...dmis.org>, <mhiramat@...nel.org>,
<mathieu.desnoyers@...icios.com>, <shuah@...nel.org>, <kvm@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <loongarch@...ts.linux.dev>,
<linux-riscv@...ts.infradead.org>, <linux-s390@...r.kernel.org>,
<linux-trace-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>
Subject: [RFC PATCH v3 6/6] kvm: selftests: run gmem tests with KVM_GMEM_NO_DIRECT_MAP set
Also adjust test_create_guest_memfd_invalid, as now BIT(0) is a
valid value for flags (note that this also fixes an issue where the loop
in test_create_guest_memfd_invalid is a noop. I've posted that fix as a
separate patch last week [1]).
[1]: https://lore.kernel.org/kvm/20241024095956.3668818-1-roypat@amazon.co.uk/
Signed-off-by: Patrick Roy <roypat@...zon.co.uk>
---
tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
.../selftests/kvm/x86_64/private_mem_conversions_test.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index ba0c8e9960358..d04f7ff3dfb15 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
size);
}
- for (flag = 0; flag; flag <<= 1) {
+ for (flag = BIT(1); flag; flag <<= 1) {
fd = __vm_create_guest_memfd(vm, page_size, flag);
TEST_ASSERT(fd == -1 && errno == EINVAL,
"guest_memfd() with flag '0x%lx' should fail with EINVAL",
diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
index 82a8d88b5338e..dfc78781e93b8 100644
--- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
+++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
@@ -367,7 +367,7 @@ static void *__test_mem_conversions(void *__vcpu)
}
static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t nr_vcpus,
- uint32_t nr_memslots)
+ uint32_t nr_memslots, uint64_t gmem_flags)
{
/*
* Allocate enough memory so that each vCPU's chunk of memory can be
@@ -394,7 +394,7 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t
vm_enable_cap(vm, KVM_CAP_EXIT_HYPERCALL, (1 << KVM_HC_MAP_GPA_RANGE));
- memfd = vm_create_guest_memfd(vm, memfd_size, 0);
+ memfd = vm_create_guest_memfd(vm, memfd_size, gmem_flags);
for (i = 0; i < nr_memslots; i++)
vm_mem_add(vm, src_type, BASE_DATA_GPA + slot_size * i,
@@ -477,7 +477,8 @@ int main(int argc, char *argv[])
}
}
- test_mem_conversions(src_type, nr_vcpus, nr_memslots);
+ test_mem_conversions(src_type, nr_vcpus, nr_memslots, 0);
+ test_mem_conversions(src_type, nr_vcpus, nr_memslots, KVM_GMEM_NO_DIRECT_MAP);
return 0;
}
--
2.47.0
Powered by blists - more mailing lists