Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode cpu_lwp_inkernel approach won't work, back...



details:   https://anonhg.NetBSD.org/src/rev/989f688e7072
branches:  trunk
changeset: 769304:989f688e7072
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Sep 06 09:55:04 2011 +0000

description:
cpu_lwp_inkernel approach won't work, back to the drawing board

diffstat:

 sys/arch/usermode/dev/cpu.c             |   7 ++-----
 sys/arch/usermode/usermode/trap.c       |  11 ++---------
 sys/arch/usermode/usermode/urkelvisor.c |  13 +++++--------
 3 files changed, 9 insertions(+), 22 deletions(-)

diffs (130 lines):

diff -r 0edc9d01e486 -r 989f688e7072 sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c       Tue Sep 06 09:48:34 2011 +0000
+++ b/sys/arch/usermode/dev/cpu.c       Tue Sep 06 09:55:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.33 2011/09/05 20:54:47 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.34 2011/09/06 09:55:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_cpu.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.33 2011/09/05 20:54:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.34 2011/09/06 09:55:04 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -58,8 +58,6 @@
 #define cpu_unreachable()      do { thunk_abort(); } while (0)
 #endif
 
-int cpu_lwp_inkernel = 1;
-
 static int     cpu_match(device_t, cfdata_t, void *);
 static void    cpu_attach(device_t, device_t, void *);
 
@@ -188,7 +186,6 @@
 
        ci->ci_stash = oldlwp;
        curlwp = newlwp;
-       cpu_lwp_inkernel = curproc->p_vmspace->vm_map.pmap == pmap_kernel();
 
        if (oldpcb) {
                oldpcb->pcb_errno = thunk_geterrno();
diff -r 0edc9d01e486 -r 989f688e7072 sys/arch/usermode/usermode/trap.c
--- a/sys/arch/usermode/usermode/trap.c Tue Sep 06 09:48:34 2011 +0000
+++ b/sys/arch/usermode/usermode/trap.c Tue Sep 06 09:55:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.29 2011/09/06 09:38:27 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.30 2011/09/06 09:55:04 jmcneill 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.29 2011/09/06 09:38:27 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.30 2011/09/06 09:55:04 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -48,8 +48,6 @@
 //#include <machine/instr.h>
 //#include <machine/userret.h>
 
-extern int cpu_lwp_inkernel;
-
 /* forwards and externals */
 void setup_signal_handlers(void);
 static void mem_access_handler(int sig, siginfo_t *info, void *ctx);
@@ -118,8 +116,6 @@
        void *onfault;
        int kmem, lwp_errno, rv;
 
-       cpu_lwp_inkernel++;
-
        recurse++;
        if (recurse > 1)
                printf("enter trap recursion level %d\n", recurse);
@@ -232,7 +228,6 @@
        if (recurse > 1)
                printf("leaving trap recursion level %d\n", recurse);
        recurse--;
-       cpu_lwp_inkernel--;
 }
 
 static void
@@ -244,7 +239,6 @@
        struct pcb *pcb;
        vaddr_t va;
 
-       cpu_lwp_inkernel++;
        recurse++;
        if (recurse > 1)
                printf("enter trap recursion level %d\n", recurse);
@@ -292,5 +286,4 @@
 
                panic("illegal instruction encountered\n");
        }
-       cpu_lwp_inkernel--;
 }
diff -r 0edc9d01e486 -r 989f688e7072 sys/arch/usermode/usermode/urkelvisor.c
--- a/sys/arch/usermode/usermode/urkelvisor.c   Tue Sep 06 09:48:34 2011 +0000
+++ b/sys/arch/usermode/usermode/urkelvisor.c   Tue Sep 06 09:55:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: urkelvisor.c,v 1.7 2011/09/05 20:54:48 jmcneill Exp $ */
+/* $NetBSD: urkelvisor.c,v 1.8 2011/09/06 09:55:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: urkelvisor.c,v 1.7 2011/09/05 20:54:48 jmcneill Exp $");
+__RCSID("$NetBSD: urkelvisor.c,v 1.8 2011/09/06 09:55:04 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -114,15 +114,12 @@
 static int
 handle_syscall(struct reg_struct *puregs, pid_t urkel_pid)
 {
-       extern int cpu_lwp_inkernel;
+       vaddr_t pc;
        int sig = 0;
        int inkernel;
 
-       errno = 0;
-       inkernel = ptrace(PT_READ_D, urkel_pid, &cpu_lwp_inkernel, 0);
-       if (errno)
-               err(EXIT_FAILURE, "ptrace(PT_READ_D, %d, %p, 0) failed",
-                   urkel_pid, &cpu_lwp_inkernel);
+       pc = (vaddr_t)R_PC(puregs);
+       inkernel = !(pc >= kmem_user_start && pc < kmem_user_end);
 
        //fprintf(stderr, "%s: pid=%d pc=%p inkernel=%d\n",
        //    __func__, urkel_pid, (void *)R_PC(puregs), inkernel);



Home | Main Index | Thread Index | Old Index