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

Configure Feed

Select the types of activity you want to include in your feed.

KVM: riscv: selftests: Fix incorrect rounding in page_align()

The implementation of `page_align()` in `processor.c` calculates
alignment incorrectly for values that are already aligned. Specifically,
`(v + vm->page_size) & ~(vm->page_size - 1)` aligns to the *next* page
boundary even if `v` is already page-aligned, potentially wasting a page
of memory.

Fix the calculation to use standard alignment logic: `(v + vm->page_size
- 1) & ~(vm->page_size - 1)`.

Fixes: 3e06cdf10520 ("KVM: selftests: Add initial support for RISC-V 64-bit")
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260109082218.3236580-4-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Fuad Tabba and committed by
Marc Zyngier
582b3946 dd0c5d04

+1 -1
+1 -1
tools/testing/selftests/kvm/lib/riscv/processor.c
··· 28 28 29 29 static uint64_t page_align(struct kvm_vm *vm, uint64_t v) 30 30 { 31 - return (v + vm->page_size) & ~(vm->page_size - 1); 31 + return (v + vm->page_size - 1) & ~(vm->page_size - 1); 32 32 } 33 33 34 34 static uint64_t pte_addr(struct kvm_vm *vm, uint64_t entry)