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:32 -0400
commit97efebf1bc30a80122af3295ebdb726dbc040ca6 (patch)
tree128bf2669c2081a0fac18c17ceafb2ce23e46e1f
parente7126cf5f10aef1555cb99eddb7efff41bdf9566 (diff)
x86/mpx: Trace entry to bounds exception paths
There are two basic things that can happen as the result of a bounds exception (#BR): 1. We allocate a new bounds table 2. We pass up a bounds exception to userspace. This patch adds a trace point for the case where we are passing the exception up to userspace with a signal. We are also explicit that we're printing out the inverse of the 'upper' that we encounter. If you want to filter, for instance, you need to ~ the value first. The reason we do this is because of how 'upper' is stored in the bounds table. If a pointer's range is: 0x1000 -> 0x2000 it is stored in the bounds table as (32-bits here for brevity): lower: 0x00001000 upper: 0xffffdfff That is so that an all 0's entry: lower: 0x00000000 upper: 0x00000000 corresponds to the "init" bounds which store a *range* of: 0x00000000 -> 0xffffffff That is, by far, the common case, and that lets us use the zero page, or deduplicate the memory, etc... The 'upper' stored in the table is gibberish to print by itself, so we print ~upper to get the *actual*, logical, human-readable value printed out. 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.027BB9B0@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/trace/mpx.h34
-rw-r--r--arch/x86/mm/mpx.c1
2 files changed, 35 insertions, 0 deletions
diff --git a/arch/x86/include/asm/trace/mpx.h b/arch/x86/include/asm/trace/mpx.h
index 5c03ec8a90d6..5c3af06a2ae1 100644
--- a/arch/x86/include/asm/trace/mpx.h
+++ b/arch/x86/include/asm/trace/mpx.h
@@ -8,6 +8,40 @@
8 8
9#ifdef CONFIG_X86_INTEL_MPX 9#ifdef CONFIG_X86_INTEL_MPX
10 10
11TRACE_EVENT(mpx_bounds_register_exception,
12
13 TP_PROTO(void *addr_referenced,
14 const struct bndreg *bndreg),
15 TP_ARGS(addr_referenced, bndreg),
16
17 TP_STRUCT__entry(
18 __field(void *, addr_referenced)
19 __field(u64, lower_bound)
20 __field(u64, upper_bound)
21 ),
22
23 TP_fast_assign(
24 __entry->addr_referenced = addr_referenced;
25 __entry->lower_bound = bndreg->lower_bound;
26 __entry->upper_bound = bndreg->upper_bound;
27 ),
28 /*
29 * Note that we are printing out the '~' of the upper
30 * bounds register here. It is actually stored in its
31 * one's complement form so that its 'init' state
32 * corresponds to all 0's. But, that looks like
33 * gibberish when printed out, so print out the 1's
34 * complement instead of the actual value here. Note
35 * though that you still need to specify filters for the
36 * actual value, not the displayed one.
37 */
38 TP_printk("address referenced: 0x%p bounds: lower: 0x%llx ~upper: 0x%llx",
39 __entry->addr_referenced,
40 __entry->lower_bound,
41 ~__entry->upper_bound
42 )
43);
44
11TRACE_EVENT(bounds_exception_mpx, 45TRACE_EVENT(bounds_exception_mpx,
12 46
13 TP_PROTO(const struct bndcsr *bndcsr), 47 TP_PROTO(const struct bndcsr *bndcsr),
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index 1fef52c17fc8..75e5d7043f65 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -335,6 +335,7 @@ siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
335 err = -EINVAL; 335 err = -EINVAL;
336 goto err_out; 336 goto err_out;
337 } 337 }
338 trace_mpx_bounds_register_exception(info->si_addr, bndreg);
338 return info; 339 return info;
339err_out: 340err_out:
340 /* info might be NULL, but kfree() handles that */ 341 /* info might be NULL, but kfree() handles that */