Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1644780 > unrolled thread
| Started by | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| First post | 2017-05-18 19:40 +0200 |
| Last post | 2017-05-19 15:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/4] KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() Radim Krčmář <rkrcmar@redhat.com> - 2017-05-18 19:40 +0200
Re: [PATCH 3/4] KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() David Hildenbrand <david@redhat.com> - 2017-05-19 15:40 +0200
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2017-05-18 19:40 +0200 |
| Subject | [PATCH 3/4] KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() |
| Message-ID | <tIxz3-5R2-15@gated-at.bofh.it> |
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: 25462f7f5295 ("KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch")
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
arch/x86/kvm/pmu_intel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/pmu_intel.c b/arch/x86/kvm/pmu_intel.c
index 9d4a8504a95a..5ab4a364348e 100644
--- a/arch/x86/kvm/pmu_intel.c
+++ b/arch/x86/kvm/pmu_intel.c
@@ -294,7 +294,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
((u64)1 << edx.split.bit_width_fixed) - 1;
}
- pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
+ pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) |
(((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
pmu->global_ctrl_mask = ~pmu->global_ctrl;
--
2.13.0
[toc] | [next] | [standalone]
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Date | 2017-05-19 15:40 +0200 |
| Subject | Re: [PATCH 3/4] KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() |
| Message-ID | <tIQil-2MD-3@gated-at.bofh.it> |
| In reply to | #1644780 |
On 18.05.2017 19:37, Radim Krčmář wrote:
> 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: 25462f7f5295 ("KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch")
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
> arch/x86/kvm/pmu_intel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/pmu_intel.c b/arch/x86/kvm/pmu_intel.c
> index 9d4a8504a95a..5ab4a364348e 100644
> --- a/arch/x86/kvm/pmu_intel.c
> +++ b/arch/x86/kvm/pmu_intel.c
> @@ -294,7 +294,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
> ((u64)1 << edx.split.bit_width_fixed) - 1;
> }
>
> - pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
> + pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) |
> (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
> pmu->global_ctrl_mask = ~pmu->global_ctrl;
>
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web