KVM: selftests: Use vcpu_{set,clear}_cpuid_feature() in nVMX state test
Use vcpu_{set,clear}_cpuid_feature() to toggle nested VMX support in the vCPU CPUID module in the nVMX state test. Drop CPUID_VMX as there are no longer any users. Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-29-seanjc@google.com
This commit is contained in:
Родитель
49f6876a2e
Коммит
4ee315231e
|
@ -160,7 +160,6 @@ struct kvm_x86_cpu_feature {
|
|||
#define X86_FEATURE_KVM_MIGRATION_CONTROL KVM_X86_CPU_FEATURE(0x40000001, 0, EAX, 17)
|
||||
|
||||
/* CPUID.1.ECX */
|
||||
#define CPUID_VMX (1ul << 5)
|
||||
#define CPUID_XSAVE (1ul << 26)
|
||||
#define CPUID_OSXSAVE (1ul << 27)
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
|
|||
test_nested_state(vcpu, state);
|
||||
|
||||
/* Enable VMX in the guest CPUID. */
|
||||
vcpu_set_cpuid(vcpu);
|
||||
vcpu_set_cpuid_feature(vcpu, X86_FEATURE_VMX);
|
||||
|
||||
/*
|
||||
* Setting vmxon_pa == -1ull and vmcs_pa == -1ull exits early without
|
||||
|
@ -243,22 +243,6 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
|
|||
free(state);
|
||||
}
|
||||
|
||||
void disable_vmx(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
struct kvm_cpuid2 *cpuid = vcpu->cpuid;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cpuid->nent; ++i)
|
||||
if (cpuid->entries[i].function == 1 &&
|
||||
cpuid->entries[i].index == 0)
|
||||
break;
|
||||
TEST_ASSERT(i != cpuid->nent, "CPUID function 1 not found");
|
||||
|
||||
cpuid->entries[i].ecx &= ~CPUID_VMX;
|
||||
vcpu_set_cpuid(vcpu);
|
||||
cpuid->entries[i].ecx |= CPUID_VMX;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct kvm_vm *vm;
|
||||
|
@ -280,7 +264,7 @@ int main(int argc, char *argv[])
|
|||
/*
|
||||
* First run tests with VMX disabled to check error handling.
|
||||
*/
|
||||
disable_vmx(vcpu);
|
||||
vcpu_clear_cpuid_feature(vcpu, X86_FEATURE_VMX);
|
||||
|
||||
/* Passing a NULL kvm_nested_state causes a EFAULT. */
|
||||
test_nested_state_expect_efault(vcpu, NULL);
|
||||
|
|
Загрузка…
Ссылка в новой задаче