Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm split PUSHFRAMEINSVC into two pieces so that we...



details:   https://anonhg.NetBSD.org/src/rev/a594ff234783
branches:  trunk
changeset: 825281:a594ff234783
user:      chs <chs%NetBSD.org@localhost>
date:      Fri Jul 07 00:34:09 2017 +0000

description:
split PUSHFRAMEINSVC into two pieces so that we can insert some additional
instructions in the middle in undefinedinstruction_bounce, namely to add
some additional space on the stack before the trapframe for undefineds from
SVC mode.  this extra space allows dtrace to emulate a "push" instruction.
the initial version was from me and some improvements were from nick.

diffstat:

 sys/arch/arm/arm32/exception.S     |   8 +++++---
 sys/arch/arm/include/arm32/frame.h |  25 +++++++++++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)

diffs (86 lines):

diff -r 2f8be7d5d19f -r a594ff234783 sys/arch/arm/arm32/exception.S
--- a/sys/arch/arm/arm32/exception.S    Thu Jul 06 22:10:14 2017 +0000
+++ b/sys/arch/arm/arm32/exception.S    Fri Jul 07 00:34:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $      */
+/*     $NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $       */
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -51,7 +51,7 @@
 
 #include <arm/locore.h>
 
-       RCSID("$NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $")
+       RCSID("$NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $")
 
        .text   
        .align  0
@@ -258,7 +258,9 @@
  */
 
 ENTRY_NP(undefinedinstruction_bounce)
-       PUSHFRAMEINSVC
+       PUSHXXXREGSANDSWITCH
+       PUSHDTRACEGAP
+       PUSHTRAPFRAME(r2)
        ENABLE_ALIGNMENT_FAULTS
 
        mov     r0, sp
diff -r 2f8be7d5d19f -r a594ff234783 sys/arch/arm/include/arm32/frame.h
--- a/sys/arch/arm/include/arm32/frame.h        Thu Jul 06 22:10:14 2017 +0000
+++ b/sys/arch/arm/include/arm32/frame.h        Fri Jul 07 00:34:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frame.h,v 1.43 2017/06/22 08:44:21 skrll Exp $ */
+/*     $NetBSD: frame.h,v 1.44 2017/07/07 00:34:09 chs Exp $   */
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -95,6 +95,7 @@
 #include "opt_cpuoptions.h"
 #include "opt_arm_debug.h"
 #include "opt_cputypes.h"
+#include "opt_dtrace.h"
 
 #include <arm/locore.h>
 
@@ -440,13 +441,25 @@
        msr     cpsr_c, tmp             /* Punch into SVC mode */
 #endif
 
-#define PUSHFRAMEINSVC                                                    \
+#define PUSHXXXREGSANDSWITCH                                              \
        stmdb   sp, {r0-r3};            /* Save 4 registers */             \
        mov     r0, lr;                 /* Save xxx32 r14 */               \
        mov     r1, sp;                 /* Save xxx32 sp */                \
        mrs     r3, spsr;               /* Save xxx32 spsr */              \
-       SET_CPSR_MODE(r2, PSR_SVC32_MODE);                                 \
-       bic     r2, sp, #7;             /* Align new SVC sp */             \
+       SET_CPSR_MODE(r2, PSR_SVC32_MODE)
+
+#ifdef KDTRACE_HOOKS
+#define PUSHDTRACEGAP                                                     \
+       and     r2, r3, #(PSR_MODE);                                       \
+       cmp     r2, #(PSR_SVC32_MODE);  /* were we in SVC mode? */         \
+       mov     r2, sp;                                                    \
+       subeq   r2, r2, #(4 * 16);      /* if so, leave a gap for dtrace */
+#else
+#define PUSHDTRACEGAP                  /* nothing */
+#endif
+
+#define PUSHTRAPFRAME(rX)                                                 \
+       bic     r2, rX, #7;             /* Align new SVC sp */             \
        str     r0, [r2, #-4]!;         /* Push return address */          \
        stmdb   r2!, {sp, lr};          /* Push SVC sp, lr */              \
        mov     sp, r2;                 /* Keep stack aligned */           \
@@ -458,6 +471,10 @@
        mrs     r0, spsr;               /* Get the SPSR */                 \
        str     r0, [sp, #-TF_R0]!      /* Push the SPSR onto the stack */
 
+#define PUSHFRAMEINSVC                                                    \
+       PUSHXXXREGSANDSWITCH;                                              \
+       PUSHTRAPFRAME(sp)
+
 /*
  * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack
  * in SVC32 mode and restore the saved processor mode and PC.



Home | Main Index | Thread Index | Old Index