On unaligned access, provide the data address to the signal handler, instead

of the faulting instructions address.
This commit is contained in:
martin 2012-05-01 09:40:15 +00:00
parent 7f8940a8ce
commit 1519b75992
3 changed files with 17 additions and 9 deletions

View File

@ -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 */

View File

@ -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 *tf)
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],

View File

@ -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: