Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-19 Thread Meelis Roos
> I think UBSAN has correctly identified a bug.  I looked at the code in
> v4.6.  In file arch/x86/events/core.c, in the function
> filter_events(), there is a loop starting at line 1554 that should go
> over 10 event counters.  But in file arch/x86/events/intel/p6.c, only
> 8 event counters have been declared at line 9.
> 
> I have a fix but do not for sure if its reasonable.  I think we should
> pass on the max_events for the pmu to filter_events() function and
> change the loop condition accordingly.  Can you apply the patch below
> and test again?  It compiles, but I have not tested it.

Seems to work - warning is gone, everythins is detected as before.

-- 
Meelis Roos (mr...@linux.ee)


Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-19 Thread Meelis Roos
> I think UBSAN has correctly identified a bug.  I looked at the code in
> v4.6.  In file arch/x86/events/core.c, in the function
> filter_events(), there is a loop starting at line 1554 that should go
> over 10 event counters.  But in file arch/x86/events/intel/p6.c, only
> 8 event counters have been declared at line 9.
> 
> I have a fix but do not for sure if its reasonable.  I think we should
> pass on the max_events for the pmu to filter_events() function and
> change the loop condition accordingly.  Can you apply the patch below
> and test again?  It compiles, but I have not tested it.

Seems to work - warning is gone, everythins is detected as before.

-- 
Meelis Roos (mr...@linux.ee)


Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-18 Thread Nilay Vaish
On 16 May 2016 at 13:41, Meelis Roos <mr...@linux.ee> wrote:
> Not sure if this is a genuine warning or a false positive but since some
> UBSAN warnings have been real and google does not find report about this
> specific warning, I'll send it in anyway.
>
> I have seen similar amd pmu warnings from UBSAN but I do not have any
> amd machines from that time frame online for now, so p6 only.
>
> [0.15] Performance Events: p6 PMU driver.
> [0.15] 
> ========
> [    0.150000] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29
> [0.15] index 8 is out of range for type 'u64 [8]'
> [0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
> [0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933
>   , BIOS A09 12/10/2004
> [0.15]   c13a4bcc 0046 f605de88 0008 c13d5188 
> c17ddfd4 c13d5725
> [0.15]  c176ae8c f605de8c c17ddfec 0202 0038 00752101 
> 0002 
> [0.15]   0297 00c2 c17d2b60  c102b14f 
> 0008 
> [0.15] Call Trace:
> [0.15]  [] ? dump_stack+0x45/0x69
> [0.15]  [] ? ubsan_epilogue+0x8/0x30
> [0.15]  [] ? __ubsan_handle_out_of_bounds+0x55/0x60
> [0.15]  [] ? __register_nmi_handler+0xbf/0x300
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? p6_pmu_event_map+0x3d/0x50
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? init_hw_perf_events+0x493/0x688
> [0.15]  [] ? merge_attr+0x1d5/0x1d5
> [0.15]  [] ? do_one_initcall+0x82/0x230
> [0.15]  [] ? vprintk_default+0xf/0x20
> [0.15]  [] ? printk+0x11/0x12
> [0.15]  [] ? print_cpu_info+0x86/0x130
> [0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
> [0.15]  [] ? kernel_init_freeable+0x117/0x2fd
> [0.15]  [] ? kernel_init+0x6/0x100
> [0.15]  [] ? ret_from_kernel_thread+0x21/0x38
> [0.15]  [] ? rest_init+0x60/0x60
> [0.15] 
> 
> [0.15] 
> 
> [0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:9
> [0.15] load of address c16adf20 with insufficient space
> [0.15] for an object of type 'const u64'
> [0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
> [0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933
>   , BIOS A09 12/10/2004
> [0.15]   c13a4bcc 0046 f605deb4 c16adf20 c13d5188 
> c17ddfac c13d5229
> [0.15]  c176a901 c17ddfc8 c176aca4 c176a95e c16adf20 0202 
> 0008 
> [0.15]  c101841d 0008 c10183d0 0008 c1af0c78 c17d2c00 
> f605df08 0001
> [0.15] Call Trace:
> [0.15]  [] ? dump_stack+0x45/0x69
> [0.15]  [] ? ubsan_epilogue+0x8/0x30
> [0.15]  [] ? __ubsan_handle_type_mismatch+0x79/0x150
> [0.15]  [] ? p6_pmu_event_map+0x4d/0x50
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? init_hw_perf_events+0x493/0x688
> [0.15]  [] ? merge_attr+0x1d5/0x1d5
> [0.15]  [] ? do_one_initcall+0x82/0x230
> [0.15]  [] ? vprintk_default+0xf/0x20
> [0.15]  [] ? printk+0x11/0x12
> [0.15]  [] ? print_cpu_info+0x86/0x130
> [0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
> [0.15]  [] ? kernel_init_freeable+0x117/0x2fd
> [0.15]  [] ? kernel_init+0x6/0x100
> [0.15]  [] ? ret_from_kernel_thread+0x21/0x38
> [0.15]  [] ? rest_init+0x60/0x60
> [0.15] 
> 
> [0.15] ... version:0
> [0.15] ... bit width:  32
> [0.15] ... generic registers:  2
> [0.15] ... value mask: 
> [0.15] ... max period: 7fff
> [0.15] ... fixed-purpose events:   0
> [0.15] ... event mask: 0003
>


I think UBSAN has correctly identified a bug.  I looked at the code in
v4.6.  In file arch/x86/events/core.c, in the function
filter_events(), there is a loop starting at line 1554 that should go
over 10 event counters.  But in file arch/x86/events/intel/p6.c, only
8 event counters have been declared at line 9.

I have a fix but do not for sure if its reasonable.  I think we should
pass on the max_events for the pmu to filter_events() function and
change 

Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-18 Thread Nilay Vaish
On 16 May 2016 at 13:41, Meelis Roos  wrote:
> Not sure if this is a genuine warning or a false positive but since some
> UBSAN warnings have been real and google does not find report about this
> specific warning, I'll send it in anyway.
>
> I have seen similar amd pmu warnings from UBSAN but I do not have any
> amd machines from that time frame online for now, so p6 only.
>
> [0.15] Performance Events: p6 PMU driver.
> [0.15] 
> ====
> [0.150000] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29
> [0.15] index 8 is out of range for type 'u64 [8]'
> [0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
> [0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933
>   , BIOS A09 12/10/2004
> [0.15]   c13a4bcc 0046 f605de88 0008 c13d5188 
> c17ddfd4 c13d5725
> [0.15]  c176ae8c f605de8c c17ddfec 0202 0038 00752101 
> 0002 
> [0.15]   0297 00c2 c17d2b60  c102b14f 
> 0008 
> [0.15] Call Trace:
> [0.15]  [] ? dump_stack+0x45/0x69
> [0.15]  [] ? ubsan_epilogue+0x8/0x30
> [0.15]  [] ? __ubsan_handle_out_of_bounds+0x55/0x60
> [0.15]  [] ? __register_nmi_handler+0xbf/0x300
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? p6_pmu_event_map+0x3d/0x50
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? init_hw_perf_events+0x493/0x688
> [0.15]  [] ? merge_attr+0x1d5/0x1d5
> [0.15]  [] ? do_one_initcall+0x82/0x230
> [0.15]  [] ? vprintk_default+0xf/0x20
> [0.15]  [] ? printk+0x11/0x12
> [0.15]  [] ? print_cpu_info+0x86/0x130
> [0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
> [0.15]  [] ? kernel_init_freeable+0x117/0x2fd
> [0.15]  [] ? kernel_init+0x6/0x100
> [0.15]  [] ? ret_from_kernel_thread+0x21/0x38
> [0.15]  [] ? rest_init+0x60/0x60
> [0.15] 
> 
> [0.15] 
> 
> [0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:9
> [0.15] load of address c16adf20 with insufficient space
> [0.15] for an object of type 'const u64'
> [0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
> [0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933
>   , BIOS A09 12/10/2004
> [0.15]   c13a4bcc 0046 f605deb4 c16adf20 c13d5188 
> c17ddfac c13d5229
> [0.15]  c176a901 c17ddfc8 c176aca4 c176a95e c16adf20 0202 
> 0008 
> [0.15]  c101841d 0008 c10183d0 0008 c1af0c78 c17d2c00 
> f605df08 0001
> [0.15] Call Trace:
> [0.15]  [] ? dump_stack+0x45/0x69
> [0.15]  [] ? ubsan_epilogue+0x8/0x30
> [0.15]  [] ? __ubsan_handle_type_mismatch+0x79/0x150
> [0.15]  [] ? p6_pmu_event_map+0x4d/0x50
> [0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
> [0.15]  [] ? init_hw_perf_events+0x493/0x688
> [0.15]  [] ? merge_attr+0x1d5/0x1d5
> [0.15]  [] ? do_one_initcall+0x82/0x230
> [0.15]  [] ? vprintk_default+0xf/0x20
> [0.15]  [] ? printk+0x11/0x12
> [0.15]  [] ? print_cpu_info+0x86/0x130
> [0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
> [0.15]  [] ? kernel_init_freeable+0x117/0x2fd
> [0.15]  [] ? kernel_init+0x6/0x100
> [0.15]  [] ? ret_from_kernel_thread+0x21/0x38
> [0.15]  [] ? rest_init+0x60/0x60
> [0.15] 
> 
> [0.15] ... version:0
> [0.15] ... bit width:  32
> [0.15] ... generic registers:  2
> [0.15] ... value mask: 
> [0.15] ... max period: 7fff
> [0.15] ... fixed-purpose events:   0
> [0.15] ... event mask: 0003
>


I think UBSAN has correctly identified a bug.  I looked at the code in
v4.6.  In file arch/x86/events/core.c, in the function
filter_events(), there is a loop starting at line 1554 that should go
over 10 event counters.  But in file arch/x86/events/intel/p6.c, only
8 event counters have been declared at line 9.

I have a fix but do not for sure if its reasonable.  I think we should
pass on the max_events for the pmu to filter_events() function and
change the loop condition a

UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-16 Thread Meelis Roos
Not sure if this is a genuine warning or a false positive but since some 
UBSAN warnings have been real and google does not find report about this 
specific warning, I'll send it in anyway.

I have seen similar amd pmu warnings from UBSAN but I do not have any 
amd machines from that time frame online for now, so p6 only.

[0.15] Performance Events: p6 PMU driver.
[0.15] 

[0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29
[0.15] index 8 is out of range for type 'u64 [8]'
[0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
[0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933  
, BIOS A09 12/10/2004
[0.15]   c13a4bcc 0046 f605de88 0008 c13d5188 c17ddfd4 
c13d5725
[0.15]  c176ae8c f605de8c c17ddfec 0202 0038 00752101 0002 

[0.15]   0297 00c2 c17d2b60  c102b14f 0008 

[0.15] Call Trace:
[0.15]  [] ? dump_stack+0x45/0x69
[0.15]  [] ? ubsan_epilogue+0x8/0x30
[0.15]  [] ? __ubsan_handle_out_of_bounds+0x55/0x60
[0.15]  [] ? __register_nmi_handler+0xbf/0x300
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? p6_pmu_event_map+0x3d/0x50
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? init_hw_perf_events+0x493/0x688
[0.15]  [] ? merge_attr+0x1d5/0x1d5
[0.15]  [] ? do_one_initcall+0x82/0x230
[0.15]  [] ? vprintk_default+0xf/0x20
[0.15]  [] ? printk+0x11/0x12
[0.15]  [] ? print_cpu_info+0x86/0x130
[0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
[0.15]  [] ? kernel_init_freeable+0x117/0x2fd
[0.15]  [] ? kernel_init+0x6/0x100
[0.15]  [] ? ret_from_kernel_thread+0x21/0x38
[0.15]  [] ? rest_init+0x60/0x60
[0.15] 

[0.15] 

[0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:9
[0.15] load of address c16adf20 with insufficient space
[0.15] for an object of type 'const u64'
[0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
[0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933  
, BIOS A09 12/10/2004
[0.15]   c13a4bcc 0046 f605deb4 c16adf20 c13d5188 c17ddfac 
c13d5229
[0.15]  c176a901 c17ddfc8 c176aca4 c176a95e c16adf20 0202 0008 

[0.15]  c101841d 0008 c10183d0 0008 c1af0c78 c17d2c00 f605df08 
0001
[0.15] Call Trace:
[0.15]  [] ? dump_stack+0x45/0x69
[0.15]  [] ? ubsan_epilogue+0x8/0x30
[0.15]  [] ? __ubsan_handle_type_mismatch+0x79/0x150
[0.15]  [] ? p6_pmu_event_map+0x4d/0x50
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? init_hw_perf_events+0x493/0x688
[0.15]  [] ? merge_attr+0x1d5/0x1d5
[0.15]  [] ? do_one_initcall+0x82/0x230
[0.15]  [] ? vprintk_default+0xf/0x20
[0.15]  [] ? printk+0x11/0x12
[0.15]  [] ? print_cpu_info+0x86/0x130
[0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
[0.15]  [] ? kernel_init_freeable+0x117/0x2fd
[0.15]  [] ? kernel_init+0x6/0x100
[0.15]  [] ? ret_from_kernel_thread+0x21/0x38
[0.15]  [] ? rest_init+0x60/0x60
[0.15] 

[0.15] ... version:0
[0.15] ... bit width:  32
[0.15] ... generic registers:  2
[0.15] ... value mask: 
[0.15] ... max period: 7fff
[0.15] ... fixed-purpose events:   0
[0.15] ... event mask: 0003



-- 
Meelis Roos (mr...@linux.ee)


UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

2016-05-16 Thread Meelis Roos
Not sure if this is a genuine warning or a false positive but since some 
UBSAN warnings have been real and google does not find report about this 
specific warning, I'll send it in anyway.

I have seen similar amd pmu warnings from UBSAN but I do not have any 
amd machines from that time frame online for now, so p6 only.

[0.15] Performance Events: p6 PMU driver.
[0.15] 

[0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29
[0.15] index 8 is out of range for type 'u64 [8]'
[0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
[0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933  
, BIOS A09 12/10/2004
[0.15]   c13a4bcc 0046 f605de88 0008 c13d5188 c17ddfd4 
c13d5725
[0.15]  c176ae8c f605de8c c17ddfec 0202 0038 00752101 0002 

[0.15]   0297 00c2 c17d2b60  c102b14f 0008 

[0.15] Call Trace:
[0.15]  [] ? dump_stack+0x45/0x69
[0.15]  [] ? ubsan_epilogue+0x8/0x30
[0.15]  [] ? __ubsan_handle_out_of_bounds+0x55/0x60
[0.15]  [] ? __register_nmi_handler+0xbf/0x300
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? p6_pmu_event_map+0x3d/0x50
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? init_hw_perf_events+0x493/0x688
[0.15]  [] ? merge_attr+0x1d5/0x1d5
[0.15]  [] ? do_one_initcall+0x82/0x230
[0.15]  [] ? vprintk_default+0xf/0x20
[0.15]  [] ? printk+0x11/0x12
[0.15]  [] ? print_cpu_info+0x86/0x130
[0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
[0.15]  [] ? kernel_init_freeable+0x117/0x2fd
[0.15]  [] ? kernel_init+0x6/0x100
[0.15]  [] ? ret_from_kernel_thread+0x21/0x38
[0.15]  [] ? rest_init+0x60/0x60
[0.15] 

[0.15] 

[0.15] UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:9
[0.15] load of address c16adf20 with insufficient space
[0.15] for an object of type 'const u64'
[0.15] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0 #21
[0.15] Hardware name: Dell Computer Corporation PowerEdge 1550/933  
, BIOS A09 12/10/2004
[0.15]   c13a4bcc 0046 f605deb4 c16adf20 c13d5188 c17ddfac 
c13d5229
[0.15]  c176a901 c17ddfc8 c176aca4 c176a95e c16adf20 0202 0008 

[0.15]  c101841d 0008 c10183d0 0008 c1af0c78 c17d2c00 f605df08 
0001
[0.15] Call Trace:
[0.15]  [] ? dump_stack+0x45/0x69
[0.15]  [] ? ubsan_epilogue+0x8/0x30
[0.15]  [] ? __ubsan_handle_type_mismatch+0x79/0x150
[0.15]  [] ? p6_pmu_event_map+0x4d/0x50
[0.15]  [] ? p4_pmu_schedule_events+0x740/0x740
[0.15]  [] ? init_hw_perf_events+0x493/0x688
[0.15]  [] ? merge_attr+0x1d5/0x1d5
[0.15]  [] ? do_one_initcall+0x82/0x230
[0.15]  [] ? vprintk_default+0xf/0x20
[0.15]  [] ? printk+0x11/0x12
[0.15]  [] ? print_cpu_info+0x86/0x130
[0.15]  [] ? native_smp_prepare_cpus+0x40e/0x453
[0.15]  [] ? kernel_init_freeable+0x117/0x2fd
[0.15]  [] ? kernel_init+0x6/0x100
[0.15]  [] ? ret_from_kernel_thread+0x21/0x38
[0.15]  [] ? rest_init+0x60/0x60
[0.15] 

[0.15] ... version:0
[0.15] ... bit width:  32
[0.15] ... generic registers:  2
[0.15] ... value mask: 
[0.15] ... max period: 7fff
[0.15] ... fixed-purpose events:   0
[0.15] ... event mask: 0003



-- 
Meelis Roos (mr...@linux.ee)