Module Name:    src
Committed By:   christos
Date:           Thu Jun 27 02:00:31 UTC 2019

Modified Files:
        src/sys/arch/amd64/amd64: machdep.c

Log Message:
Although this is correct, I will let maxv commit it. Still waiting.


To generate a diff of this commit:
cvs rdiff -u -r1.333 -r1.334 src/sys/arch/amd64/amd64/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/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.333 src/sys/arch/amd64/amd64/machdep.c:1.334
--- src/sys/arch/amd64/amd64/machdep.c:1.333	Wed Jun 26 21:59:30 2019
+++ src/sys/arch/amd64/amd64/machdep.c	Wed Jun 26 22:00:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.333 2019/06/27 01:59:30 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.334 2019/06/27 02:00:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.333 2019/06/27 01:59:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.334 2019/06/27 02:00:30 christos Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -2095,50 +2095,44 @@ cpu_setmcontext(struct lwp *l, const mco
 int
 cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
 {
-	struct proc *p = l->l_proc;
+	struct proc *p __diagused = l->l_proc;
 	struct trapframe *tf = l->l_md.md_regs;
 	const __greg_t *gr;
 	uint16_t sel;
-	const bool pk32 = (p->p_flag & PK_32) != 0;
 
+	KASSERT((p->p_flag & PK_32) == 0);
 	gr = mcp->__gregs;
 
 	if (((gr[_REG_RFLAGS] ^ tf->tf_rflags) & PSL_USERSTATIC) != 0)
 		return EINVAL;
-#define VUD(sel) (pk32 ? VALID_USER_DSEL32(sel) : VALID_USER_DSEL(sel))
-#define VUF(sel) (pk32 ? (VALID_USER_DSEL32(sel) || VALID_USER_FSEL32(sel)) \
-    : VALID_USER_DSEL(sel))
-#define VUG(sel) (pk32 ? (VALID_USER_DSEL32(sel) || VALID_USER_GSEL32(sel)) \
-    : VALID_USER_DSEL(sel))
-#define VUC(sel) (pk32 ? VALID_USER_CSEL32(sel) : VALID_USER_CSEL(sel))
 
 	sel = gr[_REG_ES] & 0xffff;
-	if (sel != 0 && !VUD(sel))
+	if (sel != 0 && !VALID_USER_DSEL(sel))
 		return EINVAL;
 
 	sel = gr[_REG_FS] & 0xffff;
-	if (sel != 0 && !VUF(sel))
+	if (sel != 0 && !VALID_USER_DSEL(sel))
 		return EINVAL;
 
 	sel = gr[_REG_GS] & 0xffff;
-	if (sel != 0 && !VUG(sel))
+	if (sel != 0 && !VALID_USER_DSEL(sel))
 		return EINVAL;
 
 	sel = gr[_REG_DS] & 0xffff;
-	if (!VUD(sel))
+	if (!VALID_USER_DSEL(sel))
 		return EINVAL;
 
 #ifndef XENPV
 	sel = gr[_REG_SS] & 0xffff;
-	if (!VUD(sel))
+	if (!VALID_USER_DSEL(sel))
 		return EINVAL;
 
 	sel = gr[_REG_CS] & 0xffff;
-	if (!VUC(sel))
+	if (!VALID_USER_CSEL(sel))
 		return EINVAL;
 #endif
 
-	if (gr[_REG_RIP] >= (pk32 ? VM_MAXUSER_ADDRESS32 : VM_MAXUSER_ADDRESS))
+	if (gr[_REG_RIP] >= VM_MAXUSER_ADDRESS)
 		return EINVAL;
 
 	return 0;

Reply via email to