Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode/usermode Hack trap for now to upgrade prot...



details:   https://anonhg.NetBSD.org/src/rev/56d8a43f3ed6
branches:  trunk
changeset: 768938:56d8a43f3ed6
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Mon Aug 29 12:42:19 2011 +0000

description:
Hack trap for now to upgrade protection.. this really needs fixing soon

diffstat:

 sys/arch/usermode/usermode/trap.c |  23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r 050126918cf9 -r 56d8a43f3ed6 sys/arch/usermode/usermode/trap.c
--- a/sys/arch/usermode/usermode/trap.c Mon Aug 29 12:41:38 2011 +0000
+++ b/sys/arch/usermode/usermode/trap.c Mon Aug 29 12:42:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.10 2011/08/28 19:38:20 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.11 2011/08/29 12:42:19 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.10 2011/08/28 19:38:20 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.11 2011/08/29 12:42:19 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -35,15 +35,18 @@
 #include <sys/proc.h>
 #include <sys/systm.h>
 #include <sys/userret.h>
+#include <sys/errno.h>
+
 #include <uvm/uvm_extern.h>
 #include <machine/cpu.h>
+#include <machine/pcb.h>
+#include <machine/pmap.h>
+#include <machine/thunk.h>
+
 //#include <machine/ctlreg.h>
 //#include <machine/trap.h>
 //#include <machine/instr.h>
-#include <machine/pcb.h>
-#include <machine/pmap.h>
 //#include <machine/userret.h>
-#include <machine/thunk.h>
 
 
 void setup_signal_handlers(void);
@@ -135,11 +138,17 @@
                        panic("peeing outside the box!");
                }
 
+               /* XXX TODO determine atype?? */
+atype = PROT_READ;
+again:
                pcb->pcb_onfault = NULL;
-               /* XXX TODO determine atype?? */
-atype = PROT_READ | PROT_WRITE;
                rv = uvm_fault(vm_map, (vaddr_t) va, atype);
                pcb->pcb_onfault = (void *) onfault;
+if (rv) printf("uvm_fault rv = %d\n", rv);
+if (rv == EACCES) {
+       atype |= PROT_WRITE | PROT_EXEC;
+       goto again;
+}
                if (rv) {
                        /* something got wrong */
                        if (kmem) {



Home | Main Index | Thread Index | Old Index