]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: support passing offset as arg0 to FBT return probes
authorKris Van Hees <kris.van.hees@oracle.com>
Tue, 16 May 2017 13:55:41 +0000 (09:55 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Tue, 23 May 2017 13:36:10 +0000 (09:36 -0400)
FBT return probes pass the offset from the function start (in bytes)
as arg0.  To make that possible, we pass the offset value in the call
to fbt_add_probe.  For FBT entry probes we pass 0 (which is ignored).

This commit also ensures that we emulate the 'ret' instruction on the
return path.

Orabug: 25949086
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
dtrace/fbt_dev.c
dtrace/fbt_x86_64.c

index 2d292a0a20e52e327971a3c548d5b6d69fea17ed..9d0ddd9487998abce0b3d1e8b13861cbc481bfa4 100644 (file)
@@ -43,7 +43,8 @@ int                   fbt_probetab_size = FBT_PROBETAB_SIZE;
 int                    fbt_probetab_mask;
 
 static void *fbt_provide_probe(struct module *mp, char *func, int type, int
-                              stype, asm_instr_t *addr, void *pfbt)
+                              stype, asm_instr_t *addr, uintptr_t off,
+                              void *pfbt)
 {
        fbt_probe_t     *fbp;
        fbt_probe_t     *prev;
@@ -57,6 +58,7 @@ static void *fbt_provide_probe(struct module *mp, char *func, int type, int
                fbp->fbp_module = mp;
                fbp->fbp_loadcnt = 1; /* FIXME */
                fbp->fbp_primary = 1; /* FIXME */
+               fbp->fbp_roffset = off;
                fbp->fbp_patchpoint = addr;
                fbt_provide_probe_arch(fbp, type, stype);
                 fbp->fbp_hashnext = fbt_probetab[FBT_ADDR2NDX(addr)];
@@ -83,6 +85,7 @@ static void *fbt_provide_probe(struct module *mp, char *func, int type, int
                fbp->fbp_module = mp;
                fbp->fbp_loadcnt = 1; /* FIXME */
                fbp->fbp_primary = 1; /* FIXME */
+               fbp->fbp_roffset = off;
                fbp->fbp_patchpoint = addr;
                fbt_provide_probe_arch(fbp, type, stype);
                 fbp->fbp_hashnext = fbt_probetab[FBT_ADDR2NDX(addr)];
index 9a873c7cec2be4c279e75f77a3ef7668a625c633..45eb7eb5ee7863efe71154f55225b4457dc3e6b1 100644 (file)
@@ -41,9 +41,13 @@ static uint8_t fbt_invop(struct pt_regs *regs)
        for (; fbp != NULL; fbp = fbp->fbp_hashnext) {
                if ((uintptr_t)fbp->fbp_patchpoint == regs->ip) {
                        this_cpu_core->cpu_dtrace_regs = regs;
-
-                       dtrace_probe(fbp->fbp_id, regs->di, regs->si,
-                                    regs->dx, regs->cx, regs->r8);
+                       if (fbp->fbp_roffset == 0) {
+                               dtrace_probe(fbp->fbp_id, regs->di, regs->si,
+                                            regs->dx, regs->cx, regs->r8);
+                       } else {
+                               dtrace_probe(fbp->fbp_id, fbp->fbp_roffset,
+                                            regs->ax, 0, 0, 0);
+                       }
 
                        this_cpu_core->cpu_dtrace_regs = NULL;
 
@@ -58,7 +62,7 @@ void fbt_provide_probe_arch(fbt_probe_t *fbp, int type, int stype)
 {
        fbp->fbp_patchval = FBT_PATCHVAL;
        fbp->fbp_savedval = *fbp->fbp_patchpoint;
-       fbp->fbp_rval = type == FBT_ENTRY ? DTRACE_INVOP_MOV_RSP_RBP
+       fbp->fbp_rval = type == FBT_ENTRY ? DTRACE_INVOP_PUSH_BP
                                          : DTRACE_INVOP_RET;
 }