mirror of
https://github.com/torvalds/linux.git
synced 2026-05-21 05:18:45 +02:00
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: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-7-seanjc@google.com
This commit is contained in:
parent
f21940a3bb
commit
1ecbb337fa
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ int main(int argc, char *argv[])
|
|||
if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
|
||||
if (kvm_cpu_has(X86_FEATURE_SVM))
|
||||
vcpu_alloc_svm(vm, &nested_gva);
|
||||
else if (nested_vmx_supported())
|
||||
else if (kvm_cpu_has(X86_FEATURE_VMX))
|
||||
vcpu_alloc_vmx(vm, &nested_gva);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ int main(int argc, char *argv[])
|
|||
if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
|
||||
if (kvm_cpu_has(X86_FEATURE_SVM))
|
||||
vcpu_alloc_svm(vm, &nested_gva);
|
||||
else if (nested_vmx_supported())
|
||||
else if (kvm_cpu_has(X86_FEATURE_VMX))
|
||||
vcpu_alloc_vmx(vm, &nested_gva);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ int main(void)
|
|||
vm_vaddr_t vmx_pages_gva;
|
||||
struct ucall uc;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
TEST_REQUIRE(kvm_has_cap(KVM_CAP_X86_TRIPLE_FAULT_EVENT));
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
|||
struct kvm_vcpu *vcpu;
|
||||
struct kvm_vm *vm;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
|
|||
struct kvm_vcpu *vcpu;
|
||||
struct kvm_vm *vm;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
|||
struct ucall uc;
|
||||
bool done = false;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
/* Create VM */
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
|||
struct kvm_run *run;
|
||||
struct ucall uc;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
|||
uint64_t l1_tsc_freq = 0;
|
||||
uint64_t l2_tsc_freq = 0;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
TEST_REQUIRE(kvm_has_cap(KVM_CAP_TSC_CONTROL));
|
||||
stable_tsc_check_supported();
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
|||
* AMD currently does not implement any VMX features, so for now we
|
||||
* just early out.
|
||||
*/
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
TEST_REQUIRE(kvm_has_cap(KVM_CAP_NESTED_STATE));
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ int main(int argc, char *argv[])
|
|||
* AMD currently does not implement set_nested_state, so for now we
|
||||
* just early out.
|
||||
*/
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ int main(int argc, char *argv[])
|
|||
vm_vaddr_t vmx_pages_gva;
|
||||
struct kvm_vcpu *vcpu;
|
||||
|
||||
nested_vmx_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, (void *) l1_guest_code);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user