Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64 memseg_baseaddr() is only called from valid_u...



details:   https://anonhg.NetBSD.org/src/rev/e40da3fff185
branches:  trunk
changeset: 779765:e40da3fff185
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sat Jun 16 20:47:04 2012 +0000

description:
memseg_baseaddr() is only called from valid_user_selector() and
both only locally.
Make static, remove one of the functions, and remove the never-set args.
Code is still very dubious.

diffstat:

 sys/arch/amd64/amd64/machdep.c    |  42 ++++++++++++--------------------------
 sys/arch/amd64/include/segments.h |   4 +--
 2 files changed, 14 insertions(+), 32 deletions(-)

diffs (134 lines):

diff -r b4a6deb2b8d9 -r e40da3fff185 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sat Jun 16 19:54:01 2012 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sat Jun 16 20:47:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $      */
+/*     $NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -332,6 +332,8 @@
 
 void   init_x86_64(paddr_t);
 
+static int valid_user_selector(struct lwp *, uint64_t);
+
 /*
  * Machine-dependent startup code
  */
@@ -2093,28 +2095,28 @@
                return EINVAL;
 
        if (__predict_false(pmap->pm_ldt != NULL)) {
-               error = valid_user_selector(l, gr[_REG_ES], NULL, 0);
+               error = valid_user_selector(l, gr[_REG_ES]);
                if (error != 0)
                        return error;
 
-               error = valid_user_selector(l, gr[_REG_FS], NULL, 0);
+               error = valid_user_selector(l, gr[_REG_FS]);
                if (error != 0)
                        return error;
 
-               error = valid_user_selector(l, gr[_REG_GS], NULL, 0);
+               error = valid_user_selector(l, gr[_REG_GS]);
                if (error != 0)
                        return error;
 
                if ((gr[_REG_DS] & 0xffff) == 0)
                        return EINVAL;
-               error = valid_user_selector(l, gr[_REG_DS], NULL, 0);
+               error = valid_user_selector(l, gr[_REG_DS]);
                if (error != 0)
                        return error;
 
 #ifndef XEN
                if ((gr[_REG_SS] & 0xffff) == 0)
                        return EINVAL;
-               error = valid_user_selector(l, gr[_REG_SS], NULL, 0);
+               error = valid_user_selector(l, gr[_REG_SS]);
                if (error != 0)
                        return error;
 #endif
@@ -2169,9 +2171,8 @@
        (*initclock_func)();
 }
 
-int
-memseg_baseaddr(struct lwp *l, uint64_t seg, char *ldtp, int llen,
-               uint64_t *addr)
+static int
+valid_user_selector(struct lwp *l, uint64_t seg)
 {
        int off, len;
        char *dt;
@@ -2182,18 +2183,12 @@
 
        seg &= 0xffff;
 
-       if (seg == 0) {
-               if (addr != NULL)
-                       *addr = 0;
+       if (seg == 0)
                return 0;
-       }
 
        off = (seg & 0xfff8);
        if (seg & SEL_LDT) {
-               if (ldtp != NULL) {
-                       dt = ldtp;
-                       len = llen;
-               } else if (pmap->pm_ldt != NULL) {
+               if (pmap->pm_ldt != NULL) {
                        len = pmap->pm_ldt_len; /* XXX broken */
                        dt = (char *)pmap->pm_ldt;
                } else {
@@ -2220,21 +2215,10 @@
        if (base >= VM_MAXUSER_ADDRESS)
                return EINVAL;
 
-       if (addr == NULL)
-               return 0;
-
-       *addr = base;
-
        return 0;
 }
 
 int
-valid_user_selector(struct lwp *l, uint64_t seg, char *ldtp, int len)
-{
-       return memseg_baseaddr(l, seg, ldtp, len, NULL);
-}
-
-int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
        extern int start, __data_start;
diff -r b4a6deb2b8d9 -r e40da3fff185 sys/arch/amd64/include/segments.h
--- a/sys/arch/amd64/include/segments.h Sat Jun 16 19:54:01 2012 +0000
+++ b/sys/arch/amd64/include/segments.h Sat Jun 16 20:47:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: segments.h,v 1.22 2011/02/07 03:54:45 chs Exp $        */
+/*     $NetBSD: segments.h,v 1.23 2012/06/16 20:47:04 dsl Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -256,8 +256,6 @@
 #endif
 
 struct lwp;
-int memseg_baseaddr(struct lwp *, uint64_t, char *, int, uint64_t *);
-int valid_user_selector(struct lwp *, uint64_t, char *, int);
 void cpu_fsgs_zero(struct lwp *);
 void cpu_fsgs_reload(struct lwp *, int, int);
 



Home | Main Index | Thread Index | Old Index