Re: [PATCH v2 10/11] KVM: selftests: x86: Set supported CPUIDs on default VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 11, 2020 at 01:26:35PM +0100, Andrew Jones wrote:
> +void disable_vmx(struct kvm_vm *vm)
> +{
> +	struct kvm_cpuid2 *cpuid = kvm_get_supported_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(vm, VCPU_ID, cpuid);
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  	struct kvm_vm *vm;
> @@ -264,6 +280,11 @@ int main(int argc, char *argv[])
>  
>  	vm = vm_create_default(VCPU_ID, 0, 0);
>  
> +	/*
> +	 * First run tests with VMX disabled to check error handling.
> +	 */
> +	disable_vmx(vm);
> +

My gut feeling is that we may even drop these complexity, but simply remove the
vcpu_set_cpuid() in test_vmx_nested_state().  Since I see that most (or all?)
the tests before vcpu_set_cpuid() were a bunch of ioctl testings against
KVM_SET_NESTED_STATE - seems not really related to the applied cpuid at all...

-- 
Peter Xu




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux