diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-09-01 19:14:05 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-09-01 19:14:05 +0000 |
commit | 8c643fa97dba3913c4dcf9288ab2a0086f149862 (patch) | |
tree | c26c00124db4bb3801cbbadddf2e58f52d568e29 /sys/arch/mvme88k/dev | |
parent | 2184cb26e19fac9e35b58667a17599f739d23317 (diff) |
Prevent userland from invoking BUG system calls, by saving the initial BUG
trap vector contents, putting the bugtrap() stub in place, and switching
back and forth between them when the kernel needs to invoke BUG functions.
Diffstat (limited to 'sys/arch/mvme88k/dev')
-rw-r--r-- | sys/arch/mvme88k/dev/bugio.c | 42 | ||||
-rw-r--r-- | sys/arch/mvme88k/dev/bugtty.c | 19 |
2 files changed, 43 insertions, 18 deletions
diff --git a/sys/arch/mvme88k/dev/bugio.c b/sys/arch/mvme88k/dev/bugio.c index 10d39ef1540..a8ae21fcf9f 100644 --- a/sys/arch/mvme88k/dev/bugio.c +++ b/sys/arch/mvme88k/dev/bugio.c @@ -1,17 +1,56 @@ -/* $OpenBSD: bugio.c,v 1.9 2002/03/05 22:11:37 miod Exp $ */ +/* $OpenBSD: bugio.c,v 1.10 2003/09/01 19:14:01 miod Exp $ */ /* Copyright (c) 1998 Steve Murphree, Jr. */ #include <sys/param.h> #include <sys/systm.h> +#include <machine/asm_macro.h> #include <machine/bugio.h> #include <machine/prom.h> register_t ossr0, ossr1, ossr2, ossr3; register_t bugsr0, bugsr1, bugsr2, bugsr3; +unsigned long bugvec[2], sysbugvec[2]; + +void bug_vector(void); +void sysbug_vector(void); + +#define MVMEPROM_CALL(x) \ + __asm__ __volatile__ (__CONCAT("or r9,r0,",__STRING(x))); \ + __asm__ __volatile__ ("tb0 0,r0,496") + +void +bug_vector() +{ + unsigned long *vbr, psr; + + psr = disable_interrupts_return_psr(); /* paranoia */ + + __asm__ __volatile__ ("ldcr %0, cr7" : "=r" (vbr)); + vbr[2 * MVMEPROM_VECTOR + 0] = bugvec[0]; + vbr[2 * MVMEPROM_VECTOR + 1] = bugvec[1]; + + set_psr(psr); +} + +void +sysbug_vector() +{ + unsigned long *vbr, psr; + + psr = disable_interrupts_return_psr(); /* paranoia */ + + __asm__ __volatile__ ("ldcr %0, cr7" : "=r" (vbr)); + vbr[2 * MVMEPROM_VECTOR + 0] = sysbugvec[0]; + vbr[2 * MVMEPROM_VECTOR + 1] = sysbugvec[1]; + + set_psr(psr); +} + #define BUGCTXT() \ { \ + bug_vector(); \ __asm__ __volatile__ ("ldcr %0, cr17" : "=r" (ossr0)); \ __asm__ __volatile__ ("ldcr %0, cr18" : "=r" (ossr1)); \ __asm__ __volatile__ ("ldcr %0, cr19" : "=r" (ossr2)); \ @@ -36,6 +75,7 @@ register_t bugsr0, bugsr1, bugsr2, bugsr3; __asm__ __volatile__ ("stcr %0, cr18" :: "r"(ossr1)); \ __asm__ __volatile__ ("stcr %0, cr19" :: "r"(ossr2)); \ __asm__ __volatile__ ("stcr %0, cr20" :: "r"(ossr3)); \ + sysbug_vector(); \ } static void diff --git a/sys/arch/mvme88k/dev/bugtty.c b/sys/arch/mvme88k/dev/bugtty.c index 18753ce6401..e8f6b482bbd 100644 --- a/sys/arch/mvme88k/dev/bugtty.c +++ b/sys/arch/mvme88k/dev/bugtty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bugtty.c,v 1.15 2003/08/15 20:32:14 tedu Exp $ */ +/* $OpenBSD: bugtty.c,v 1.16 2003/09/01 19:14:01 miod Exp $ */ /* Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -113,7 +113,7 @@ bugttyattach(parent, self, aux) struct device *self; void *aux; { - printf(": bugtty\n"); + printf(": fallback console\n"); } #define BUGTTYUNIT(x) ((x) & (0x7f)) @@ -467,21 +467,6 @@ bugttycnprobe(cp) return (0); } -#if 0 - switch (cputyp) { - case CPU_147: - case CPU_162: - cp->cn_pri = CN_NORMAL; - return (0); - default: - break; - } -#endif -#if 0 - cp->cn_pri = CN_NORMAL; - return (0); -#endif /* 0 */ - /* locate the major number */ for (maj = 0; maj < nchrdev; maj++) if (cdevsw[maj].d_open == bugttyopen) |