mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 06:01:53 +02:00
KVM: selftests: Assert that vcpu->cpuid is non-NULL when getting CPUID entries
Add a sanity check in __vcpu_get_cpuid_entry() to provide a friendlier error than a segfault when a test developer tries to use a vCPU CPUID helper on a barebones vCPU. Link: https://lore.kernel.org/r/20241128013424.4096668-8-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
bf4dfc3aa8
commit
08833719e7
|
|
@ -1014,6 +1014,8 @@ static inline struct kvm_cpuid_entry2 *__vcpu_get_cpuid_entry(struct kvm_vcpu *v
|
|||
uint32_t function,
|
||||
uint32_t index)
|
||||
{
|
||||
TEST_ASSERT(vcpu->cpuid, "Must do vcpu_init_cpuid() first (or equivalent)");
|
||||
|
||||
return (struct kvm_cpuid_entry2 *)get_cpuid_entry(vcpu->cpuid,
|
||||
function, index);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user