1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM mpx
4
5 #if !defined(_TRACE_MPX_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_MPX_H
7
8 #include <linux/tracepoint.h>
9
10 #ifdef CONFIG_X86_INTEL_MPX
11
12 TRACE_EVENT(mpx_bounds_register_exception,
13
14 TP_PROTO(void *addr_referenced,
15 const struct mpx_bndreg *bndreg),
16 TP_ARGS(addr_referenced, bndreg),
17
18 TP_STRUCT__entry(
19 __field(void *, addr_referenced)
20 __field(u64, lower_bound)
21 __field(u64, upper_bound)
22 ),
23
24 TP_fast_assign(
25 __entry->addr_referenced = addr_referenced;
26 __entry->lower_bound = bndreg->lower_bound;
27 __entry->upper_bound = bndreg->upper_bound;
28 ),
29 /*
30 * Note that we are printing out the '~' of the upper
31 * bounds register here. It is actually stored in its
32 * one's complement form so that its 'init' state
33 * corresponds to all 0's. But, that looks like
34 * gibberish when printed out, so print out the 1's
35 * complement instead of the actual value here. Note
36 * though that you still need to specify filters for the
37 * actual value, not the displayed one.
38 */
39 TP_printk("address referenced: 0x%p bounds: lower: 0x%llx ~upper: 0x%llx",
40 __entry->addr_referenced,
41 __entry->lower_bound,
42 ~__entry->upper_bound
43 )
44 );
45
46 TRACE_EVENT(bounds_exception_mpx,
47
48 TP_PROTO(const struct mpx_bndcsr *bndcsr),
49 TP_ARGS(bndcsr),
50
51 TP_STRUCT__entry(
52 __field(u64, bndcfgu)
53 __field(u64, bndstatus)
54 ),
55
56 TP_fast_assign(
57 /* need to get rid of the 'const' on bndcsr */
58 __entry->bndcfgu = (u64)bndcsr->bndcfgu;
59 __entry->bndstatus = (u64)bndcsr->bndstatus;
60 ),
61
62 TP_printk("bndcfgu:0x%llx bndstatus:0x%llx",
63 __entry->bndcfgu,
64 __entry->bndstatus)
65 );
66
67 DECLARE_EVENT_CLASS(mpx_range_trace,
68
69 TP_PROTO(unsigned long start,
70 unsigned long end),
71 TP_ARGS(start, end),
72
73 TP_STRUCT__entry(
74 __field(unsigned long, start)
75 __field(unsigned long, end)
76 ),
77
78 TP_fast_assign(
79 __entry->start = start;
80 __entry->end = end;
81 ),
82
83 TP_printk("[0x%p:0x%p]",
84 (void *)__entry->start,
85 (void *)__entry->end
86 )
87 );
88
89 DEFINE_EVENT(mpx_range_trace, mpx_unmap_zap,
90 TP_PROTO(unsigned long start, unsigned long end),
91 TP_ARGS(start, end)
92 );
93
94 DEFINE_EVENT(mpx_range_trace, mpx_unmap_search,
95 TP_PROTO(unsigned long start, unsigned long end),
96 TP_ARGS(start, end)
97 );
98
99 TRACE_EVENT(mpx_new_bounds_table,
100
101 TP_PROTO(unsigned long table_vaddr),
102 TP_ARGS(table_vaddr),
103
104 TP_STRUCT__entry(
105 __field(unsigned long, table_vaddr)
106 ),
107
108 TP_fast_assign(
109 __entry->table_vaddr = table_vaddr;
110 ),
111
112 TP_printk("table vaddr:%p", (void *)__entry->table_vaddr)
113 );
114
115 #else
116
117 /*
118 * This gets used outside of MPX-specific code, so we need a stub.
119 */
120 static inline
trace_bounds_exception_mpx(const struct mpx_bndcsr * bndcsr)121 void trace_bounds_exception_mpx(const struct mpx_bndcsr *bndcsr)
122 {
123 }
124
125 #endif /* CONFIG_X86_INTEL_MPX */
126
127 #undef TRACE_INCLUDE_PATH
128 #define TRACE_INCLUDE_PATH asm/trace/
129 #undef TRACE_INCLUDE_FILE
130 #define TRACE_INCLUDE_FILE mpx
131 #endif /* _TRACE_MPX_H */
132
133 /* This part must be outside protection */
134 #include <trace/define_trace.h>
135