mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
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
This commit is contained in:
@@ -50,6 +50,9 @@ struct kvm_vcpu {
|
||||
int fd;
|
||||
struct kvm_vm *vm;
|
||||
struct kvm_run *run;
|
||||
#ifdef __x86_64__
|
||||
struct kvm_cpuid2 *cpuid;
|
||||
#endif
|
||||
struct kvm_dirty_gfn *dirty_gfns;
|
||||
uint32_t fetch_index;
|
||||
uint32_t dirty_gfns_count;
|
||||
@@ -748,6 +751,8 @@ static inline struct kvm_vcpu *vm_vcpu_recreate(struct kvm_vm *vm,
|
||||
return vm_arch_vcpu_recreate(vm, vcpu_id);
|
||||
}
|
||||
|
||||
void vcpu_arch_free(struct kvm_vcpu *vcpu);
|
||||
|
||||
void virt_arch_pgd_alloc(struct kvm_vm *vm);
|
||||
|
||||
static inline void virt_pgd_alloc(struct kvm_vm *vm)
|
||||
|
||||
Reference in New Issue
Block a user