Skip to content

Commit 8b03c97

Browse files
Ricardo KollerMarc Zyngier
authored andcommitted
KVM: selftests: aarch64: Fix check of dirty log PT write
The dirty log checks are mistakenly testing the first page in the page table (PT) memory region instead of the page holding the test data page PTE. This wasn't an issue before commit 406504c ("KVM: arm64: Fix S1PTW handling on RO memslots") as all PT pages (including the first page) were treated as writes. Fix the page_fault_test dirty logging tests by checking for the right page: the one for the PTE of the data test page. Fixes: a4edf25 ("KVM: selftests: aarch64: Add dirty logging tests into page_fault_test") Signed-off-by: Ricardo Koller <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4256175 commit 8b03c97

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/testing/selftests/kvm/aarch64/page_fault_test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,12 @@ static bool handle_cmd(struct kvm_vm *vm, int cmd)
470470
{
471471
struct userspace_mem_region *data_region, *pt_region;
472472
bool continue_test = true;
473+
uint64_t pte_gpa, pte_pg;
473474

474475
data_region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA);
475476
pt_region = vm_get_mem_region(vm, MEM_REGION_PT);
477+
pte_gpa = addr_hva2gpa(vm, virt_get_pte_hva(vm, TEST_GVA));
478+
pte_pg = (pte_gpa - pt_region->region.guest_phys_addr) / getpagesize();
476479

477480
if (cmd == CMD_SKIP_TEST)
478481
continue_test = false;
@@ -485,13 +488,13 @@ static bool handle_cmd(struct kvm_vm *vm, int cmd)
485488
TEST_ASSERT(check_write_in_dirty_log(vm, data_region, 0),
486489
"Missing write in dirty log");
487490
if (cmd & CMD_CHECK_S1PTW_WR_IN_DIRTY_LOG)
488-
TEST_ASSERT(check_write_in_dirty_log(vm, pt_region, 0),
491+
TEST_ASSERT(check_write_in_dirty_log(vm, pt_region, pte_pg),
489492
"Missing s1ptw write in dirty log");
490493
if (cmd & CMD_CHECK_NO_WRITE_IN_DIRTY_LOG)
491494
TEST_ASSERT(!check_write_in_dirty_log(vm, data_region, 0),
492495
"Unexpected write in dirty log");
493496
if (cmd & CMD_CHECK_NO_S1PTW_WR_IN_DIRTY_LOG)
494-
TEST_ASSERT(!check_write_in_dirty_log(vm, pt_region, 0),
497+
TEST_ASSERT(!check_write_in_dirty_log(vm, pt_region, pte_pg),
495498
"Unexpected s1ptw write in dirty log");
496499

497500
return continue_test;

0 commit comments

Comments
 (0)