Source-Changes-HG archive

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

[src/trunk]: src/sys move macros for validating fs/gs to segments.h and use them



details:   https://anonhg.NetBSD.org/src/rev/f9347adab8ed
branches:  trunk
changeset: 761764:f9347adab8ed
user:      chs <chs%NetBSD.org@localhost>
date:      Mon Feb 07 03:54:45 2011 +0000

description:
move macros for validating fs/gs to segments.h and use them
in the linux32 code as well.

diffstat:

 sys/arch/amd64/amd64/netbsd32_machdep.c         |  17 ++++++-----------
 sys/arch/amd64/include/segments.h               |   6 +++++-
 sys/compat/linux32/arch/amd64/linux32_machdep.c |   8 ++++----
 3 files changed, 15 insertions(+), 16 deletions(-)

diffs (108 lines):

diff -r 5b14d4463fc0 -r f9347adab8ed sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Mon Feb 07 03:14:28 2011 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Mon Feb 07 03:54:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.69 2011/01/26 21:44:31 njoly Exp $      */
+/*     $NetBSD: netbsd32_machdep.c,v 1.70 2011/02/07 03:54:45 chs Exp $        */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.69 2011/01/26 21:44:31 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.70 2011/02/07 03:54:45 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -953,11 +953,6 @@
  * These functions perform the needed checks.
  */
 
-#define        VALID_FS32(s) \
-    (((s) & 0xffff) == GSEL(GUFS_SEL, SEL_UPL))
-#define        VALID_GS32(s) \
-    (((s) & 0xffff) == GSEL(GUGS_SEL, SEL_UPL))
-
 static int
 check_sigcontext32(struct lwp *l, const struct netbsd32_sigcontext *scp)
 {
@@ -971,10 +966,10 @@
            !VALID_USER_CSEL32(scp->sc_cs))
                return EINVAL;
        if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
-           !(VALID_FS32(scp->sc_fs) && pcb->pcb_fs != 0))
+           !(VALID_USER_FSEL32(scp->sc_fs) && pcb->pcb_fs != 0))
                return EINVAL;
        if (scp->sc_gs != 0 && !VALID_USER_DSEL32(scp->sc_gs) &&
-           !(VALID_GS32(scp->sc_gs) && pcb->pcb_gs != 0))
+           !(VALID_USER_GSEL32(scp->sc_gs) && pcb->pcb_gs != 0))
                return EINVAL;
        if (scp->sc_es != 0 && !VALID_USER_DSEL32(scp->sc_es))
                return EINVAL;
@@ -1000,10 +995,10 @@
            !VALID_USER_CSEL32(gr[_REG32_CS]))
                return EINVAL;
        if (gr[_REG32_FS] != 0 && !VALID_USER_DSEL32(gr[_REG32_FS]) &&
-           !(VALID_FS32(gr[_REG32_FS]) && pcb->pcb_fs != 0))
+           !(VALID_USER_FSEL32(gr[_REG32_FS]) && pcb->pcb_fs != 0))
                return EINVAL;
        if (gr[_REG32_GS] != 0 && !VALID_USER_DSEL32(gr[_REG32_GS]) &&
-           !(VALID_GS32(gr[_REG32_GS]) && pcb->pcb_gs != 0))
+           !(VALID_USER_GSEL32(gr[_REG32_GS]) && pcb->pcb_gs != 0))
                return EINVAL;
        if (gr[_REG32_ES] != 0 && !VALID_USER_DSEL32(gr[_REG32_ES]))
                return EINVAL;
diff -r 5b14d4463fc0 -r f9347adab8ed sys/arch/amd64/include/segments.h
--- a/sys/arch/amd64/include/segments.h Mon Feb 07 03:14:28 2011 +0000
+++ b/sys/arch/amd64/include/segments.h Mon Feb 07 03:54:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: segments.h,v 1.21 2010/09/05 20:14:40 chs Exp $        */
+/*     $NetBSD: segments.h,v 1.22 2011/02/07 03:54:45 chs Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -397,6 +397,10 @@
      ((s) & 0xffff) == LSEL(LUDATA32_SEL, SEL_UPL))
 #define VALID_USER_CSEL32(s) \
     ((s) == GSEL(GUCODE32_SEL, SEL_UPL) || (s) == LSEL(LUCODE32_SEL, SEL_UPL))
+#define VALID_USER_FSEL32(s) \
+    (((s) & 0xffff) == GSEL(GUFS_SEL, SEL_UPL))
+#define VALID_USER_GSEL32(s) \
+    (((s) & 0xffff) == GSEL(GUGS_SEL, SEL_UPL))
 
 #define VALID_USER_CSEL(s) \
     ((s) == GSEL(GUCODE_SEL, SEL_UPL) || (s) == LSEL(LUCODE_SEL, SEL_UPL))
diff -r 5b14d4463fc0 -r f9347adab8ed sys/compat/linux32/arch/amd64/linux32_machdep.c
--- a/sys/compat/linux32/arch/amd64/linux32_machdep.c   Mon Feb 07 03:14:28 2011 +0000
+++ b/sys/compat/linux32/arch/amd64/linux32_machdep.c   Mon Feb 07 03:54:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_machdep.c,v 1.27 2010/11/02 18:14:06 chs Exp $ */
+/*     $NetBSD: linux32_machdep.c,v 1.28 2011/02/07 03:54:45 chs Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -31,7 +31,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.27 2010/11/02 18:14:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.28 2011/02/07 03:54:45 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -433,11 +433,11 @@
                return EINVAL;
 
        if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
-           !(scp->sc_fs == GSEL(GUFS_SEL, SEL_UPL) && pcb->pcb_fs != 0))
+           !(VALID_USER_FSEL32(scp->sc_fs) && pcb->pcb_fs != 0))
                return EINVAL;
 
        if (scp->sc_gs != 0 && !VALID_USER_DSEL32(scp->sc_gs) &&
-           !(scp->sc_gs == GSEL(GUGS_SEL, SEL_UPL) && pcb->pcb_gs != 0))
+           !(VALID_USER_GSEL32(scp->sc_gs) && pcb->pcb_gs != 0))
                return EINVAL;
 
        if (scp->sc_es != 0 && !VALID_USER_DSEL32(scp->sc_es))



Home | Main Index | Thread Index | Old Index