Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Stop hardcoding PAGE_SIZE in x86 selftests

Use PAGE_SIZE instead of 4096.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251021074736.1324328-9-yosry.ahmed@linux.dev
Signed-off-by: Sean Christopherson <seanjc@google.com>

authored by

Yosry Ahmed and committed by
Sean Christopherson
28b2dced 3c40777f

+18 -18
+1 -1
tools/testing/selftests/kvm/x86/hyperv_features.c
··· 94 94 95 95 if (!(hcall->control & HV_HYPERCALL_FAST_BIT)) { 96 96 input = pgs_gpa; 97 - output = pgs_gpa + 4096; 97 + output = pgs_gpa + PAGE_SIZE; 98 98 } else { 99 99 input = output = 0; 100 100 }
+9 -9
tools/testing/selftests/kvm/x86/hyperv_ipi.c
··· 102 102 /* 'Slow' HvCallSendSyntheticClusterIpi to RECEIVER_VCPU_ID_1 */ 103 103 ipi->vector = IPI_VECTOR; 104 104 ipi->cpu_mask = 1 << RECEIVER_VCPU_ID_1; 105 - hyperv_hypercall(HVCALL_SEND_IPI, pgs_gpa, pgs_gpa + 4096); 105 + hyperv_hypercall(HVCALL_SEND_IPI, pgs_gpa, pgs_gpa + PAGE_SIZE); 106 106 nop_loop(); 107 107 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_1] == ++ipis_expected[0]); 108 108 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_2] == ipis_expected[1]); ··· 116 116 GUEST_SYNC(stage++); 117 117 118 118 /* 'Slow' HvCallSendSyntheticClusterIpiEx to RECEIVER_VCPU_ID_1 */ 119 - memset(hcall_page, 0, 4096); 119 + memset(hcall_page, 0, PAGE_SIZE); 120 120 ipi_ex->vector = IPI_VECTOR; 121 121 ipi_ex->vp_set.format = HV_GENERIC_SET_SPARSE_4K; 122 122 ipi_ex->vp_set.valid_bank_mask = 1 << 0; 123 123 ipi_ex->vp_set.bank_contents[0] = BIT(RECEIVER_VCPU_ID_1); 124 124 hyperv_hypercall(HVCALL_SEND_IPI_EX | (1 << HV_HYPERCALL_VARHEAD_OFFSET), 125 - pgs_gpa, pgs_gpa + 4096); 125 + pgs_gpa, pgs_gpa + PAGE_SIZE); 126 126 nop_loop(); 127 127 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_1] == ++ipis_expected[0]); 128 128 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_2] == ipis_expected[1]); ··· 138 138 GUEST_SYNC(stage++); 139 139 140 140 /* 'Slow' HvCallSendSyntheticClusterIpiEx to RECEIVER_VCPU_ID_2 */ 141 - memset(hcall_page, 0, 4096); 141 + memset(hcall_page, 0, PAGE_SIZE); 142 142 ipi_ex->vector = IPI_VECTOR; 143 143 ipi_ex->vp_set.format = HV_GENERIC_SET_SPARSE_4K; 144 144 ipi_ex->vp_set.valid_bank_mask = 1 << 1; 145 145 ipi_ex->vp_set.bank_contents[0] = BIT(RECEIVER_VCPU_ID_2 - 64); 146 146 hyperv_hypercall(HVCALL_SEND_IPI_EX | (1 << HV_HYPERCALL_VARHEAD_OFFSET), 147 - pgs_gpa, pgs_gpa + 4096); 147 + pgs_gpa, pgs_gpa + PAGE_SIZE); 148 148 nop_loop(); 149 149 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_1] == ipis_expected[0]); 150 150 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_2] == ++ipis_expected[1]); ··· 160 160 GUEST_SYNC(stage++); 161 161 162 162 /* 'Slow' HvCallSendSyntheticClusterIpiEx to both RECEIVER_VCPU_ID_{1,2} */ 163 - memset(hcall_page, 0, 4096); 163 + memset(hcall_page, 0, PAGE_SIZE); 164 164 ipi_ex->vector = IPI_VECTOR; 165 165 ipi_ex->vp_set.format = HV_GENERIC_SET_SPARSE_4K; 166 166 ipi_ex->vp_set.valid_bank_mask = 1 << 1 | 1; 167 167 ipi_ex->vp_set.bank_contents[0] = BIT(RECEIVER_VCPU_ID_1); 168 168 ipi_ex->vp_set.bank_contents[1] = BIT(RECEIVER_VCPU_ID_2 - 64); 169 169 hyperv_hypercall(HVCALL_SEND_IPI_EX | (2 << HV_HYPERCALL_VARHEAD_OFFSET), 170 - pgs_gpa, pgs_gpa + 4096); 170 + pgs_gpa, pgs_gpa + PAGE_SIZE); 171 171 nop_loop(); 172 172 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_1] == ++ipis_expected[0]); 173 173 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_2] == ++ipis_expected[1]); ··· 183 183 GUEST_SYNC(stage++); 184 184 185 185 /* 'Slow' HvCallSendSyntheticClusterIpiEx to HV_GENERIC_SET_ALL */ 186 - memset(hcall_page, 0, 4096); 186 + memset(hcall_page, 0, PAGE_SIZE); 187 187 ipi_ex->vector = IPI_VECTOR; 188 188 ipi_ex->vp_set.format = HV_GENERIC_SET_ALL; 189 - hyperv_hypercall(HVCALL_SEND_IPI_EX, pgs_gpa, pgs_gpa + 4096); 189 + hyperv_hypercall(HVCALL_SEND_IPI_EX, pgs_gpa, pgs_gpa + PAGE_SIZE); 190 190 nop_loop(); 191 191 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_1] == ++ipis_expected[0]); 192 192 GUEST_ASSERT(ipis_rcvd[RECEIVER_VCPU_ID_2] == ++ipis_expected[1]);
+1 -1
tools/testing/selftests/kvm/x86/sev_smoke_test.c
··· 104 104 vm_sev_launch(vm, policy, NULL); 105 105 106 106 /* This page is shared, so make it decrypted. */ 107 - memset(hva, 0, 4096); 107 + memset(hva, 0, PAGE_SIZE); 108 108 109 109 vcpu_run(vcpu); 110 110
+1 -1
tools/testing/selftests/kvm/x86/state_test.c
··· 141 141 142 142 if (this_cpu_has(X86_FEATURE_XSAVE)) { 143 143 uint64_t supported_xcr0 = this_cpu_supported_xcr0(); 144 - uint8_t buffer[4096]; 144 + uint8_t buffer[PAGE_SIZE]; 145 145 146 146 memset(buffer, 0xcc, sizeof(buffer)); 147 147
+1 -1
tools/testing/selftests/kvm/x86/userspace_io_test.c
··· 85 85 regs.rcx = 1; 86 86 if (regs.rcx == 3) 87 87 regs.rcx = 8192; 88 - memset((void *)run + run->io.data_offset, 0xaa, 4096); 88 + memset((void *)run + run->io.data_offset, 0xaa, PAGE_SIZE); 89 89 vcpu_regs_set(vcpu, &regs); 90 90 } 91 91
+5 -5
tools/testing/selftests/kvm/x86/vmx_dirty_log_test.c
··· 122 122 if (enable_ept) { 123 123 prepare_eptp(vmx, vm, 0); 124 124 nested_map_memslot(vmx, vm, 0); 125 - nested_map(vmx, vm, NESTED_TEST_MEM1, GUEST_TEST_MEM, 4096); 126 - nested_map(vmx, vm, NESTED_TEST_MEM2, GUEST_TEST_MEM, 4096); 125 + nested_map(vmx, vm, NESTED_TEST_MEM1, GUEST_TEST_MEM, PAGE_SIZE); 126 + nested_map(vmx, vm, NESTED_TEST_MEM2, GUEST_TEST_MEM, PAGE_SIZE); 127 127 } 128 128 129 129 bmap = bitmap_zalloc(TEST_MEM_PAGES); 130 130 host_test_mem = addr_gpa2hva(vm, GUEST_TEST_MEM); 131 131 132 132 while (!done) { 133 - memset(host_test_mem, 0xaa, TEST_MEM_PAGES * 4096); 133 + memset(host_test_mem, 0xaa, TEST_MEM_PAGES * PAGE_SIZE); 134 134 vcpu_run(vcpu); 135 135 TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO); 136 136 ··· 153 153 } 154 154 155 155 TEST_ASSERT(!test_bit(1, bmap), "Page 1 incorrectly reported dirty"); 156 - TEST_ASSERT(host_test_mem[4096 / 8] == 0xaaaaaaaaaaaaaaaaULL, "Page 1 written by guest"); 156 + TEST_ASSERT(host_test_mem[PAGE_SIZE / 8] == 0xaaaaaaaaaaaaaaaaULL, "Page 1 written by guest"); 157 157 TEST_ASSERT(!test_bit(2, bmap), "Page 2 incorrectly reported dirty"); 158 - TEST_ASSERT(host_test_mem[8192 / 8] == 0xaaaaaaaaaaaaaaaaULL, "Page 2 written by guest"); 158 + TEST_ASSERT(host_test_mem[PAGE_SIZE*2 / 8] == 0xaaaaaaaaaaaaaaaaULL, "Page 2 written by guest"); 159 159 break; 160 160 case UCALL_DONE: 161 161 done = true;