Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/amd64 Now that valid_user_selector only check...



details:   https://anonhg.NetBSD.org/src/rev/d76ab6979105
branches:  trunk
changeset: 351183:d76ab6979105
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Feb 05 08:36:08 2017 +0000

description:
Now that valid_user_selector only checks for LDT selectors, remove it. A
user may legitimately want to have one register in the GDT, and another in
the LDT.

Pass 2/2.

diffstat:

 sys/arch/amd64/amd64/machdep.c |  53 +++--------------------------------------
 1 files changed, 5 insertions(+), 48 deletions(-)

diffs (103 lines):

diff -r 240a6594968a -r d76ab6979105 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sun Feb 05 08:19:05 2017 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sun Feb 05 08:36:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.250 2017/02/05 08:19:05 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.251 2017/02/05 08:36:08 maxv 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.250 2017/02/05 08:19:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.251 2017/02/05 08:36:08 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -320,8 +320,6 @@
 
 void init_x86_64(paddr_t);
 
-static int valid_user_selector(struct lwp *, uint64_t);
-
 /*
  * Machine-dependent startup code
  */
@@ -1902,12 +1900,11 @@
 int
 cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
 {
-       const __greg_t *gr;
-       uint16_t sel;
-       int error;
        struct pmap *pmap = l->l_proc->p_vmspace->vm_map.pmap;
        struct proc *p = l->l_proc;
        struct trapframe *tf = l->l_md.md_regs;
+       const __greg_t *gr;
+       uint16_t sel;
 
        gr = mcp->__gregs;
 
@@ -1915,31 +1912,12 @@
                return EINVAL;
 
        if (__predict_false(pmap->pm_ldt != NULL)) {
-               error = valid_user_selector(l, gr[_REG_ES]);
-               if (error != 0)
-                       return error;
-
-               error = valid_user_selector(l, gr[_REG_FS]);
-               if (error != 0)
-                       return error;
-
-               error = valid_user_selector(l, gr[_REG_GS]);
-               if (error != 0)
-                       return error;
-
+               /* Only when the LDT is user-set (with USER_LDT) */
                if ((gr[_REG_DS] & 0xffff) == 0)
                        return EINVAL;
-               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]);
-               if (error != 0)
-                       return error;
-
                if (!USERMODE(gr[_REG_CS], gr[_REG_RFLAGS]))
                        return EINVAL;
 #endif
@@ -1991,27 +1969,6 @@
        (*initclock_func)();
 }
 
-/*
- * Called only when the LDT is user-set (USER_LDT).
- */
-static int
-valid_user_selector(struct lwp *l, uint64_t seg)
-{
-       seg &= 0xffff;
-       if (seg == 0)
-               return 0;
-
-       if (!(seg & SEL_LDT)) {
-               CTASSERT(GUDATA_SEL & SEL_LDT);
-               KASSERT(seg != GUDATA_SEL);
-               CTASSERT(GUDATA32_SEL & SEL_LDT);
-               KASSERT(seg != GUDATA32_SEL);
-               return EINVAL;
-       }
-
-       return 0;
-}
-
 int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {



Home | Main Index | Thread Index | Old Index