linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test
@ 2022-10-13  6:30 Gavin Shan
  2022-10-13 11:35 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Gavin Shan @ 2022-10-13  6:30 UTC (permalink / raw)
  To: kvmarm
  Cc: kvmarm, kvm, linux-kernel, maz, oliver.upton, pbonzini, shuah,
	dmatlack, peterx, venkateshs, seanjc, shan.gavin, ajones

It's required by vm_userspace_mem_region_add() that memory size
should be aligned to host page size. However, one guest page is
provided by memslot_modification_stress_test. It triggers failure
in the scenario of 64KB-page-size-host and 4KB-page-size-guest,
as the following messages indicate.

 # ./memslot_modification_stress_test
 Testing guest mode: PA-bits:40,  VA-bits:48,  4K pages
 guest physical test memory: [0xffbfff0000, 0xffffff0000)
 Finished creating vCPUs
 Started all vCPUs
 ==== Test Assertion Failure ====
   lib/kvm_util.c:824: vm_adjust_num_guest_pages(vm->mode, npages) == npages
   pid=5712 tid=5712 errno=0 - Success
      1	0x0000000000404eeb: vm_userspace_mem_region_add at kvm_util.c:822
      2	0x0000000000401a5b: add_remove_memslot at memslot_modification_stress_test.c:82
      3	 (inlined by) run_test at memslot_modification_stress_test.c:110
      4	0x0000000000402417: for_each_guest_mode at guest_modes.c:100
      5	0x00000000004016a7: main at memslot_modification_stress_test.c:187
      6	0x0000ffffb8cd4383: ?? ??:0
      7	0x0000000000401827: _start at :?
   Number of guest pages is not compatible with the host. Try npages=16

Fix the issue by providing 16 guest pages to the memory slot for this
particular combination of 64KB-page-size-host and 4KB-page-size-guest
on aarch64.

Fixes: ef4c9f4f65462 ("KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn()")
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 tools/testing/selftests/kvm/memslot_modification_stress_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
index 6ee7e1dde404..bb1d17a1171b 100644
--- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c
+++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
@@ -67,7 +67,7 @@ struct memslot_antagonist_args {
 static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay,
 			       uint64_t nr_modifications)
 {
-	const uint64_t pages = 1;
+	uint64_t pages = max_t(int, vm->page_size, getpagesize()) / vm->page_size;
 	uint64_t gpa;
 	int i;
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test
  2022-10-13  6:30 [PATCH] KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test Gavin Shan
@ 2022-10-13 11:35 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2022-10-13 11:35 UTC (permalink / raw)
  To: kvmarm, Gavin Shan
  Cc: oliver.upton, linux-kernel, ajones, kvm, seanjc, kvmarm,
	dmatlack, pbonzini, venkateshs, peterx, shan.gavin, shuah

On Thu, 13 Oct 2022 14:30:20 +0800, Gavin Shan wrote:
> It's required by vm_userspace_mem_region_add() that memory size
> should be aligned to host page size. However, one guest page is
> provided by memslot_modification_stress_test. It triggers failure
> in the scenario of 64KB-page-size-host and 4KB-page-size-guest,
> as the following messages indicate.
> 
>  # ./memslot_modification_stress_test
>  Testing guest mode: PA-bits:40,  VA-bits:48,  4K pages
>  guest physical test memory: [0xffbfff0000, 0xffffff0000)
>  Finished creating vCPUs
>  Started all vCPUs
>  ==== Test Assertion Failure ====
>    lib/kvm_util.c:824: vm_adjust_num_guest_pages(vm->mode, npages) == npages
>    pid=5712 tid=5712 errno=0 - Success
>       1	0x0000000000404eeb: vm_userspace_mem_region_add at kvm_util.c:822
>       2	0x0000000000401a5b: add_remove_memslot at memslot_modification_stress_test.c:82
>       3	 (inlined by) run_test at memslot_modification_stress_test.c:110
>       4	0x0000000000402417: for_each_guest_mode at guest_modes.c:100
>       5	0x00000000004016a7: main at memslot_modification_stress_test.c:187
>       6	0x0000ffffb8cd4383: ?? ??:0
>       7	0x0000000000401827: _start at :?
>    Number of guest pages is not compatible with the host. Try npages=16
> 
> [...]

Applied to fixes, thanks!

[1/1] KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test
      commit: 05c2224d4b049406b0545a10be05280ff4b8ba0a

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-13 11:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13  6:30 [PATCH] KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test Gavin Shan
2022-10-13 11:35 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).