Commit 1ecbb337 authored by Sean Christopherson's avatar Sean Christopherson
Browse files

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



Use kvm_cpu_has() to check for nested VMX 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-7-seanjc@google.com
parent f21940a3
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -607,8 +607,6 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx);
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp);
bool load_vmcs(struct vmx_pages *vmx);

bool nested_vmx_supported(void);
void nested_vmx_check_supported(void);
bool ept_1g_pages_supported(void);

void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ void perf_test_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vc
	vm_vaddr_t vmx_gva;
	int vcpu_id;

	nested_vmx_check_supported();
	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));

	for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) {
		vmx = vcpu_alloc_vmx(vm, &vmx_gva);
+0 −12
Original line number Diff line number Diff line
@@ -382,18 +382,6 @@ void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp)
	init_vmcs_guest_state(guest_rip, guest_rsp);
}

bool nested_vmx_supported(void)
{
	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);

	return entry->ecx & CPUID_VMX;
}

void nested_vmx_check_supported(void)
{
	TEST_REQUIRE(nested_vmx_supported());
}

static void nested_create_pte(struct kvm_vm *vm,
			      struct eptPageTableEntry *pte,
			      uint64_t nested_paddr,
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])

	vm = vm_create_with_one_vcpu(&vcpu, guest_code);

	TEST_REQUIRE(nested_vmx_supported());
	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
	TEST_REQUIRE(kvm_has_cap(KVM_CAP_NESTED_STATE));
	TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS));

+2 −2
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
	test_hv_cpuid(hv_cpuid_entries, false);
	free(hv_cpuid_entries);

	if (!nested_vmx_supported() ||
	if (!kvm_cpu_has(X86_FEATURE_VMX) ||
	    !kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) {
		print_skip("Enlightened VMCS is unsupported");
		goto do_sys;
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
	test_hv_cpuid_e2big(vm, NULL);

	hv_cpuid_entries = kvm_get_supported_hv_cpuid();
	test_hv_cpuid(hv_cpuid_entries, nested_vmx_supported());
	test_hv_cpuid(hv_cpuid_entries, kvm_cpu_has(X86_FEATURE_VMX));

out:
	kvm_vm_free(vm);
Loading