]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: FBT entry probes will now use int3
authorKris Van Hees <kris.van.hees@oracle.com>
Tue, 13 Jun 2017 16:33:04 +0000 (12:33 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Wed, 28 Jun 2017 16:01:04 +0000 (12:01 -0400)
Due to some function prologues inserting an instruction between the
push rbp and mov rsp,rbp instruction *and* that instruction being one
that can validly take a LOCK profix (e.g. inc), it is not safe to
continue using the LOCK prefix as a way to trigger an Invalid Opcode
trap for FBT entry probes.  The new trigger uses int3 (like the return
probes already do).

Orabug: 26190412
Orabug: 26174895
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
dtrace/fbt_x86_64.c

index 7b5611959fa583006a7b2c775fcc16cdefe7da1a..dd3b1527654b473a9b08230970f9d5056ab16b5e 100644 (file)
 #include "dtrace_dev.h"
 #include "fbt_impl.h"
 
-#define FBT_ENTRY_PATCHVAL             0xf0
+/*
+ * Use 0xf0 (LOCK Prefix) and X86_TRAP_UD for Invalid Opcode traps to be used.
+ * Use 0xcc (INT 3) and X86_TRAP_BP for Breakpoint traps to be used.
+ */
+#define FBT_ENTRY_PATCHVAL             0xcc
+#define FBT_ENTRY_TRAP                 X86_TRAP_BP
 #define FBT_RETURN_PATCHVAL            0xcc
+#define FBT_RETURN_TRAP                        X86_TRAP_BP
 
 static uint8_t fbt_invop(struct pt_regs *regs)
 {
@@ -51,18 +57,18 @@ static uint8_t fbt_invop(struct pt_regs *regs)
                         * the TLS thread key calculation.
                         *
                         * This is not pretty, but neither is the fact that
-                        * int3 cause handlers to think they are called from
+                        * int3 causes handlers to think they are called from
                         * within an interrupt.
                         */
                        this_cpu_core->cpu_dtrace_regs = regs;
                        orig_ax = regs->orig_ax;
 
                        if (fbp->fbp_roffset == 0) {
-                               regs->orig_ax = X86_TRAP_UD;
+                               regs->orig_ax = FBT_ENTRY_TRAP;
                                dtrace_probe(fbp->fbp_id, regs->di, regs->si,
                                             regs->dx, regs->cx, regs->r8);
                        } else {
-                               regs->orig_ax = X86_TRAP_BP;
+                               regs->orig_ax = FBT_RETURN_TRAP;
                                dtrace_probe(fbp->fbp_id, fbp->fbp_roffset,
                                             regs->ax, 0, 0, 0);
                        }