diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2001-09-09 23:56:41 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2001-09-09 23:56:41 +0000 |
commit | a650e4d7c781bcb8119778619b32e381058aa2b7 (patch) | |
tree | f58adf7921330a8dd99a60dcf8f62d0ab7df0e23 /sys/arch/macppc | |
parent | 8674622d42ba3ecb1e0630b405632478fe39a505 (diff) |
Protect debugger accesses with setfault. Should improve debugger usability,
need to verify that kernel exception code deals with this properly.
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r-- | sys/arch/macppc/macppc/db_memrw.c | 48 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/db_trace.c | 6 |
2 files changed, 32 insertions, 22 deletions
diff --git a/sys/arch/macppc/macppc/db_memrw.c b/sys/arch/macppc/macppc/db_memrw.c index 8c8e400175b..226c2417bfd 100644 --- a/sys/arch/macppc/macppc/db_memrw.c +++ b/sys/arch/macppc/macppc/db_memrw.c @@ -1,5 +1,5 @@ /* $NetBSD: db_memrw.c,v 1.4 2001/05/18 20:38:27 matt Exp $ */ -/* $OpenBSD: db_memrw.c,v 1.1 2001/09/01 15:44:20 drahn Exp $ */ +/* $OpenBSD: db_memrw.c,v 1.2 2001/09/09 23:56:40 drahn Exp $ */ /* * Mach Operating System @@ -45,6 +45,7 @@ #include <vm/vm.h> #include <machine/db_machdep.h> +#include <machine/pcb.h> #include <ddb/db_access.h> @@ -58,21 +59,24 @@ db_read_bytes(addr, size, data) register char *data; { register char *src = (char*)addr; - - if (size == 4) { - *((int*)data) = *((int*)src); + faultbuf env; + faultbuf *old_onfault = curpcb->pcb_onfault; + if (setfault(env)) { + curpcb->pcb_onfault = old_onfault; return; } - if (size == 2) { + if (size == 4) { + *((int*)data) = *((int*)src); + } else if (size == 2) { *((short*)data) = *((short*)src); - return; - } - - while (size > 0) { - --size; - *data++ = *src++; + } else { + while (size > 0) { + --size; + *data++ = *src++; + } } + curpcb->pcb_onfault = old_onfault; } /* @@ -85,21 +89,25 @@ db_write_bytes(addr, size, data) register char *data; { register char *dst = (char *)addr; + faultbuf env; + faultbuf *old_onfault = curpcb->pcb_onfault; - if (size == 4) { - *((int*)dst) = *((int*)data); + if (setfault(env)) { + curpcb->pcb_onfault = old_onfault; return; } - if (size == 2) { + if (size == 4) { + *((int*)dst) = *((int*)data); + } else if (size == 2) { *((short*)dst) = *((short*)data); - return; - } - - while (size > 0) { - --size; - *dst++ = *data++; + } else { + while (size > 0) { + --size; + *dst++ = *data++; + } } syncicache((void *)addr, size); + curpcb->pcb_onfault = old_onfault; } diff --git a/sys/arch/macppc/macppc/db_trace.c b/sys/arch/macppc/macppc/db_trace.c index ef077301df9..8b329da05ef 100644 --- a/sys/arch/macppc/macppc/db_trace.c +++ b/sys/arch/macppc/macppc/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.3 2001/09/05 20:49:55 drahn Exp $ */ +/* $OpenBSD: db_trace.c,v 1.4 2001/09/09 23:56:40 drahn Exp $ */ /* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ /* @@ -100,11 +100,13 @@ int db_read32(u_int32_t paddr, u_int32_t *value) { faultbuf env; + faultbuf *old_onfault = curpcb->pcb_onfault; if (setfault(env)) { - curpcb->pcb_onfault = 0; + curpcb->pcb_onfault = old_onfault; return EFAULT; } *value = *(u_int32_t *)paddr; + curpcb->pcb_onfault = old_onfault; return 0; } |