Commit | Line | Data |
---|---|---|
61baff6e MJ |
1 | // SPDX-FileCopyrightText: 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
2 | // | |
3 | // SPDX-License-Identifier: GPL-2.0-only | |
4 | ||
da0f6c58 MD |
5 | #if !defined(LTTNG_TRACE_EXCEPTIONS_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_EXCEPTIONS_H | |
7 | ||
3b4aafcb | 8 | #include <lttng/tracepoint-event.h> |
5f4c791e | 9 | #include <lttng/kernel-version.h> |
da0f6c58 | 10 | |
2eb43df6 | 11 | #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM |
5f4c791e | 12 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) |
8c7f2a9f | 13 | #include <../arch/x86/include/asm/traps.h> |
5f4c791e | 14 | #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) */ |
8c7f2a9f FD |
15 | |
16 | /* Only define this enum once. */ | |
17 | ||
18 | #ifndef ONCE_LTTNG_EXCEPTIONS_H | |
19 | #define ONCE_LTTNG_EXCEPTIONS_H | |
20 | ||
21 | enum { | |
22 | X86_PF_PROT = 1 << 0, | |
23 | X86_PF_WRITE = 1 << 1, | |
24 | X86_PF_USER = 1 << 2, | |
25 | X86_PF_RSVD = 1 << 3, | |
26 | X86_PF_INSTR = 1 << 4, | |
5f4c791e | 27 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) |
8c7f2a9f | 28 | X86_PF_PK = 1 << 5, |
5f4c791e | 29 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) */ |
8c7f2a9f FD |
30 | }; |
31 | ||
32 | #endif /* ONCE_LTTNG_EXCEPTIONS_H */ | |
33 | ||
5f4c791e | 34 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) */ |
2eb43df6 | 35 | #endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */ |
8c7f2a9f | 36 | |
da0f6c58 MD |
37 | #undef TRACE_SYSTEM |
38 | #define TRACE_SYSTEM x86_exceptions | |
39 | ||
2eb43df6 | 40 | #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM |
8c7f2a9f FD |
41 | LTTNG_TRACEPOINT_ENUM(lttng_x86_pf_error_code, |
42 | TP_ENUM_VALUES( | |
43 | ctf_enum_value("PROTECTION_FAULT", X86_PF_PROT) | |
44 | ctf_enum_value("WRITE_ACCESS", X86_PF_WRITE) | |
45 | ctf_enum_value("USER_MODE", X86_PF_USER) | |
46 | ctf_enum_value("RESERVED_BIT", X86_PF_RSVD) | |
47 | ctf_enum_value("INSTRUCTION_FETCH", X86_PF_INSTR) | |
5f4c791e | 48 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) |
8c7f2a9f | 49 | ctf_enum_value("PROTECTION_KEYS_BLOCK", X86_PF_PK) |
5f4c791e | 50 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) */ |
8c7f2a9f FD |
51 | ) |
52 | ) | |
2eb43df6 | 53 | #endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */ |
8c7f2a9f | 54 | |
da0f6c58 MD |
55 | LTTNG_TRACEPOINT_EVENT_CLASS(x86_exceptions_class, |
56 | ||
57 | TP_PROTO(unsigned long address, struct pt_regs *regs, | |
58 | unsigned long error_code), | |
59 | ||
60 | TP_ARGS(address, regs, error_code), | |
61 | ||
62 | TP_FIELDS( | |
63 | ctf_integer_hex(unsigned long, address, address) | |
64 | ctf_integer_hex(unsigned long, ip, regs->ip) | |
65 | /* | |
66 | * Note: we cast error_code from unsigned long | |
67 | * to unsigned char to save space in the trace. | |
68 | * Currently, only 5 low bits are used. Should be made | |
69 | * larger if error codes are added to the kernel. | |
70 | */ | |
2eb43df6 | 71 | #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM |
8c7f2a9f | 72 | ctf_enum(lttng_x86_pf_error_code, unsigned char, error_code, error_code) |
2eb43df6 MJ |
73 | #else |
74 | ctf_integer_hex(unsigned char, error_code, error_code) | |
75 | #endif | |
da0f6c58 MD |
76 | ) |
77 | ) | |
78 | ||
79 | #define LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(name, map) \ | |
80 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(x86_exceptions_class, \ | |
81 | name, \ | |
82 | map, \ | |
83 | TP_PROTO(unsigned long address, struct pt_regs *regs, \ | |
84 | unsigned long error_code), \ | |
85 | TP_ARGS(address, regs, error_code) \ | |
86 | ) | |
87 | ||
88 | LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_user, | |
89 | x86_exceptions_page_fault_user) | |
90 | LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_kernel, | |
91 | x86_exceptions_page_fault_kernel) | |
92 | ||
93 | #endif /* LTTNG_TRACE_EXCEPTIONS_H */ | |
94 | ||
95 | #undef TRACE_INCLUDE_PATH | |
4f47ccf0 | 96 | #define TRACE_INCLUDE_PATH instrumentation/events/arch/x86 |
da0f6c58 MD |
97 | #undef TRACE_INCLUDE_FILE |
98 | #define TRACE_INCLUDE_FILE exceptions | |
99 | ||
100 | /* This part must be outside protection */ | |
3b4aafcb | 101 | #include <lttng/define_trace.h> |