Module Name: src
Committed By: chs
Date: Mon Feb 7 03:54:46 UTC 2011
Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep.c
src/sys/arch/amd64/include: segments.h
src/sys/compat/linux32/arch/amd64: linux32_machdep.c
Log Message:
move macros for validating fs/gs to segments.h and use them
in the linux32 code as well.
To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/amd64/amd64/netbsd32_machdep.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/include/segments.h
cvs rdiff -u -r1.27 -r1.28 \
src/sys/compat/linux32/arch/amd64/linux32_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.69 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.70
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.69 Wed Jan 26 21:44:31 2011
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Feb 7 03:54:45 2011
@@ -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;
Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.21 src/sys/arch/amd64/include/segments.h:1.22
--- src/sys/arch/amd64/include/segments.h:1.21 Sun Sep 5 20:14:40 2010
+++ src/sys/arch/amd64/include/segments.h Mon Feb 7 03:54:45 2011
@@ -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))
Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c
diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.27 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.28
--- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.27 Tue Nov 2 18:14:06 2010
+++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Mon Feb 7 03:54:45 2011
@@ -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))