Skip to content

Commit 3b1609f

Browse files
rkrcmargregkh
authored andcommitted
KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh()
commit 34b0dadbdf698f9b277a31b2747b625b9a75ea1f upstream. Static analysis noticed that pmu->nr_arch_gp_counters can be 32 (INTEL_PMC_MAX_GENERIC) and therefore cannot be used to shift 'int'. I didn't add BUILD_BUG_ON for it as we have a better checker. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Fixes: 25462f7 ("KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch") Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b9b3eb5 commit 3b1609f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/pmu_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
294294
((u64)1 << edx.split.bit_width_fixed) - 1;
295295
}
296296

297-
pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
297+
pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) |
298298
(((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
299299
pmu->global_ctrl_mask = ~pmu->global_ctrl;
300300

0 commit comments

Comments
 (0)