Skip to content

Commit 945897f

Browse files
sean-jcmehmetb0
authored andcommitted
KVM: x86: Explicitly zero-initialize on-stack CPUID unions
BugLink: https://bugs.launchpad.net/bugs/2108854 commit bc52ae0 upstream. Explicitly zero/empty-initialize the unions used for PMU related CPUID entries, instead of manually zeroing all fields (hopefully), or in the case of 0x80000022, relying on the compiler to clobber the uninitialized bitfields. Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Message-ID: <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 7c65065 commit 945897f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
14231423
}
14241424
break;
14251425
case 0xa: { /* Architectural Performance Monitoring */
1426-
union cpuid10_eax eax;
1427-
union cpuid10_edx edx;
1426+
union cpuid10_eax eax = { };
1427+
union cpuid10_edx edx = { };
14281428

14291429
if (!enable_pmu || !static_cpu_has(X86_FEATURE_ARCH_PERFMON)) {
14301430
entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
@@ -1440,8 +1440,6 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
14401440

14411441
if (kvm_pmu_cap.version)
14421442
edx.split.anythread_deprecated = 1;
1443-
edx.split.reserved1 = 0;
1444-
edx.split.reserved2 = 0;
14451443

14461444
entry->eax = eax.full;
14471445
entry->ebx = kvm_pmu_cap.events_mask;
@@ -1759,7 +1757,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
17591757
break;
17601758
/* AMD Extended Performance Monitoring and Debug */
17611759
case 0x80000022: {
1762-
union cpuid_0x80000022_ebx ebx;
1760+
union cpuid_0x80000022_ebx ebx = { };
17631761

17641762
entry->ecx = entry->edx = 0;
17651763
if (!enable_pmu || !kvm_cpu_cap_has(X86_FEATURE_PERFMON_V2)) {

0 commit comments

Comments
 (0)