Commit 9cb1944f authored by Yosry Ahmed's avatar Yosry Ahmed Committed by Sean Christopherson
Browse files

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: default avatarYosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251230230150.4150236-16-seanjc@google.com


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 07676c04
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;