OSDN Git Service

KVM: selftests: Fix nx_huge_pages_test on TDP-disabled hosts
authorDavid Matlack <dmatlack@google.com>
Thu, 29 Sep 2022 18:12:07 +0000 (11:12 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 30 Sep 2022 10:39:36 +0000 (06:39 -0400)
commit458e98746fa852d744d34b5a8d0b1673959efc2f
tree32e32bcebee63ef2398050116e84da76b01bc28a
parent4d2bd14319e4e0a49fc868c50ca0b2a747b58208
KVM: selftests: Fix nx_huge_pages_test on TDP-disabled hosts

Map the test's huge page region with 2MiB virtual mappings when TDP is
disabled so that KVM can shadow the region with huge pages. This fixes
nx_huge_pages_test on hosts where TDP hardware support is disabled.

Purposely do not skip this test on TDP-disabled hosts. While we don't
care about NX Huge Pages on TDP-disabled hosts from a security
perspective, KVM does support it, and so we should test it.

For TDP-enabled hosts, continue mapping the region with 4KiB pages to
ensure that KVM can map it with huge pages irrespective of the guest
mappings.

Fixes: 8448ec5993be ("KVM: selftests: Add NX huge pages test")
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20220929181207.2281449-4-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/include/x86_64/processor.h
tools/testing/selftests/kvm/lib/x86_64/processor.c
tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c