Module Name: src Committed By: martin Date: Tue May 1 09:40:16 UTC 2012
Modified Files: src/sys/arch/sparc/include: cpu.h src/sys/arch/sparc/sparc: emul.c trap.c Log Message: On unaligned access, provide the data address to the signal handler, instead of the faulting instructions address. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/include/cpu.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/sparc/emul.c cvs rdiff -u -r1.189 -r1.190 src/sys/arch/sparc/sparc/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc/include/cpu.h diff -u src/sys/arch/sparc/include/cpu.h:1.93 src/sys/arch/sparc/include/cpu.h:1.94 --- src/sys/arch/sparc/include/cpu.h:1.93 Sun Feb 19 21:06:28 2012 +++ src/sys/arch/sparc/include/cpu.h Tue May 1 09:40:15 2012 @@ -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 @@ void kgdb_panic(void); /* emul.c */ struct trapframe; -int fixalign(struct lwp *, struct trapframe *); +int fixalign(struct lwp *, struct trapframe *, void **); int emulinstr(int, struct trapframe *); /* cpu.c */ Index: src/sys/arch/sparc/sparc/emul.c diff -u src/sys/arch/sparc/sparc/emul.c:1.16 src/sys/arch/sparc/sparc/emul.c:1.17 --- src/sys/arch/sparc/sparc/emul.c:1.16 Mon Apr 28 20:23:36 2008 +++ src/sys/arch/sparc/sparc/emul.c Tue May 1 09:40:15 2012 @@ -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 @@ muldiv(struct trapframe *tf, * 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 @@ fixalign(struct lwp *l, struct trapframe 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], Index: src/sys/arch/sparc/sparc/trap.c diff -u src/sys/arch/sparc/sparc/trap.c:1.189 src/sys/arch/sparc/sparc/trap.c:1.190 --- src/sys/arch/sparc/sparc/trap.c:1.189 Sun Feb 19 21:06:29 2012 +++ src/sys/arch/sparc/sparc/trap.c Tue May 1 09:40:15 2012 @@ -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 @@ badtrap: 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 @@ badtrap: 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: