linux/drivers/hwtracing/coresight
Wang Nan f094446390 coresight: fix kernel panic caused by invalid CPU
Commit d52c9750f1 ("coresight: reset "enable_sink" flag when need be")
caused a kernel panic because of the using of an invalid value: after
'for_each_cpu(cpu, mask)', value of local variable 'cpu' become invalid,
causes following 'cpu_to_node' access invalid memory area.

This patch brings the deleted 'cpu = cpumask_first(mask)' back.

Panic log:

 $ perf record -e cs_etm// ls

 Unable to handle kernel paging request at virtual address fffe801804af4f10
 pgd = ffff8017ce031600
 [fffe801804af4f10] *pgd=0000000000000000, *pud=0000000000000000
 Internal error: Oops: 96000004 [#1] SMP
 Modules linked in:
 CPU: 33 PID: 1619 Comm: perf Not tainted 4.7.1+ #16
 Hardware name: Huawei Taishan 2280 /CH05TEVBA, BIOS 1.10 11/24/2016
 task: ffff8017cb0c8400 ti: ffff8017cb154000 task.ti: ffff8017cb154000
 PC is at tmc_alloc_etf_buffer+0x60/0xd4
 LR is at tmc_alloc_etf_buffer+0x44/0xd4
 pc : [<ffff000008633df8>] lr : [<ffff000008633ddc>] pstate: 60000145
 sp : ffff8017cb157b40
 x29: ffff8017cb157b40 x28: 0000000000000000
 ...skip...
 7a60: ffff000008c64dc8 0000000000000006 0000000000000253 ffffffffffffffff
 7a80: 0000000000000000 0000000000000000 ffff0000080872cc 0000000000000001
 [<ffff000008633df8>] tmc_alloc_etf_buffer+0x60/0xd4
 [<ffff000008632b9c>] etm_setup_aux+0x1dc/0x1e8
 [<ffff00000816eed4>] rb_alloc_aux+0x2b0/0x338
 [<ffff00000816a5e4>] perf_mmap+0x414/0x568
 [<ffff0000081ab694>] mmap_region+0x324/0x544
 [<ffff0000081abbe8>] do_mmap+0x334/0x3e0
 [<ffff000008191150>] vm_mmap_pgoff+0xa4/0xc8
 [<ffff0000081a9a30>] SyS_mmap_pgoff+0xb0/0x22c
 [<ffff0000080872e4>] sys_mmap+0x18/0x28
 [<ffff0000080843f0>] el0_svc_naked+0x24/0x28
 Code: 912040a5 d0001c00 f873d821 911c6000 (b8656822)
 ---[ end trace 98933da8f92b0c9a ]---

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Xia Kaixu <xiakaixu@huawei.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Fixes: d52c9750f1 ("coresight: reset "enable_sink" flag when need be")
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: stable <stable@vger.kernel.org> # 4.10
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-25 11:46:42 +01:00
..
coresight-etb10.c coresight: fix handling of ETM trace register access via sysfs 2016-08-31 13:05:43 +02:00
coresight-etm3x-sysfs.c coresight: etm3x: Adding missing features of Coresight PTM components 2016-11-29 20:05:32 +01:00
coresight-etm3x.c cpu/hotplug: Cleanup state names 2016-12-25 10:47:44 +01:00
coresight-etm4x-sysfs.c coresight: remove duplicated enumeration 2016-08-31 13:05:43 +02:00
coresight-etm4x.c coresight/etm3/4x: Consolidate hotplug state space 2016-12-25 10:47:44 +01:00
coresight-etm4x.h coresight: remove duplicated enumeration 2016-08-31 13:05:43 +02:00
coresight-etm-cp14.c
coresight-etm-perf.c coresight: fix kernel panic caused by invalid CPU 2017-01-25 11:46:42 +01:00
coresight-etm-perf.h coresight: etm-perf: configuring filters from perf core 2016-08-31 13:05:43 +02:00
coresight-etm.h coresight: etm3x: Adding missing features of Coresight PTM components 2016-11-29 20:05:32 +01:00
coresight-funnel.c coresight: Use local coresight_desc instances 2016-08-31 13:05:43 +02:00
coresight-priv.h coresight: reset "enable_sink" flag when need be 2016-11-29 20:05:32 +01:00
coresight-replicator-qcom.c coresight: Use local coresight_desc instances 2016-08-31 13:05:43 +02:00
coresight-replicator.c coresight: Use local coresight_desc instances 2016-08-31 13:05:43 +02:00
coresight-stm.c coresight: STM: Balance enable/disable 2017-01-19 12:42:25 +01:00
coresight-tmc-etf.c coresight: tmc: Get rid of mode parameter for helper routines 2016-11-29 20:05:32 +01:00
coresight-tmc-etr.c coresight: tmc: Remove duplicate memset 2016-11-29 20:05:32 +01:00
coresight-tmc.c coresight: tmc: mark symbols static where possible 2016-09-09 13:53:00 +02:00
coresight-tmc.h coresight: tmc: Cleanup operation mode handling 2016-11-29 20:05:32 +01:00
coresight-tpiu.c coresight: Use local coresight_desc instances 2016-08-31 13:05:43 +02:00
coresight.c coresight: reset "enable_sink" flag when need be 2016-11-29 20:05:32 +01:00
Kconfig coresight: stm: adding driver for CoreSight STM component 2016-05-03 14:59:30 -07:00
Makefile coresight: tmc: splitting driver in ETB/ETF and ETR components 2016-05-03 14:59:30 -07:00
of_coresight.c hwtracing: coresight: of_coresight: add missing of_node_put after calling of_parse_phandle 2016-08-31 13:05:43 +02:00