x86: add error code enum to pagefault tracepoints
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 5 Jun 2020 22:42:54 +0000 (18:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 5 Aug 2020 18:26:47 +0000 (14:26 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia939eccd1a918958f6a281595e447f33da2d64f7

include/instrumentation/events/arch/x86/exceptions.h

index b322f3e75be0dd17cec816dc74d045762a8a96ec..3c124638ec7c45847472ccc050b08c3f2d5eef00 100644 (file)
@@ -5,9 +5,46 @@
 #include <lttng/tracepoint-event.h>
 #include <linux/version.h>
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0))
+#include <../arch/x86/include/asm/traps.h>
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)) */
+
+/* Only define this enum once. */
+
+#ifndef ONCE_LTTNG_EXCEPTIONS_H
+#define ONCE_LTTNG_EXCEPTIONS_H
+
+enum {
+       X86_PF_PROT =   1 << 0,
+       X86_PF_WRITE =  1 << 1,
+       X86_PF_USER =   1 << 2,
+       X86_PF_RSVD =   1 << 3,
+       X86_PF_INSTR =  1 << 4,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+       X86_PF_PK =     1 << 5,
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) */
+};
+
+#endif /* ONCE_LTTNG_EXCEPTIONS_H */
+
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)) */
+
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM x86_exceptions
 
+LTTNG_TRACEPOINT_ENUM(lttng_x86_pf_error_code,
+       TP_ENUM_VALUES(
+               ctf_enum_value("PROTECTION_FAULT",      X86_PF_PROT)
+               ctf_enum_value("WRITE_ACCESS",          X86_PF_WRITE)
+               ctf_enum_value("USER_MODE",             X86_PF_USER)
+               ctf_enum_value("RESERVED_BIT",          X86_PF_RSVD)
+               ctf_enum_value("INSTRUCTION_FETCH",     X86_PF_INSTR)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+               ctf_enum_value("PROTECTION_KEYS_BLOCK", X86_PF_PK)
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) */
+       )
+)
+
 LTTNG_TRACEPOINT_EVENT_CLASS(x86_exceptions_class,
 
        TP_PROTO(unsigned long address, struct pt_regs *regs,
@@ -24,7 +61,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(x86_exceptions_class,
                 * Currently, only 5 low bits are used. Should be made
                 * larger if error codes are added to the kernel.
                 */
-               ctf_integer_hex(unsigned char, error_code, error_code)
+               ctf_enum(lttng_x86_pf_error_code, unsigned char, error_code, error_code)
        )
 )
 
This page took 0.043559 seconds and 4 git commands to generate.