Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1399144 > unrolled thread

[PATCH] perf/x86: fix undefined shift on 32-bit kernels

Started byAndrey Ryabinin <aryabinin@virtuozzo.com>
First post2016-05-11 16:10 +0200
Last post2016-05-12 12:40 +0200
Articles 3 — 3 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.


Contents

  [PATCH] perf/x86: fix undefined shift on 32-bit kernels Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-05-11 16:10 +0200
    Re: [PATCH] perf/x86: fix undefined shift on 32-bit kernels Peter Zijlstra <peterz@infradead.org> - 2016-05-11 16:10 +0200
    [tip:perf/core] perf/x86: Fix undefined shift on 32-bit kernels tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2016-05-12 12:40 +0200

#1399144 — [PATCH] perf/x86: fix undefined shift on 32-bit kernels

FromAndrey Ryabinin <aryabinin@virtuozzo.com>
Date2016-05-11 16:10 +0200
Subject[PATCH] perf/x86: fix undefined shift on 32-bit kernels
Message-ID<rxCZQ-1jh-23@gated-at.bofh.it>
Jim reported:
	UBSAN: Undefined behaviour in arch/x86/events/intel/core.c:3708:12
	shift exponent 35 is too large for 32-bit type 'long unsigned int'

The use of 'unsigned long' type obviously is not correct here, make it
'unsigned long long' instead.

Fixes: 2c33645d366d ("perf/x86: Honor the architectural performance monitoring version")
Reported-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 arch/x86/events/intel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a6fd4db..5210eaa 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3708,7 +3708,7 @@ __init int intel_pmu_init(void)
 				c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
 			}
 			c->idxmsk64 &=
-				~(~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed));
+				~(~0ULL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed));
 			c->weight = hweight64(c->idxmsk64);
 		}
 	}
-- 
2.7.3

[toc] | [next] | [standalone]


#1399149

FromPeter Zijlstra <peterz@infradead.org>
Date2016-05-11 16:10 +0200
Message-ID<rxCZR-1jh-39@gated-at.bofh.it>
In reply to#1399144
On Wed, May 11, 2016 at 04:51:51PM +0300, Andrey Ryabinin wrote:
> Jim reported:
> 	UBSAN: Undefined behaviour in arch/x86/events/intel/core.c:3708:12
> 	shift exponent 35 is too large for 32-bit type 'long unsigned int'
> 
> The use of 'unsigned long' type obviously is not correct here, make it
> 'unsigned long long' instead.
> 
> Fixes: 2c33645d366d ("perf/x86: Honor the architectural performance monitoring version")
> Reported-by: Jim Cromie <jim.cromie@gmail.com>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

Thanks!

[toc] | [prev] | [next] | [standalone]


#1399902 — [tip:perf/core] perf/x86: Fix undefined shift on 32-bit kernels

Fromtip-bot for Andrey Ryabinin <tipbot@zytor.com>
Date2016-05-12 12:40 +0200
Subject[tip:perf/core] perf/x86: Fix undefined shift on 32-bit kernels
Message-ID<rxWcb-3K2-35@gated-at.bofh.it>
In reply to#1399144
Commit-ID:  6d6f2833bfbf296101f9f085e10488aef2601ba5
Gitweb:     http://git.kernel.org/tip/6d6f2833bfbf296101f9f085e10488aef2601ba5
Author:     Andrey Ryabinin <aryabinin@virtuozzo.com>
AuthorDate: Wed, 11 May 2016 16:51:51 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 12 May 2016 10:14:31 +0200

perf/x86: Fix undefined shift on 32-bit kernels

Jim reported:

	UBSAN: Undefined behaviour in arch/x86/events/intel/core.c:3708:12
	shift exponent 35 is too large for 32-bit type 'long unsigned int'

The use of 'unsigned long' type obviously is not correct here, make it
'unsigned long long' instead.

Reported-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Imre Palik <imrep@amazon.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Fixes: 2c33645d366d ("perf/x86: Honor the architectural performance monitoring version")
Link: http://lkml.kernel.org/r/1462974711-10037-1-git-send-email-aryabinin@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/intel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a6fd4db..5210eaa 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3708,7 +3708,7 @@ __init int intel_pmu_init(void)
 				c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
 			}
 			c->idxmsk64 &=
-				~(~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed));
+				~(~0ULL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed));
 			c->weight = hweight64(c->idxmsk64);
 		}
 	}

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web