android_kernel_samsung_a7y1.../arch/arc/kernel
Alexey Brodkin 97f9b262b0 ARC: perf: Accommodate big-endian CPU
commit 5effc09c4907901f0e71e68e5f2e14211d9a203f upstream.

8-letter strings representing ARC perf events are stores in two
32-bit registers as ASCII characters like that: "IJMP", "IALL", "IJMPTAK" etc.

And the same order of bytes in the word is used regardless CPU endianness.

Which means in case of big-endian CPU core we need to swap bytes to get
the same order as if it was on little-endian CPU.

Otherwise we're seeing the following error message on boot:
------------------------->8----------------------
ARC perf        : 8 counters (32 bits), 40 conditions, [overflow IRQ support]
sysfs: cannot create duplicate filename '/devices/arc_pct/events/pmji'
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.18 #3
Stack Trace:
  arc_unwind_core+0xd4/0xfc
  dump_stack+0x64/0x80
  sysfs_warn_dup+0x46/0x58
  sysfs_add_file_mode_ns+0xb2/0x168
  create_files+0x70/0x2a0
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at kernel/events/core.c:12144 perf_event_sysfs_init+0x70/0xa0
Failed to register pmu: arc_pct, reason -17
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.18 #3
Stack Trace:
  arc_unwind_core+0xd4/0xfc
  dump_stack+0x64/0x80
  __warn+0x9c/0xd4
  warn_slowpath_fmt+0x22/0x2c
  perf_event_sysfs_init+0x70/0xa0
---[ end trace a75fb9a9837bd1ec ]---
------------------------->8----------------------

What happens here we're trying to register more than one raw perf event
with the same name "PMJI". Why? Because ARC perf events are 4 to 8 letters
and encoded into two 32-bit words. In this particular case we deal with 2
events:
 * "IJMP____" which counts all jump & branch instructions
 * "IJMPC___" which counts only conditional jumps & branches

Those strings are split in two 32-bit words this way "IJMP" + "____" &
"IJMP" + "C___" correspondingly. Now if we read them swapped due to CPU core
being big-endian then we read "PMJI" + "____" & "PMJI" + "___C".

And since we interpret read array of ASCII letters as a null-terminated string
on big-endian CPU we end up with 2 events of the same name "PMJI".

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: stable@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 12:37:04 +02:00
..
arc_hostlink.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
arcksyms.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
asm-offsets.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
clk.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ctx_sw_asm.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ctx_sw.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
devtree.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
disasm.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
entry-arcv2.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
entry-compact.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
entry.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fpu.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
head.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
intc-arcv2.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
intc-compact.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
irq.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kgdb.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kprobes.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mcip.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
module.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
perf_event.c ARC: perf: Accommodate big-endian CPU 2020-04-07 12:37:04 +02:00
process.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ptrace.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
reset.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
setup.c ARC: Assume multiplier is always present 2020-04-06 19:17:53 +02:00
signal.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
smp.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stacktrace.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sys.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
time.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
traps.c ARC: export "abort" for modules 2020-04-06 21:37:11 +02:00
troubleshoot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
unaligned.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
unwind.c ARC: hide unused function unw_hdr_alloc 2020-04-06 19:31:15 +02:00
vmlinux.lds.S A750FXXU4CTBC 2020-03-27 21:51:54 +05:30