Skip to content

Commit dc90fe0

Browse files
sean-jcjfvogel
authored andcommitted
KVM: x86: Explicitly zero-initialize on-stack CPUID unions
commit bc52ae0a708cb6fa3926d11c88e3c55e1171b4a1 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]> (cherry picked from commit bbf821c35dab3211d6e4229656b4a53e04ca0c4e) Signed-off-by: Jack Vogel <[email protected]>
1 parent c2be65e commit dc90fe0

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
@@ -1048,8 +1048,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
10481048
}
10491049
break;
10501050
case 0xa: { /* Architectural Performance Monitoring */
1051-
union cpuid10_eax eax;
1052-
union cpuid10_edx edx;
1051+
union cpuid10_eax eax = { };
1052+
union cpuid10_edx edx = { };
10531053

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

10661066
if (kvm_pmu_cap.version)
10671067
edx.split.anythread_deprecated = 1;
1068-
edx.split.reserved1 = 0;
1069-
edx.split.reserved2 = 0;
10701068

10711069
entry->eax = eax.full;
10721070
entry->ebx = kvm_pmu_cap.events_mask;
@@ -1384,7 +1382,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
13841382
break;
13851383
/* AMD Extended Performance Monitoring and Debug */
13861384
case 0x80000022: {
1387-
union cpuid_0x80000022_ebx ebx;
1385+
union cpuid_0x80000022_ebx ebx = { };
13881386

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

0 commit comments

Comments
 (0)