linux/tools/testing/selftests/kvm
Zenghui Yu 309505dd56 KVM: selftests: Fix mapping length truncation in m{,un}map()
max_mem_slots is now declared as uint32_t. The result of (0x200000 * 32767)
is unexpectedly truncated to be 0xffe00000, whilst we actually need to
allocate about, 63GB. Cast max_mem_slots to size_t in both mmap() and
munmap() to fix the length truncation.

We'll otherwise see the failure on arm64 thanks to the access_ok() checking
in __kvm_set_memory_region(), as the unmapped VA happen to go beyond the
task's allowed address space.

 # ./set_memory_region_test
Allowed number of memory slots: 32767
Adding slots 0..32766, each memory region with 2048K size
==== Test Assertion Failure ====
  set_memory_region_test.c:391: ret == 0
  pid=94861 tid=94861 errno=22 - Invalid argument
     1	0x00000000004015a7: test_add_max_memory_regions at set_memory_region_test.c:389
     2	 (inlined by) main at set_memory_region_test.c:426
     3	0x0000ffffb8e67bdf: ?? ??:0
     4	0x00000000004016db: _start at :?
  KVM_SET_USER_MEMORY_REGION IOCTL failed,
  rc: -1 errno: 22 slot: 2615

Fixes: 3bf0fcd754 ("KVM: selftests: Speed up set_memory_region_test")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Message-Id: <20210624070931.565-1-yuzenghui@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-06-24 04:04:38 -04:00
..
aarch64 KVM: selftests: vgic_init kvm selftests fixup 2021-04-07 15:50:50 +01:00
include selftests: kvm: Add support for customized slot0 memory size 2021-06-08 13:29:10 -04:00
lib KVM: selftests: Fix kvm_check_cap() assertion 2021-06-17 13:06:57 -04:00
s390x KVM: selftests: sync_regs test for diag318 2020-12-10 13:36:05 +01:00
x86_64 KVM: selftests: Print a message if /dev/kvm is missing 2021-05-27 07:45:55 -04:00
.gitignore KVM: selftests: add a memslot-related performance benchmark 2021-05-27 07:45:54 -04:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: add shared hugetlbfs backing source type 2021-05-27 07:45:57 -04:00
dirty_log_perf_test.c KVM: selftests: Disable dirty logging with vCPUs running 2021-02-04 05:27:20 -05:00
dirty_log_test.c KVM: selftests: Always run vCPU thread with blocked SIG_IPI 2021-04-21 12:20:02 -04:00
hardware_disable_test.c KVM: selftests: Fix hang in hardware_disable_test 2021-05-27 07:45:55 -04:00
kvm_create_max_vcpus.c KVM: selftests: Convert some printf's to pr_info's 2020-03-16 17:57:07 +01:00
kvm_page_table_test.c selftests: kvm: Add support for customized slot0 memory size 2021-06-08 13:29:10 -04:00
Makefile KVM: selftests: add a memslot-related performance benchmark 2021-05-27 07:45:54 -04:00
memslot_modification_stress_test.c KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn() 2021-05-27 07:45:54 -04:00
memslot_perf_test.c selftests: kvm: Add support for customized slot0 memory size 2021-06-08 13:29:10 -04:00
set_memory_region_test.c KVM: selftests: Fix mapping length truncation in m{,un}map() 2021-06-24 04:04:38 -04:00
settings selftests: kvm: Raise the default timeout to 120 seconds 2021-02-09 08:17:08 -05:00
steal_time.c KVM: selftests: Rework timespec functions and usage 2020-03-18 14:08:56 +01:00