Commit f21940a3 authored by Sean Christopherson's avatar Sean Christopherson
Browse files

KVM: selftests: Use kvm_cpu_has() for nested SVM checks



Use kvm_cpu_has() to check for nested SVM support, and drop the helpers
now that their functionality is trivial to implement.

No functional change intended.

Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-6-seanjc@google.com
parent c5c5b827
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ struct svm_test_data {
struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
bool nested_svm_supported(void);
void nested_svm_check_supported(void);

static inline bool cpu_has_svm(void)
{
+0 −13
Original line number Diff line number Diff line
@@ -164,19 +164,6 @@ void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa)
		: "r15", "memory");
}

bool nested_svm_supported(void)
{
	struct kvm_cpuid_entry2 *entry =
		kvm_get_supported_cpuid_entry(0x80000001);

	return entry->ecx & CPUID_SVM;
}

void nested_svm_check_supported(void)
{
	TEST_REQUIRE(nested_svm_supported());
}

/*
 * Open SEV_DEV_PATH if available, otherwise exit the entire program.
 *
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
	struct ucall uc;
	int stage;

	TEST_REQUIRE(nested_svm_supported());
	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));

	/* Create VM */
	vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
	vcpu_set_msr(vcpu, MSR_IA32_SMBASE, SMRAM_GPA);

	if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
		if (nested_svm_supported())
		if (kvm_cpu_has(X86_FEATURE_SVM))
			vcpu_alloc_svm(vm, &nested_gva);
		else if (nested_vmx_supported())
			vcpu_alloc_vmx(vm, &nested_gva);
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
	vcpu_regs_get(vcpu, &regs1);

	if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
		if (nested_svm_supported())
		if (kvm_cpu_has(X86_FEATURE_SVM))
			vcpu_alloc_svm(vm, &nested_gva);
		else if (nested_vmx_supported())
			vcpu_alloc_vmx(vm, &nested_gva);
Loading