Commit 22f232d1 authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

KVM: selftests: x86: Set supported CPUIDs on default VM



Almost all tests do this anyway and the ones that don't don't
appear to care. Only vmx_set_nested_state_test assumes that
a feature (VMX) is disabled until later setting the supported
CPUIDs. It's better to disable that explicitly anyway.

Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
Message-Id: <20201111122636.73346-11-drjones@redhat.com>
[Restore CPUID_VMX, or vmx_set_nested_state breaks. - Paolo]
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 08d3e277
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -740,9 +740,6 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
	/* Cache the HVA pointer of the region */
	host_test_mem = addr_gpa2hva(vm, (vm_paddr_t)guest_test_phys_mem);

#ifdef __x86_64__
	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
#endif
	ucall_init(vm, NULL);

	/* Export the shared variables to the guest */
+0 −4
Original line number Diff line number Diff line
@@ -179,10 +179,6 @@ static void add_vcpus(struct kvm_vm *vm, int vcpus, uint64_t vcpu_memory_bytes)

		vm_vcpu_add_default(vm, vcpu_id, guest_code);

#ifdef __x86_64__
		vcpu_set_cpuid(vm, vcpu_id, kvm_get_supported_cpuid());
#endif

		vcpu_args->vcpu_id = vcpu_id;
		vcpu_args->gva = guest_test_virt_mem +
				 (vcpu_id * vcpu_memory_bytes);
+9 −2
Original line number Diff line number Diff line
@@ -311,8 +311,15 @@ struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
	vm_create_irqchip(vm);
#endif

	for (i = 0; i < nr_vcpus; ++i)
		vm_vcpu_add_default(vm, vcpuids ? vcpuids[i] : i, guest_code);
	for (i = 0; i < nr_vcpus; ++i) {
		uint32_t vcpuid = vcpuids ? vcpuids[i] : i;

		vm_vcpu_add_default(vm, vcpuid, guest_code);

#ifdef __x86_64__
		vcpu_set_cpuid(vm, vcpuid, kvm_get_supported_cpuid());
#endif
	}

	return vm;
}
+0 −2
Original line number Diff line number Diff line
@@ -121,8 +121,6 @@ static struct kvm_vm *spawn_vm(pthread_t *vcpu_thread, void *guest_code)

	vm = vm_create_default(VCPU_ID, 0, guest_code);

	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());

	vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS_THP,
				    MEM_REGION_GPA, MEM_REGION_SLOT,
				    MEM_REGION_SIZE / getpagesize(), 0);
+0 −1
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ int main(int argc, char *argv[])

	/* Create VM */
	vm = vm_create_default(VCPU_ID, 0, guest_code);
	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
	run = vcpu_state(vm, VCPU_ID);

	while (1) {
Loading