Skip to content

Commit 9cb1944

Browse files
yosrym93sean-jc
authored andcommitted
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>
1 parent 07676c0 commit 9cb1944

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • tools/testing/selftests/kvm/lib/x86

tools/testing/selftests/kvm/lib/x86/vmx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ bool kvm_cpu_has_ept(void)
377377
{
378378
uint64_t ctrl;
379379

380+
if (!kvm_cpu_has(X86_FEATURE_VMX))
381+
return false;
382+
380383
ctrl = kvm_get_feature_msr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS) >> 32;
381384
if (!(ctrl & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS))
382385
return false;

0 commit comments

Comments
 (0)