KVM: selftests: Move page_align() to shared header

To avoid code duplication, move page_align() to the shared `kvm_util.h`
header file. Rename it to vm_page_align(), to make it clear that the
alignment is done with respect to the guest's base page size.

No functional change intended.

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260109082218.3236580-5-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
Fuad Tabba
2026-01-09 08:22:17 +00:00
committed by Marc Zyngier
parent 582b39463f
commit de00d07321
3 changed files with 7 additions and 12 deletions

View File

@@ -1258,6 +1258,11 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)
return __vm_enable_cap(vm, KVM_CAP_VM_DISABLE_NX_HUGE_PAGES, 0);
}
static inline uint64_t vm_page_align(struct kvm_vm *vm, uint64_t v)
{
return (v + vm->page_size - 1) & ~(vm->page_size - 1);
}
/*
* Arch hook that is invoked via a constructor, i.e. before exeucting main(),
* to allow for arch-specific setup that is common to all tests, e.g. computing