Skip to content

Commit dd0c5d0

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: 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: 7a6629e ("kvm: selftests: add virt mem support for aarch64") Reviewed-by: Andrew Jones <andrew.jones@linux.dev> Signed-off-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20260109082218.3236580-3-tabba@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 7e03d07 commit dd0c5d0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/testing/selftests/kvm/lib/arm64/processor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static vm_vaddr_t exception_handlers;
2323

2424
static uint64_t page_align(struct kvm_vm *vm, uint64_t v)
2525
{
26-
return (v + vm->page_size) & ~(vm->page_size - 1);
26+
return (v + vm->page_size - 1) & ~(vm->page_size - 1);
2727
}
2828

2929
static uint64_t pgd_index(struct kvm_vm *vm, vm_vaddr_t gva)

0 commit comments

Comments
 (0)