linux-xiaomi-chiron/tools/testing/selftests/kvm/lib
Sean Christopherson 7fbc6038ac KVM: selftests: Cache CPUID in struct kvm_vcpu
Cache a vCPU's CPUID information in "struct kvm_vcpu" to allow fixing the
mess where tests, often unknowingly, modify the global/static "cpuid"
allocated by kvm_get_supported_cpuid().

Add vcpu_init_cpuid() to handle stuffing an entirely different CPUID
model, e.g. during vCPU creation or when switching to the Hyper-V enabled
CPUID model.  Automatically refresh the cache on vcpu_set_cpuid() so that
any adjustments made by KVM are always reflected in the cache.  Drop
vcpu_get_cpuid() entirely to force tests to use the cache, and to allow
adding e.g. vcpu_get_cpuid_entry() in the future without creating a
conflicting set of APIs where vcpu_get_cpuid() does KVM_GET_CPUID2, but
vcpu_get_cpuid_entry() does not.

Opportunistically convert the VMX nested state test and KVM PV test to
manipulating the vCPU's CPUID (because it's easy), but use
vcpu_init_cpuid() for the Hyper-V features test and "emulator error" test
to effectively retain their current behavior as they're less trivial to
convert.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-19-seanjc@google.com
2022-07-13 18:14:15 -07:00
..
aarch64 KVM: selftests: Sanity check input to ioctls() at build time 2022-06-11 11:48:09 -04:00
riscv KVM: selftests: Purge vm+vcpu_id == vcpu silliness 2022-06-11 11:47:22 -04:00
s390x KVM: selftests: Add kvm_has_cap() to provide syntactic sugar 2022-06-11 11:47:28 -04:00
x86_64 KVM: selftests: Cache CPUID in struct kvm_vcpu 2022-07-13 18:14:15 -07:00
assert.c KVM: selftests: Print the errno besides error-string in TEST_ASSERT 2021-04-20 04:18:52 -04:00
elf.c KVM: selftests: Get rid of kvm_util_internal.h 2022-06-11 11:46:19 -04:00
guest_modes.c KVM: selftests: Sanity check input to ioctls() at build time 2022-06-11 11:48:09 -04:00
io.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
kvm_util.c KVM: selftests: Cache CPUID in struct kvm_vcpu 2022-07-13 18:14:15 -07:00
perf_test_util.c KVM: selftests: Drop @num_percpu_pages from __vm_create_with_vcpus() 2022-06-11 11:47:25 -04:00
rbtree.c KVM: selftests: Keep track of memslots more efficiently 2021-05-27 07:45:54 -04:00
sparsebit.c kvm: selftests: Fix spelling mistake "missmatch" -> "mismatch" 2021-09-30 04:27:08 -04:00
test_util.c KVM: selftests: Assert mmap HVA is aligned when using HugeTLB 2021-11-16 07:43:25 -05:00