]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: selftests: Add a hugetlb memslot alignment test mode
authorJinyu Tang <tjytimi@163.com>
Thu, 4 Jun 2026 14:26:02 +0000 (22:26 +0800)
committerAnup Patel <anup@brainfault.org>
Sun, 7 Jun 2026 05:46:18 +0000 (11:16 +0530)
commitc8aafbebfc95d9b65b9b86573dc47723fa621358
treef01bac5652e2fcf2df416cc4d17cae522dd70ba6
parent49476d58f2171afc2e899da8040710d2c37760af
KVM: selftests: Add a hugetlb memslot alignment test mode

kvm_page_table_test can already exercise hugetlb-backed guest memory,
but it always creates the test memslot with GPA alignment matching the
hugetlb backing size. That misses the case where a valid hugetlb
memslot is later moved so that the memslot GPA and HVA no longer have
the same offset within the backing huge page.

Add a -u option that moves the test memslot GPA by one guest page after
creating the hugetlb memslot. The memslot is created through the normal
helper first, so the backing allocation remains valid and hugetlb aligned.
Moving the memslot then creates a deliberate HVA/GPA offset mismatch
before the guest mapping is installed.

This mode is useful for checking that architecture MMUs do not install
a block mapping when the block would map the wrong host pages or cover
memory outside the memslot. The option is restricted to hugetlb-backed
test memory because it's specifically about hugetlb block mapping
eligibility.

Signed-off-by: Jinyu Tang <tjytimi@163.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260604142602.3582602-3-tjytimi@163.com
Signed-off-by: Anup Patel <anup@brainfault.org>
tools/testing/selftests/kvm/kvm_page_table_test.c