diff options
| author | Yosry Ahmed <yosry.ahmed@linux.dev> | 2025-12-30 15:01:44 -0800 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-01-08 12:02:14 -0800 |
| commit | 9cb1944f6bf09ecebcc7609f35178b85aa26f165 (patch) | |
| tree | 1ba5d7c848d6b4715b89590193ca72e719a37faf /tools/testing/selftests/kvm/lib | |
| parent | 07676c04bd753f32a9fe2f247b0ba2d213dd7a99 (diff) | |
KVM: selftests: Allow kvm_cpu_has_ept() to be called on AMD CPUs
In preparation for generalizing the nested dirty logging test, checking
if either EPT or NPT is enabled will be needed. To avoid needing to gate
the kvm_cpu_has_ept() call by the CPU type, make sure the function
returns false if VMX is not available instead of trying to read VMX-only
MSRs.
No functional change intended.
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251230230150.4150236-16-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib')
| -rw-r--r-- | tools/testing/selftests/kvm/lib/x86/vmx.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c index 448a63457467..c87b340362a9 100644 --- a/tools/testing/selftests/kvm/lib/x86/vmx.c +++ b/tools/testing/selftests/kvm/lib/x86/vmx.c @@ -377,6 +377,9 @@ bool kvm_cpu_has_ept(void) { uint64_t ctrl; + if (!kvm_cpu_has(X86_FEATURE_VMX)) + return false; + ctrl = kvm_get_feature_msr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS) >> 32; if (!(ctrl & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) return false; |
