-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM64: perf: add support for perf registers API
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Compat mode is also supported. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers. Signed-off-by: Jean Pihet <jean.pihet@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
- Loading branch information
Jean Pihet
authored and
Catalin Marinas
committed
Mar 13, 2014
1 parent
87366d8
commit 2ee0d7f
Showing
6 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _ASM_ARM64_PERF_REGS_H | ||
#define _ASM_ARM64_PERF_REGS_H | ||
|
||
enum perf_event_arm_regs { | ||
PERF_REG_ARM64_X0, | ||
PERF_REG_ARM64_X1, | ||
PERF_REG_ARM64_X2, | ||
PERF_REG_ARM64_X3, | ||
PERF_REG_ARM64_X4, | ||
PERF_REG_ARM64_X5, | ||
PERF_REG_ARM64_X6, | ||
PERF_REG_ARM64_X7, | ||
PERF_REG_ARM64_X8, | ||
PERF_REG_ARM64_X9, | ||
PERF_REG_ARM64_X10, | ||
PERF_REG_ARM64_X11, | ||
PERF_REG_ARM64_X12, | ||
PERF_REG_ARM64_X13, | ||
PERF_REG_ARM64_X14, | ||
PERF_REG_ARM64_X15, | ||
PERF_REG_ARM64_X16, | ||
PERF_REG_ARM64_X17, | ||
PERF_REG_ARM64_X18, | ||
PERF_REG_ARM64_X19, | ||
PERF_REG_ARM64_X20, | ||
PERF_REG_ARM64_X21, | ||
PERF_REG_ARM64_X22, | ||
PERF_REG_ARM64_X23, | ||
PERF_REG_ARM64_X24, | ||
PERF_REG_ARM64_X25, | ||
PERF_REG_ARM64_X26, | ||
PERF_REG_ARM64_X27, | ||
PERF_REG_ARM64_X28, | ||
PERF_REG_ARM64_X29, | ||
PERF_REG_ARM64_LR, | ||
PERF_REG_ARM64_SP, | ||
PERF_REG_ARM64_PC, | ||
PERF_REG_ARM64_MAX, | ||
}; | ||
#endif /* _ASM_ARM64_PERF_REGS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <linux/errno.h> | ||
#include <linux/kernel.h> | ||
#include <linux/perf_event.h> | ||
#include <linux/bug.h> | ||
#include <asm/perf_regs.h> | ||
#include <asm/ptrace.h> | ||
|
||
u64 perf_reg_value(struct pt_regs *regs, int idx) | ||
{ | ||
if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM64_MAX)) | ||
return 0; | ||
|
||
/* | ||
* Compat (i.e. 32 bit) mode: | ||
* - PC has been set in the pt_regs struct in kernel_entry, | ||
* - Handle SP and LR here. | ||
*/ | ||
if (compat_user_mode(regs)) { | ||
if ((u32)idx == PERF_REG_ARM64_SP) | ||
return regs->compat_sp; | ||
if ((u32)idx == PERF_REG_ARM64_LR) | ||
return regs->compat_lr; | ||
} | ||
|
||
return regs->regs[idx]; | ||
} | ||
|
||
#define REG_RESERVED (~((1ULL << PERF_REG_ARM64_MAX) - 1)) | ||
|
||
int perf_reg_validate(u64 mask) | ||
{ | ||
if (!mask || mask & REG_RESERVED) | ||
return -EINVAL; | ||
|
||
return 0; | ||
} | ||
|
||
u64 perf_reg_abi(struct task_struct *task) | ||
{ | ||
if (is_compat_thread(task_thread_info(task))) | ||
return PERF_SAMPLE_REGS_ABI_32; | ||
else | ||
return PERF_SAMPLE_REGS_ABI_64; | ||
} |