mirror of
https://github.com/torvalds/linux.git
synced 2026-05-21 21:37:25 +02:00
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: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-6-seanjc@google.com
This commit is contained in:
parent
c5c5b827f1
commit
f21940a3bb
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ int main(int argc, char *argv[])
|
|||
vcpu_regs_get(vcpu, ®s1);
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
|||
struct kvm_vm *vm;
|
||||
struct ucall uc;
|
||||
|
||||
nested_svm_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
|||
/* Tell stdout not to buffer its content */
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
nested_svm_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
|
||||
|
||||
cpuid = kvm_get_supported_cpuid_entry(0x8000000a);
|
||||
TEST_ASSERT(cpuid->edx & CPUID_NRIPS,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int main(int argc, char *argv[])
|
|||
vm_vaddr_t svm_gva;
|
||||
struct kvm_vm *vm;
|
||||
|
||||
nested_svm_check_supported();
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user