Module Name:    src
Committed By:   christos
Date:           Thu Jun 27 01:59:30 UTC 2019

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

Log Message:
don't cast void *


To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/amd64/amd64/process_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.332 src/sys/arch/amd64/amd64/machdep.c:1.333
--- src/sys/arch/amd64/amd64/machdep.c:1.332	Wed Jun 12 10:28:38 2019
+++ src/sys/arch/amd64/amd64/machdep.c	Wed Jun 26 21:59:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.332 2019/06/12 14:28:38 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.333 2019/06/27 01:59: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.332 2019/06/12 14:28:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.333 2019/06/27 01:59:30 christos Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -2095,44 +2095,50 @@ cpu_setmcontext(struct lwp *l, const mco
 int
 cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
 {
-	struct proc *p __diagused = l->l_proc;
+	struct proc *p = 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 && !VALID_USER_DSEL(sel))
+	if (sel != 0 && !VUD(sel))
 		return EINVAL;
 
 	sel = gr[_REG_FS] & 0xffff;
-	if (sel != 0 && !VALID_USER_DSEL(sel))
+	if (sel != 0 && !VUF(sel))
 		return EINVAL;
 
 	sel = gr[_REG_GS] & 0xffff;
-	if (sel != 0 && !VALID_USER_DSEL(sel))
+	if (sel != 0 && !VUG(sel))
 		return EINVAL;
 
 	sel = gr[_REG_DS] & 0xffff;
-	if (!VALID_USER_DSEL(sel))
+	if (!VUD(sel))
 		return EINVAL;
 
 #ifndef XENPV
 	sel = gr[_REG_SS] & 0xffff;
-	if (!VALID_USER_DSEL(sel))
+	if (!VUD(sel))
 		return EINVAL;
 
 	sel = gr[_REG_CS] & 0xffff;
-	if (!VALID_USER_CSEL(sel))
+	if (!VUC(sel))
 		return EINVAL;
 #endif
 
-	if (gr[_REG_RIP] >= VM_MAXUSER_ADDRESS)
+	if (gr[_REG_RIP] >= (pk32 ? VM_MAXUSER_ADDRESS32 : VM_MAXUSER_ADDRESS))
 		return EINVAL;
 
 	return 0;

Index: src/sys/arch/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.40 src/sys/arch/amd64/amd64/process_machdep.c:1.41
--- src/sys/arch/amd64/amd64/process_machdep.c:1.40	Wed Jun 26 08:30:12 2019
+++ src/sys/arch/amd64/amd64/process_machdep.c	Wed Jun 26 21:59:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.40 2019/06/26 12:30:12 mgorny Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.41 2019/06/27 01:59:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.40 2019/06/26 12:30:12 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.41 2019/06/27 01:59:30 christos Exp $");
 
 #include "opt_xen.h"
 #include <sys/param.h>
@@ -339,8 +339,7 @@ ptrace_machdep_dorequest(
 		if (!process_machdep_validxstate(lt->l_proc))
 			return EINVAL;
 		if (__predict_false(l->l_proc->p_flag & PK_32)) {
-			struct netbsd32_iovec *user_iov;
-			user_iov = (struct netbsd32_iovec*)addr;
+			struct netbsd32_iovec *user_iov = addr;
 			iov.iov_base = NETBSD32PTR64(user_iov->iov_base);
 			iov.iov_len = user_iov->iov_len;
 		} else {

Reply via email to