Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/powerpc Change syscall to bound code so tha...



details:   https://anonhg.NetBSD.org/src/rev/3bce07e057b5
branches:  trunk
changeset: 539288:3bce07e057b5
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Nov 13 09:36:10 2002 +0000

description:
Change syscall to bound code so that systrace and ktrace won't fall off
the end of a table.   XXX this is wrong since code does not indicate the
sysent table for which code was used as an index.

diffstat:

 sys/arch/powerpc/powerpc/mach_syscall.c |  32 ++++++++++++++++++++++----------
 sys/arch/powerpc/powerpc/syscall.c      |  12 ++++++------
 2 files changed, 28 insertions(+), 16 deletions(-)

diffs (121 lines):

diff -r 743b3e71cc75 -r 3bce07e057b5 sys/arch/powerpc/powerpc/mach_syscall.c
--- a/sys/arch/powerpc/powerpc/mach_syscall.c   Wed Nov 13 09:33:20 2002 +0000
+++ b/sys/arch/powerpc/powerpc/mach_syscall.c   Wed Nov 13 09:36:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_syscall.c,v 1.4 2002/11/04 00:01:02 matt Exp $ */
+/*     $NetBSD: mach_syscall.c,v 1.5 2002/11/13 09:36:10 matt Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include "opt_compat_mach.h"
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: mach_syscall.c,v 1.4 2002/11/04 00:01:02 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_syscall.c,v 1.5 2002/11/13 09:36:10 matt Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
@@ -60,35 +60,47 @@
 #define MACH_PPCCALLS          0x00006000
 #define MACH_ODD_SYSCALL_MASK  0x0000fff0
 
-static inline const struct sysent *mach_syscall_dispatch __P((register_t));
+static inline const struct sysent *mach_syscall_dispatch __P((register_t *));
 
 #include "syscall.c"
 
 static inline const struct sysent *
-mach_syscall_dispatch(register_t code)
+mach_syscall_dispatch(register_t *code_p)
 {
+       const struct sysent *callp = NULL;
+       register_t code = *code_p;
+
 #ifdef DEBUG_MACH
        if (code >= MACH_PPCCALLS);
                printf("->mach(0x%x)\n", code);
 #endif
+
        switch (code & MACH_ODD_SYSCALL_MASK) {
        case MACH_PPCCALLS:
-               return mach_ppccalls_sysent +
-                   ((code - MACH_PPCCALLS) & (MACH_PPCCALLS_SYS_NSYSENT-1));
+               code = (code - MACH_PPCCALLS) & (MACH_PPCCALLS_SYS_NSYSENT-1);
+               callp = mach_ppccalls_sysent;
+               break;
 
        case MACH_FASTTRAPS:
-               return mach_fasttraps_sysent +
-                   ((code - MACH_FASTTRAPS) & (MACH_FASTTRAPS_SYS_NSYSENT-1));
+               code = (code - MACH_FASTTRAPS) & (MACH_FASTTRAPS_SYS_NSYSENT-1);
+               callp = mach_fasttraps_sysent;
+               break;
 
        default:
                if (code < 0) {
 #ifdef DEBUG_MACH
                        printf("->mach(%d)\n", code);
 #endif /* DEBUG_MACH */
-                       return mach_sysent + (-code & (MACH_SYS_NSYSENT-1));
+                       code = -code & (MACH_SYS_NSYSENT-1);
+                       callp = mach_sysent;
                }
                break;
        }
 
-       return NULL;
+       if (callp != NULL) {
+               *code_p = code;
+               callp += code;
+       }
+
+       return callp;
 }
diff -r 743b3e71cc75 -r 3bce07e057b5 sys/arch/powerpc/powerpc/syscall.c
--- a/sys/arch/powerpc/powerpc/syscall.c        Wed Nov 13 09:33:20 2002 +0000
+++ b/sys/arch/powerpc/powerpc/syscall.c        Wed Nov 13 09:36:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.12 2002/11/04 00:01:03 matt Exp $        */
+/*     $NetBSD: syscall.c,v 1.13 2002/11/13 09:36:10 matt Exp $        */
 
 /*
  * Copyright (C) 2002 Matt Thomas
@@ -65,7 +65,7 @@
 #define EMULNAME(x)    (x)
 #define EMULNAMEU(x)   (x)
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.12 2002/11/04 00:01:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.13 2002/11/13 09:36:10 matt Exp $");
 
 void
 child_return(void *arg)
@@ -114,7 +114,7 @@
        n = NARGREG;
 
 #ifdef COMPAT_MACH
-       if ((callp = mach_syscall_dispatch(code)) == NULL)
+       if ((callp = mach_syscall_dispatch(&code)) == NULL)
 #endif /* COMPAT_MACH */
        {
                switch (code) {
@@ -217,7 +217,7 @@
        n = NARGREG;
 
 #ifdef COMPAT_MACH
-       if ((callp = mach_syscall_dispatch(code)) == NULL)
+       if ((callp = mach_syscall_dispatch(&code)) == NULL)
 #endif /* COMPAT_MACH */
        {
                switch (code) {
@@ -240,8 +240,8 @@
                        break;
                }
 
-               callp = p->p_emul->e_sysent +
-                   (code & (EMULNAMEU(SYS_NSYSENT)-1));
+               code &= EMULNAMEU(SYS_NSYSENT) - 1;
+               callp = p->p_emul->e_sysent + code;
        }
 
        argsize = callp->sy_argsize;



Home | Main Index | Thread Index | Old Index