[PATCH v3]: perf/x86: store user space frame-pointer value on a sample
From: Alexey Budankov
Date: Thu May 24 2018 - 09:19:29 EST
Store user space frame-pointer value (BP register) into Perf trace
on a sample for a process so the value becomes available when
unwinding call stacks for functions gaining event samples.
Signed-off-by: Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx>
---
Changes in v3:
- adjusted comment regarding saved registers on system call after
recent KPTI improvements
Changes in v2:
- lifted restriction on frame pointer architecture so it's value is provided
as for i386 as for x86_64 processes
MAINTAINERS file lacks references to appropriate folks for reviewing
changes at arch/x86/kernel/perf_regs.c so probably it makes sense to
update the file as well in this respect.
---
arch/x86/kernel/perf_regs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c
index e47b2dbbdef3..f54348a72add 100644
--- a/arch/x86/kernel/perf_regs.c
+++ b/arch/x86/kernel/perf_regs.c
@@ -151,17 +151,19 @@ void perf_get_regs_user(struct perf_regs *regs_user,
regs_user_copy->sp = user_regs->sp;
regs_user_copy->cs = user_regs->cs;
regs_user_copy->ss = user_regs->ss;
-
/*
- * Most system calls don't save these registers, don't report them.
+ * Store user space frame-pointer value on sample
+ * to facilitate stack unwinding for cases when
+ * user space executable code has such support
+ * enabled at compile time;
*/
+ regs_user_copy->bp = user_regs->bp;
+
regs_user_copy->bx = -1;
- regs_user_copy->bp = -1;
regs_user_copy->r12 = -1;
regs_user_copy->r13 = -1;
regs_user_copy->r14 = -1;
regs_user_copy->r15 = -1;
-
/*
* For this to be at all useful, we need a reasonable guess for
* the ABI. Be careful: we're in NMI context, and we're