aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Hansen <dave.hansen@linux.intel.com>2015-06-07 14:37:03 -0400
committerIngo Molnar <mingo@kernel.org>2015-06-09 06:24:31 -0400
commite7126cf5f10aef1555cb99eddb7efff41bdf9566 (patch)
treefc24752c5b4a2202483c8e594d5c37ec948b9538
parent8c3641e957a948f41f0174290096ed7a3b95e703 (diff)
x86/mpx: Trace #BR exceptions
This is the first in a series of MPX tracing patches. I've found these extremely useful in the process of debugging applications and the kernel code itself. This exception hooks in to the bounds (#BR) exception very early and allows capturing the key registers which would influence how the exception is handled. Note that bndcfgu/bndstatus are technically still 64-bit registers even in 32-bit mode. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Dave Hansen <dave@sr71.net> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150607183703.5FE2619A@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/trace/mpx.h50
-rw-r--r--arch/x86/kernel/traps.c2
-rw-r--r--arch/x86/mm/mpx.c3
3 files changed, 55 insertions, 0 deletions
diff --git a/arch/x86/include/asm/trace/mpx.h b/arch/x86/include/asm/trace/mpx.h
new file mode 100644
index 000000000000..5c03ec8a90d6
--- /dev/null
+++ b/arch/x86/include/asm/trace/mpx.h
@@ -0,0 +1,50 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM mpx
3
4#if !defined(_TRACE_MPX_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_MPX_H
6
7#include <linux/tracepoint.h>
8
9#ifdef CONFIG_X86_INTEL_MPX
10
11TRACE_EVENT(bounds_exception_mpx,
12
13 TP_PROTO(const struct bndcsr *bndcsr),
14 TP_ARGS(bndcsr),
15
16 TP_STRUCT__entry(
17 __field(u64, bndcfgu)
18 __field(u64, bndstatus)
19 ),
20
21 TP_fast_assign(
22 /* need to get rid of the 'const' on bndcsr */
23 __entry->bndcfgu = (u64)bndcsr->bndcfgu;
24 __entry->bndstatus = (u64)bndcsr->bndstatus;
25 ),
26
27 TP_printk("bndcfgu:0x%llx bndstatus:0x%llx",
28 __entry->bndcfgu,
29 __entry->bndstatus)
30);
31
32#else
33
34/*
35 * This gets used outside of MPX-specific code, so we need a stub.
36 */
37static inline void trace_bounds_exception_mpx(const struct bndcsr *bndcsr)
38{
39}
40
41#endif /* CONFIG_X86_INTEL_MPX */
42
43#undef TRACE_INCLUDE_PATH
44#define TRACE_INCLUDE_PATH asm/trace/
45#undef TRACE_INCLUDE_FILE
46#define TRACE_INCLUDE_FILE mpx
47#endif /* _TRACE_MPX_H */
48
49/* This part must be outside protection */
50#include <trace/define_trace.h>
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index cffff669be3f..36cb15b7b367 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -60,6 +60,7 @@
60#include <asm/mach_traps.h> 60#include <asm/mach_traps.h>
61#include <asm/alternative.h> 61#include <asm/alternative.h>
62#include <asm/fpu/xstate.h> 62#include <asm/fpu/xstate.h>
63#include <asm/trace/mpx.h>
63#include <asm/mpx.h> 64#include <asm/mpx.h>
64 65
65#ifdef CONFIG_X86_64 66#ifdef CONFIG_X86_64
@@ -399,6 +400,7 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
399 if (!bndcsr) 400 if (!bndcsr)
400 goto exit_trap; 401 goto exit_trap;
401 402
403 trace_bounds_exception_mpx(bndcsr);
402 /* 404 /*
403 * The error code field of the BNDSTATUS register communicates status 405 * The error code field of the BNDSTATUS register communicates status
404 * information of a bound range exception #BR or operation involving 406 * information of a bound range exception #BR or operation involving
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index d6e02f3adee0..1fef52c17fc8 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -17,6 +17,9 @@
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/fpu/internal.h> 18#include <asm/fpu/internal.h>
19 19
20#define CREATE_TRACE_POINTS
21#include <asm/trace/mpx.h>
22
20static const char *mpx_mapping_name(struct vm_area_struct *vma) 23static const char *mpx_mapping_name(struct vm_area_struct *vma)
21{ 24{
22 return "[mpx]"; 25 return "[mpx]";