x86: add error code enum to pagefault tracepoints
[lttng-modules.git] / include / instrumentation / events / arch / x86 / exceptions.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #if !defined(LTTNG_TRACE_EXCEPTIONS_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define LTTNG_TRACE_EXCEPTIONS_H
4
5 #include <lttng/tracepoint-event.h>
6 #include <linux/version.h>
7
8 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0))
9 #include <../arch/x86/include/asm/traps.h>
10 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)) */
11
12 /* Only define this enum once. */
13
14 #ifndef ONCE_LTTNG_EXCEPTIONS_H
15 #define ONCE_LTTNG_EXCEPTIONS_H
16
17 enum {
18 X86_PF_PROT = 1 << 0,
19 X86_PF_WRITE = 1 << 1,
20 X86_PF_USER = 1 << 2,
21 X86_PF_RSVD = 1 << 3,
22 X86_PF_INSTR = 1 << 4,
23 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
24 X86_PF_PK = 1 << 5,
25 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) */
26 };
27
28 #endif /* ONCE_LTTNG_EXCEPTIONS_H */
29
30 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)) */
31
32 #undef TRACE_SYSTEM
33 #define TRACE_SYSTEM x86_exceptions
34
35 LTTNG_TRACEPOINT_ENUM(lttng_x86_pf_error_code,
36 TP_ENUM_VALUES(
37 ctf_enum_value("PROTECTION_FAULT", X86_PF_PROT)
38 ctf_enum_value("WRITE_ACCESS", X86_PF_WRITE)
39 ctf_enum_value("USER_MODE", X86_PF_USER)
40 ctf_enum_value("RESERVED_BIT", X86_PF_RSVD)
41 ctf_enum_value("INSTRUCTION_FETCH", X86_PF_INSTR)
42 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
43 ctf_enum_value("PROTECTION_KEYS_BLOCK", X86_PF_PK)
44 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) */
45 )
46 )
47
48 LTTNG_TRACEPOINT_EVENT_CLASS(x86_exceptions_class,
49
50 TP_PROTO(unsigned long address, struct pt_regs *regs,
51 unsigned long error_code),
52
53 TP_ARGS(address, regs, error_code),
54
55 TP_FIELDS(
56 ctf_integer_hex(unsigned long, address, address)
57 ctf_integer_hex(unsigned long, ip, regs->ip)
58 /*
59 * Note: we cast error_code from unsigned long
60 * to unsigned char to save space in the trace.
61 * Currently, only 5 low bits are used. Should be made
62 * larger if error codes are added to the kernel.
63 */
64 ctf_enum(lttng_x86_pf_error_code, unsigned char, error_code, error_code)
65 )
66 )
67
68 #define LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(name, map) \
69 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(x86_exceptions_class, \
70 name, \
71 map, \
72 TP_PROTO(unsigned long address, struct pt_regs *regs, \
73 unsigned long error_code), \
74 TP_ARGS(address, regs, error_code) \
75 )
76
77 LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_user,
78 x86_exceptions_page_fault_user)
79 LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_kernel,
80 x86_exceptions_page_fault_kernel)
81
82 #endif /* LTTNG_TRACE_EXCEPTIONS_H */
83
84 #undef TRACE_INCLUDE_PATH
85 #define TRACE_INCLUDE_PATH instrumentation/events/arch/x86
86 #undef TRACE_INCLUDE_FILE
87 #define TRACE_INCLUDE_FILE exceptions
88
89 /* This part must be outside protection */
90 #include <lttng/define_trace.h>
This page took 0.030879 seconds and 4 git commands to generate.