[PATCH 0/3] RISC-V: KVM: Fix skip of valid pages in gstage ops
wu.fei9 at sanechips.com.cn
wu.fei9 at sanechips.com.cn
Mon May 11 03:49:44 PDT 2026
The current gstage range walker unconditionally advances by 'page_size'
when a leaf PTE is not found, e.g. when the range to wp is
[0xfffff01fc000, 0xfffff023c000) , if found_leaf of 0xfffff01fc000
returns false and page_size is 2MB, it skips the whole range, but it's
possible to have valid entries in [0xfffff0200000, 0xfffff023c000), so
only [0xfffff01fc000, 0xfffff0200000) can be skipped safely. Both
wp/unamp have the same pattern.
dirty_log_test intentionally sets up the unaligned guest physical
address, after riscv kvm enabling KVM_DIRTY_LOG_INITIALLY_SET, it's easy
to trigger this bug if there is a larger window for guest to write more
pages before first collect_dirty_pages.
Wu Fei (3):
KVM: selftests: Add unit to dirty_log_test
RISC-V: KVM: Fix skip of valid pages in kvm_riscv_gstage_wp_range
RISC-V: KVM: Fix skip of valid pages in kvm_riscv_gstage_unmap_range
arch/riscv/kvm/gstage.c | 39 +++++++++++---------
tools/testing/selftests/kvm/dirty_log_test.c | 24 ++++++++----
2 files changed, 39 insertions(+), 24 deletions(-)
--
2.43.0
More information about the linux-riscv
mailing list