Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src apply changes equivalent to freebsd r256822, r267759 and r29...



details:   https://anonhg.NetBSD.org/src/rev/5d3af3811fd4
branches:  trunk
changeset: 822034:5d3af3811fd4
user:      chs <chs%NetBSD.org@localhost>
date:      Mon Feb 27 06:46:59 2017 +0000

description:
apply changes equivalent to freebsd r256822, r267759 and r298171:
fix the dtrace "args" variable to return correct values.
simplify the invop handlers a bit by changing the second argument
from a pointer into the stack to a pointer to the trapframe.

diffstat:

 external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S  |   7 +--
 external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c  |  41 ++++++++++++---
 external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c |  16 +++---
 external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c   |  14 ++--
 external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S   |  42 ++++++++++++++--
 external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c   |  26 ++++++----
 external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c  |  14 ++--
 external/cddl/osnet/dev/fbt/fbt.c                  |  55 ++++++++++++++++-----
 external/cddl/osnet/dist/uts/common/sys/dtrace.h   |   7 ++-
 sys/arch/arm/arm/undefined.c                       |   8 +-
 sys/arch/i386/i386/i386_trap.S                     |   7 +-
 11 files changed, 160 insertions(+), 77 deletions(-)

diffs (truncated from 595 to 300 lines):

diff -r 5f2d93fbfcf2 -r 5d3af3811fd4 external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S
--- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S Mon Feb 27 05:41:36 2017 +0000
+++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S Mon Feb 27 06:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_asm.S,v 1.6 2016/06/23 04:35:35 pgoyette Exp $  */
+/*     $NetBSD: dtrace_asm.S,v 1.7 2017/02/27 06:46:59 chs Exp $       */
 
 /*
  * CDDL HEADER START
@@ -72,13 +72,10 @@
         */
        movq    TF_RIP(%rsp), %rdi
        decq    %rdi
-       movq    TF_RSP(%rsp), %rsi
+       movq    %rsp, %rsi
        movq    TF_RAX(%rsp), %rdx
-       pushq   (%rsi)
-       movq    %rsp, %rsi
        call    dtrace_invop
        ALTENTRY(dtrace_invop_callsite)
-       addq    $8, %rsp
        cmpl    $DTRACE_INVOP_PUSHL_EBP, %eax
        je      bp_push
        cmpl    $DTRACE_INVOP_LEAVE, %eax
diff -r 5f2d93fbfcf2 -r 5d3af3811fd4 external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c
--- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c Mon Feb 27 05:41:36 2017 +0000
+++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c Mon Feb 27 06:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_isa.c,v 1.5 2016/05/14 21:19:05 chs Exp $       */
+/*     $NetBSD: dtrace_isa.c,v 1.6 2017/02/27 06:46:59 chs Exp $       */
 
 /*
  * CDDL HEADER START
@@ -47,10 +47,9 @@
 
 #define INKERNEL(va) ((intptr_t)(va) < 0)
 
-struct amd64_frame {     
+struct amd64_frame {
        struct amd64_frame      *f_frame;
-       uintptr_t                f_retaddr; 
-       uintptr_t                f_arg0;
+       uintptr_t                f_retaddr;
 };
 
 typedef unsigned long vm_offset_t;
@@ -355,7 +354,8 @@
        for (i = 1; i <= aframes; i++) {
                fp = fp->f_frame;
 
-               if (fp->f_retaddr == (long)dtrace_invop_callsite) {
+               if (P2ROUNDUP(fp->f_retaddr, 16) ==
+                   (long)dtrace_invop_callsite) {
                        /*
                         * In the case of amd64, we will use the pointer to the
                         * regs structure that was pushed when we took the
@@ -369,13 +369,36 @@
                         * we're seeking is passed in registers, we can just
                         * load it directly.
                         */
-                       struct reg *rp = (struct reg *)((uintptr_t)&fp[1] +
-                           sizeof (uintptr_t));
+                       struct trapframe *tf = (struct trapframe *)&fp[1];
 
                        if (arg <= inreg) {
-                               stack = (uintptr_t *)&rp->regs[_REG_RDI];
+                               switch (arg) {
+                               case 0:
+                                       stack = (uintptr_t *)&tf->tf_rdi;
+                                       break;
+                               case 1:
+                                       stack = (uintptr_t *)&tf->tf_rsi;
+                                       break;
+                               case 2:
+                                       stack = (uintptr_t *)&tf->tf_rdx;
+                                       break;
+                               case 3:
+                                       stack = (uintptr_t *)&tf->tf_rcx;
+                                       break;
+                               case 4:
+                                       stack = (uintptr_t *)&tf->tf_r8;
+                                       break;
+                               case 5:
+                                       stack = (uintptr_t *)&tf->tf_r9;
+                                       break;
+                               default:
+                                       KASSERT(0);
+                                       stack = NULL;
+                                       break;
+                               }
+                               arg = 0;
                        } else {
-                               stack = (uintptr_t *)(rp->regs[_REG_RSP]);
+                               stack = (uintptr_t *)(tf->tf_rsp);
                                arg -= inreg;
                        }
                        goto load;
diff -r 5f2d93fbfcf2 -r 5d3af3811fd4 external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
--- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c        Mon Feb 27 05:41:36 2017 +0000
+++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c        Mon Feb 27 06:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_subr.c,v 1.7 2012/06/16 17:31:47 chs Exp $      */
+/*     $NetBSD: dtrace_subr.c,v 1.8 2017/02/27 06:46:59 chs Exp $      */
 
 /*
  * CDDL HEADER START
@@ -51,32 +51,32 @@
 extern uintptr_t       dtrace_in_probe_addr;
 extern int             dtrace_in_probe;
 
-int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t);
+int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
 
 typedef struct dtrace_invop_hdlr {
-       int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t);
+       int (*dtih_func)(uintptr_t, struct trapframe *, uintptr_t);
        struct dtrace_invop_hdlr *dtih_next;
 } dtrace_invop_hdlr_t;
 
 dtrace_invop_hdlr_t *dtrace_invop_hdlr;
+
 void dtrace_gethrtime_init(void *);
 
-
 int
-dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
+dtrace_invop(uintptr_t addr, struct trapframe *frame, uintptr_t eax)
 {
        dtrace_invop_hdlr_t *hdlr;
        int rval;
 
        for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next)
-               if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0)
+               if ((rval = hdlr->dtih_func(addr, frame, eax)) != 0)
                        return (rval);
 
        return (0);
 }
 
 void
-dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+dtrace_invop_add(int (*func)(uintptr_t, struct trapframe *, uintptr_t))
 {
        dtrace_invop_hdlr_t *hdlr;
 
@@ -87,7 +87,7 @@
 }
 
 void
-dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+dtrace_invop_remove(int (*func)(uintptr_t, struct trapframe *, uintptr_t))
 {
        dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL;
 
diff -r 5f2d93fbfcf2 -r 5d3af3811fd4 external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
--- a/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c  Mon Feb 27 05:41:36 2017 +0000
+++ b/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c  Mon Feb 27 06:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_subr.c,v 1.2 2014/03/10 03:04:57 ozaki-r Exp $  */
+/*     $NetBSD: dtrace_subr.c,v 1.3 2017/02/27 06:47:00 chs Exp $      */
 
 /*
  * CDDL HEADER START
@@ -52,10 +52,10 @@
 extern int             dtrace_in_probe;
 extern dtrace_id_t     dtrace_probeid_error;
 
-int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t);
+int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
 
 typedef struct dtrace_invop_hdlr {
-       int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t);
+       int (*dtih_func)(uintptr_t, struct trapframe *, uintptr_t);
        struct dtrace_invop_hdlr *dtih_next;
 } dtrace_invop_hdlr_t;
 
@@ -64,20 +64,20 @@
 void dtrace_gethrtime_init(void *arg);
 
 int
-dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
+dtrace_invop(uintptr_t addr, struct trapframe *frame, uintptr_t eax)
 {
        dtrace_invop_hdlr_t *hdlr;
        int rval;
 
        for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next)
-               if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0)
+               if ((rval = hdlr->dtih_func(addr, frame, eax)) != 0)
                        return (rval);
 
        return (0);
 }
 
 void
-dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+dtrace_invop_add(int (*func)(uintptr_t, struct trapframe *, uintptr_t))
 {
        dtrace_invop_hdlr_t *hdlr;
 
@@ -88,7 +88,7 @@
 }
 
 void
-dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+dtrace_invop_remove(int (*func)(uintptr_t, struct trapframe *, uintptr_t))
 {
        dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL;
 
diff -r 5f2d93fbfcf2 -r 5d3af3811fd4 external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S
--- a/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S  Mon Feb 27 05:41:36 2017 +0000
+++ b/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S  Mon Feb 27 06:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtrace_asm.S,v 1.5 2016/06/23 04:35:35 pgoyette Exp $  */
+/*     $NetBSD: dtrace_asm.S,v 1.6 2017/02/27 06:47:00 chs Exp $       */
 
 /*
  * CDDL HEADER START
@@ -30,17 +30,45 @@
 
 #define _ASM
 
+#include "assym.h"
+
 #include <sys/cpuvar_defs.h>
 #include <sys/dtrace.h>
 #include <machine/asm.h>
 #include <machine/frameasm.h>
+#include <machine/trap.h>
+
+#define INTR_POP               \
+       addl    $16, %esp;      \
+       popl    %edi;           \
+       popl    %esi;           \
+       popl    %ebp;           \
+       popl    %ebx;           \
+       popl    %edx;           \
+       popl    %ecx;           \
+       popl    %eax;           \
+       addl    $8, %esp
 
        ENTRY(dtrace_invop_start)
+       
+       /* Store a trapframe for dtrace. */
+       pushl   $0
+       pushl   $T_PRIVINFLT
+       pushl   %eax
+       pushl   %ecx
+       pushl   %edx
+       pushl   %ebx
+       pushl   %ebp
+       pushl   %esi
+       pushl   %edi
+       subl    $16,%esp                /* dummy for segment regs */
+       cld
 
+       /* Store the args to dtrace_invop(). */
        pushl   %eax                    /* push %eax -- may be return value */
        pushl   %esp                    /* push stack pointer */
-       addl    $48, (%esp)             /* adjust to incoming args */
-       pushl   40(%esp)                /* push calling EIP */
+       addl    $4, (%esp)              /* skip first arg and segment regs */
+       pushl   TF_EIP+8(%esp)          /* push calling EIP */
 
        /*
         * Call dtrace_invop to let it check if the exception was
@@ -67,7 +95,7 @@
         * We must emulate a "pushl %ebp".  To do this, we pull the stack
         * down 4 bytes, and then store the base pointer.
         */
-       popal
+       INTR_POP
        subl    $4, %esp                /* make room for %ebp */
        pushl   %eax                    /* push temp */
        movl    8(%esp), %eax           /* load calling EIP */
@@ -86,7 +114,7 @@
         * the above:  we remove the %ebp from the stack, and squeeze up the
         * saved state from the trap.
         */
-       popal
+       INTR_POP
        pushl   %eax                    /* push temp */
        movl    16(%esp), %ebp          /* pop %ebp */
        movl    12(%esp), %eax          /* load calling EFLAGS */
@@ -106,7 +134,7 @@
         * requires two temporaries:  one for the new base pointer, and one
         * for the staging register.
         */
-       popa
+       INTR_POP
        pushl   %eax                    /* push temp */
        pushl   %ebx                    /* push temp */
        movl    %ebp, %ebx              /* set temp to old %ebp */
@@ -129,7 +157,7 @@
         * We must emulate a "nop".  This is obviously not hard:  we need only
         * advance the %eip by one.
         */
-       popa
+       INTR_POP
        incl    (%esp)



Home | Main Index | Thread Index | Old Index