Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc On unaligned access, provide the data address...



details:   https://anonhg.NetBSD.org/src/rev/9ad255c5ab0c
branches:  trunk
changeset: 779088:9ad255c5ab0c
user:      martin <martin%NetBSD.org@localhost>
date:      Tue May 01 09:40:15 2012 +0000

description:
On unaligned access, provide the data address to the signal handler, instead
of the faulting instructions address.

diffstat:

 sys/arch/sparc/include/cpu.h |   4 ++--
 sys/arch/sparc/sparc/emul.c  |  14 +++++++++++---
 sys/arch/sparc/sparc/trap.c  |   8 ++++----
 3 files changed, 17 insertions(+), 9 deletions(-)

diffs (99 lines):

diff -r 6c550a4abeda -r 9ad255c5ab0c sys/arch/sparc/include/cpu.h
--- a/sys/arch/sparc/include/cpu.h      Tue May 01 07:48:25 2012 +0000
+++ b/sys/arch/sparc/include/cpu.h      Tue May 01 09:40:15 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.93 2012/02/19 21:06:28 rmind Exp $ */
+/*     $NetBSD: cpu.h,v 1.94 2012/05/01 09:40:15 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -236,7 +236,7 @@
 
 /* emul.c */
 struct trapframe;
-int fixalign(struct lwp *, struct trapframe *);
+int fixalign(struct lwp *, struct trapframe *, void **);
 int emulinstr(int, struct trapframe *);
 
 /* cpu.c */
diff -r 6c550a4abeda -r 9ad255c5ab0c sys/arch/sparc/sparc/emul.c
--- a/sys/arch/sparc/sparc/emul.c       Tue May 01 07:48:25 2012 +0000
+++ b/sys/arch/sparc/sparc/emul.c       Tue May 01 09:40:15 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emul.c,v 1.16 2008/04/28 20:23:36 martin Exp $ */
+/*     $NetBSD: emul.c,v 1.17 2012/05/01 09:40:15 martin Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.16 2008/04/28 20:23:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.17 2012/05/01 09:40:15 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -212,10 +212,12 @@
  * Code to handle alignment faults on the sparc. This is enabled by sending
  * a fixalign trap. Such code is generated by compiling with cc -misalign
  * on SunOS, but we don't have such a feature yet on our gcc.
+ * If data_address is passed, do not emulate the instruction but just report
+ * back the VA (this is used for signal delivery).
  */
 
 int
-fixalign(struct lwp *l, struct trapframe *tf)
+fixalign(struct lwp *l, struct trapframe *tf, void **data_address)
 {
        static u_char sizedef[] = { 0x4, 0xff, 0x2, 0x8 };
 
@@ -282,6 +284,12 @@
 
        rs1 += rs2;
 
+       /* Only querying faulting data address? */
+       if (data_address) {
+               *data_address = (void*)rs1;
+               return 0;
+       }
+
 #ifdef DEBUG_EMUL
        uprintf("memalign 0x%x: %s%c%c %c%d, %c%d, ", code.i_int,
            op.bits.st ? "st" : "ld", "us"[op.bits.sgn],
diff -r 6c550a4abeda -r 9ad255c5ab0c sys/arch/sparc/sparc/trap.c
--- a/sys/arch/sparc/sparc/trap.c       Tue May 01 07:48:25 2012 +0000
+++ b/sys/arch/sparc/sparc/trap.c       Tue May 01 09:40:15 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.189 2012/02/19 21:06:29 rmind Exp $ */
+/*     $NetBSD: trap.c,v 1.190 2012/05/01 09:40:15 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.189 2012/02/19 21:06:29 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2012/05/01 09:40:15 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_svr4.h"
@@ -565,7 +565,7 @@
 
        case T_ALIGN:
                if ((p->p_md.md_flags & MDP_FIXALIGN) != 0) {
-                       n = fixalign(l, tf);
+                       n = fixalign(l, tf, NULL);
                        if (n == 0) {
                                ADVANCE;
                                break;
@@ -575,7 +575,7 @@
                KSI_INIT_TRAP(&ksi);
                ksi.ksi_trap = type;
                ksi.ksi_code = BUS_ADRALN;
-               ksi.ksi_addr = (void *)pc;
+               fixalign(l, tf, &ksi.ksi_addr);
                break;
 
        case T_FPE:



Home | Main Index | Thread Index | Old Index