linux/arch/powerpc/perf
Ravi Bangoria f41d84dddc powerpc/perf: Dereference BHRB entries safely
It's theoretically possible that branch instructions recorded in
BHRB (Branch History Rolling Buffer) entries have already been
unmapped before they are processed by the kernel. Hence, trying to
dereference such memory location will result in a crash. eg:

    Unable to handle kernel paging request for data at address 0xd000000019c41764
    Faulting instruction address: 0xc000000000084a14
    NIP [c000000000084a14] branch_target+0x4/0x70
    LR [c0000000000eb828] record_and_restart+0x568/0x5c0
    Call Trace:
    [c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable)
    [c0000000000ec378] perf_event_interrupt+0x298/0x460
    [c000000000027964] performance_monitor_exception+0x54/0x70
    [c000000000009ba4] performance_monitor_common+0x114/0x120

Fix it by deferefencing the addresses safely.

Fixes: 691231846c ("powerpc/perf: Fix setting of "to" addresses for BHRB")
Cc: stable@vger.kernel.org # v3.10+
Suggested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
[mpe: Use probe_kernel_read() which is clearer, tweak change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-12-13 20:29:20 +11:00
..
req-gen License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
8xx-pmu.c powerpc/8xx: Perf events on PPC 8xx 2017-01-26 17:49:34 -06:00
bhrb.S powerpc/perf: Add basic assembly code to read BHRB entries on POWER8 2013-04-26 16:11:11 +10:00
callchain.c powerpc/mm: Rename find_linux_pte_or_hugepte() 2017-08-17 23:13:46 +10:00
core-book3s.c powerpc/perf: Dereference BHRB entries safely 2017-12-13 20:29:20 +11:00
core-fsl-emb.c perf/powerpc: reset event hw state when adding it to the PMU 2015-01-29 23:44:18 -06:00
e500-pmu.c powerpc/perf: Add stalled-cycles events 2013-01-10 17:00:56 +11:00
e6500-pmu.c powerpc/perf: Add e6500 PMU driver 2013-08-07 18:38:04 -05:00
hv-24x7-catalog.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-24x7-domains.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-24x7.c powerpc/perf/hv-24x7: Fix incorrect comparison in memord 2017-10-22 12:08:31 +02:00
hv-24x7.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-common.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-common.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-gpci-requests.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-gpci.c powerpc/sparse: Make a bunch of things static 2016-09-13 17:35:47 +10:00
hv-gpci.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
imc-pmu.c powerpc/perf: Fix IMC_MAX_PMU macro 2017-11-22 23:04:23 +11:00
isa207-common.c powerpc/perf: Factor out PPMU_ONLY_COUNT_RUN check code from power8 2017-08-10 22:30:05 +10:00
isa207-common.h powerpc/perf: Factor out PPMU_ONLY_COUNT_RUN check code from power8 2017-08-10 22:30:05 +10:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mpc7450-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00
perf_regs.c powerpc/perf: Fix oops when kthread execs user process 2017-06-16 21:02:46 +10:00
power4-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00
power5+-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00
power5-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00
power6-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00
power7-events-list.h powerpc/perf: Make some new raw event codes available in sysfs 2014-03-24 09:48:23 +11:00
power7-pmu.c powerpc/sparse: Make a bunch of things static 2016-09-13 17:35:47 +10:00
power8-events-list.h powerpc/perf: Add Power8 mem_access event to sysfs 2017-04-19 20:00:23 +10:00
power8-pmu.c powerpc/perf: Factor out PPMU_ONLY_COUNT_RUN check code from power8 2017-08-10 22:30:05 +10:00
power9-events-list.h powerpc/perf: Cleanup of PM_BR_CMPL vs. PM_BRU_CMPL in Power9 event list 2017-08-10 22:30:06 +10:00
power9-pmu.c powerpc/perf: Cleanup of PM_BR_CMPL vs. PM_BRU_CMPL in Power9 event list 2017-08-10 22:30:06 +10:00
ppc970-pmu.c powerpc/perf: Pass the struct perf_events down to compute_mmcr() 2014-07-28 14:30:47 +10:00