* UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c
@ 2016-09-09 13:05 Meelis Roos
2016-09-10 9:51 ` Michael Ellerman
2016-09-10 16:12 ` Aneesh Kumar K.V
0 siblings, 2 replies; 4+ messages in thread
From: Meelis Roos @ 2016-09-09 13:05 UTC (permalink / raw)
To: Linux Kernel list, linuxppc-dev
Got this on my PowerPC G4 (533 MHz, PowerPC 7410, PowerMac3,4 platform),
with gcc version 5.3.1 20160509 (Debian 5.3.1-19):
[ 0.000000] ================================================================================
[ 0.000000] UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c:2240:25
[ 0.000000] shift exponent 32 is too large for 32-bit type 'long unsigned int'
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.8.0-rc5-00075-gd71f058 #106
[ 0.000000] Call Trace:
[ 0.000000] [c0a5ff10] [c03aa588] ubsan_epilogue+0x18/0x4c (unreliable)
[ 0.000000] [c0a5ff20] [c03aab38] __ubsan_handle_shift_out_of_bounds+0xe8/0x13c
[ 0.000000] [c0a5ffa0] [c07c42d0] cpu_feature_keys_init+0xa0/0xb8
[ 0.000000] [c0a5ffd0] [c07ca1fc] setup_feature_keys+0x14/0x24
[ 0.000000] [c0a5ffe0] [c07c6c74] machine_init+0x18/0x58
[ 0.000000] [c0a5fff0] [c000341c] start_here+0x38/0x78
[ 0.000000] ================================================================================
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c
2016-09-09 13:05 UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c Meelis Roos
@ 2016-09-10 9:51 ` Michael Ellerman
2016-09-11 9:12 ` Meelis Roos
2016-09-10 16:12 ` Aneesh Kumar K.V
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2016-09-10 9:51 UTC (permalink / raw)
To: Meelis Roos, Linux Kernel list, linuxppc-dev
Meelis Roos <mroos@linux.ee> writes:
> Got this on my PowerPC G4 (533 MHz, PowerPC 7410, PowerMac3,4 platform),
> with gcc version 5.3.1 20160509 (Debian 5.3.1-19):
>
> [ 0.000000] ================================================================================
> [ 0.000000] UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c:2240:25
> [ 0.000000] shift exponent 32 is too large for 32-bit type 'long unsigned int'
> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.8.0-rc5-00075-gd71f058 #106
> [ 0.000000] Call Trace:
> [ 0.000000] [c0a5ff10] [c03aa588] ubsan_epilogue+0x18/0x4c (unreliable)
> [ 0.000000] [c0a5ff20] [c03aab38] __ubsan_handle_shift_out_of_bounds+0xe8/0x13c
> [ 0.000000] [c0a5ffa0] [c07c42d0] cpu_feature_keys_init+0xa0/0xb8
> [ 0.000000] [c0a5ffd0] [c07ca1fc] setup_feature_keys+0x14/0x24
> [ 0.000000] [c0a5ffe0] [c07c6c74] machine_init+0x18/0x58
> [ 0.000000] [c0a5fff0] [c000341c] start_here+0x38/0x78
> [ 0.000000] ================================================================================
Oops, my bad.
#define NUM_CPU_FTR_KEYS 64
...
for (i = 0; i < NUM_CPU_FTR_KEYS; i++) {
unsigned long f = 1ul << i;
Does this fix it?
cheers
diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h
index 2ef55f8968a2..b312b152461b 100644
--- a/arch/powerpc/include/asm/cpu_has_feature.h
+++ b/arch/powerpc/include/asm/cpu_has_feature.h
@@ -15,7 +15,7 @@ static inline bool early_cpu_has_feature(unsigned long feature)
#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS
#include <linux/jump_label.h>
-#define NUM_CPU_FTR_KEYS 64
+#define NUM_CPU_FTR_KEYS BITS_PER_LONG
extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS];
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c
2016-09-09 13:05 UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c Meelis Roos
2016-09-10 9:51 ` Michael Ellerman
@ 2016-09-10 16:12 ` Aneesh Kumar K.V
1 sibling, 0 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-09-10 16:12 UTC (permalink / raw)
To: Meelis Roos, Linux Kernel list, linuxppc-dev
Meelis Roos <mroos@linux.ee> writes:
> Got this on my PowerPC G4 (533 MHz, PowerPC 7410, PowerMac3,4 platform),
> with gcc version 5.3.1 20160509 (Debian 5.3.1-19):
>
> [ 0.000000] ================================================================================
> [ 0.000000] UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c:2240:25
> [ 0.000000] shift exponent 32 is too large for 32-bit type 'long unsigned int'
> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.8.0-rc5-00075-gd71f058 #106
> [ 0.000000] Call Trace:
> [ 0.000000] [c0a5ff10] [c03aa588] ubsan_epilogue+0x18/0x4c (unreliable)
> [ 0.000000] [c0a5ff20] [c03aab38] __ubsan_handle_shift_out_of_bounds+0xe8/0x13c
> [ 0.000000] [c0a5ffa0] [c07c42d0] cpu_feature_keys_init+0xa0/0xb8
> [ 0.000000] [c0a5ffd0] [c07ca1fc] setup_feature_keys+0x14/0x24
> [ 0.000000] [c0a5ffe0] [c07c6c74] machine_init+0x18/0x58
> [ 0.000000] [c0a5fff0] [c000341c] start_here+0x38/0x78
> [ 0.000000] ================================================================================
>
>
Can you try
diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h
index 2ef55f8968a2..b312b152461b 100644
--- a/arch/powerpc/include/asm/cpu_has_feature.h
+++ b/arch/powerpc/include/asm/cpu_has_feature.h
@@ -15,7 +15,7 @@ static inline bool early_cpu_has_feature(unsigned long feature)
#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS
#include <linux/jump_label.h>
-#define NUM_CPU_FTR_KEYS 64
+#define NUM_CPU_FTR_KEYS BITS_PER_LONG
extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS];
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c
2016-09-10 9:51 ` Michael Ellerman
@ 2016-09-11 9:12 ` Meelis Roos
0 siblings, 0 replies; 4+ messages in thread
From: Meelis Roos @ 2016-09-11 9:12 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Linux Kernel list, Aneesh Kumar K.V, linuxppc-dev
> Does this fix it?
Yes, thank you!
> diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h
> index 2ef55f8968a2..b312b152461b 100644
> --- a/arch/powerpc/include/asm/cpu_has_feature.h
> +++ b/arch/powerpc/include/asm/cpu_has_feature.h
> @@ -15,7 +15,7 @@ static inline bool early_cpu_has_feature(unsigned long feature)
> #ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS
> #include <linux/jump_label.h>
>
> -#define NUM_CPU_FTR_KEYS 64
> +#define NUM_CPU_FTR_KEYS BITS_PER_LONG
>
> extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS];
>
>
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-11 7:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09 13:05 UBSAN: Undefined behaviour in arch/powerpc/kernel/cputable.c Meelis Roos
2016-09-10 9:51 ` Michael Ellerman
2016-09-11 9:12 ` Meelis Roos
2016-09-10 16:12 ` Aneesh Kumar K.V
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.