diff options
author | Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> | 2017-09-19 11:47:06 +0530 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-09-20 13:30:09 +1000 |
commit | 4917fcb58cc73f6b81455e3c5f960144809ddf1a (patch) | |
tree | 66d961cdba4be77348c72ee8fc7d87cf594f7aad /arch/powerpc/perf | |
parent | 8632ec8cdcaead67c019f1ba36760d1bdd0c5d23 (diff) | |
download | linux-stable-4917fcb58cc73f6b81455e3c5f960144809ddf1a.tar.gz linux-stable-4917fcb58cc73f6b81455e3c5f960144809ddf1a.tar.bz2 linux-stable-4917fcb58cc73f6b81455e3c5f960144809ddf1a.zip |
powerpc/sysrq: Fix oops whem ppmu is not registered
Kernel crashes if power pmu is not registered and user tries to dump
regs with 'echo p > /proc/sysrq-trigger'. Sample log:
Unable to handle kernel paging request for data at address 0x00000008
Faulting instruction address: 0xc0000000000d52f0
NIP [c0000000000d52f0] perf_event_print_debug+0x10/0x230
LR [c00000000058a938] sysrq_handle_showregs+0x38/0x50
Call Trace:
printk+0x38/0x4c (unreliable)
__handle_sysrq+0xe4/0x270
write_sysrq_trigger+0x64/0x80
proc_reg_write+0x80/0xd0
__vfs_write+0x40/0x200
vfs_write+0xc8/0x240
SyS_write+0x60/0x110
system_call+0x58/0x6c
Fixes: 5f6d0380c640 ("powerpc/perf: Define perf_event_print_debug() to print PMU register values")
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/perf')
-rw-r--r-- | arch/powerpc/perf/core-book3s.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index 2e3eb7431571..9e3da168d54c 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -793,6 +793,11 @@ void perf_event_print_debug(void) u32 pmcs[MAX_HWEVENTS]; int i; + if (!ppmu) { + pr_info("Performance monitor hardware not registered.\n"); + return; + } + if (!ppmu->n_counter) return; |