aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/lib/test_util.c
diff options
context:
space:
mode:
authorSean Christopherson <[email protected]>2021-11-11 00:03:01 +0000
committerPaolo Bonzini <[email protected]>2021-11-16 07:43:25 -0500
commitf4870ef3e15ab889a689f99a579fe0fe7c53a960 (patch)
tree93aab38a2b461063181ac183308013130e265104 /tools/testing/selftests/kvm/lib/test_util.c
parentc071ff41e1502990a0902c7c3fcf72a462e46330 (diff)
KVM: selftests: Assert mmap HVA is aligned when using HugeTLB
Manually padding and aligning the mmap region is only needed when using THP. When using HugeTLB, mmap will always return an address aligned to the HugeTLB page size. Add a comment to clarify this and assert the mmap behavior for HugeTLB. [Removed requirement that HugeTLB mmaps must be padded per Yanan's feedback and added assertion that mmap returns aligned addresses when using HugeTLB.] Cc: Ben Gardon <[email protected]> Cc: Yanan Wang <[email protected]> Cc: Andrew Jones <[email protected]> Cc: Peter Xu <[email protected]> Cc: Aaron Lewis <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: David Matlack <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/test_util.c')
-rw-r--r--tools/testing/selftests/kvm/lib/test_util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
index b72429108993..6d23878bbfe1 100644
--- a/tools/testing/selftests/kvm/lib/test_util.c
+++ b/tools/testing/selftests/kvm/lib/test_util.c
@@ -283,6 +283,11 @@ size_t get_backing_src_pagesz(uint32_t i)
}
}
+bool is_backing_src_hugetlb(uint32_t i)
+{
+ return !!(vm_mem_backing_src_alias(i)->flag & MAP_HUGETLB);
+}
+
static void print_available_backing_src_types(const char *prefix)
{
int i;