Module Name: src
Committed By: riz
Date: Mon May 7 15:58:04 UTC 2012
Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6]: machdep.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #212):
sys/arch/amd64/amd64/machdep.c: revision 1.181
Fix check_mcontext for PK_32 binaries. Makes gdb work for i386 binaries on
amd64.
To generate a diff of this commit:
cvs rdiff -u -r1.175.2.3 -r1.175.2.4 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.175.2.3 src/sys/arch/amd64/amd64/machdep.c:1.175.2.4
--- src/sys/arch/amd64/amd64/machdep.c:1.175.2.3 Thu Mar 22 22:50:48 2012
+++ src/sys/arch/amd64/amd64/machdep.c Mon May 7 15:58:04 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.175.2.3 2012/03/22 22:50:48 riz Exp $ */
+/* $NetBSD: machdep.c,v 1.175.2.4 2012/05/07 15:58:04 riz 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.175.2.3 2012/03/22 22:50:48 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.4 2012/05/07 15:58:04 riz Exp $");
/* #define XENDEBUG_LOW */
@@ -2111,6 +2111,7 @@ check_mcontext(struct lwp *l, const mcon
uint16_t sel;
int error;
struct pmap *pmap = l->l_proc->p_vmspace->vm_map.pmap;
+ struct proc *p = l->l_proc;
gr = mcp->__gregs;
@@ -2144,33 +2145,42 @@ check_mcontext(struct lwp *l, const mcon
return error;
#endif
} else {
+#define VUD(sel) \
+ ((p->p_flag & PK_32) ? VALID_USER_DSEL32(sel) : VALID_USER_DSEL(sel))
sel = gr[_REG_ES] & 0xffff;
- if (sel != 0 && !VALID_USER_DSEL(sel))
+ if (sel != 0 && !VUD(sel))
return EINVAL;
+/* XXX: Shouldn't this be FSEL32? */
+#define VUF(sel) \
+ ((p->p_flag & PK_32) ? VALID_USER_DSEL32(sel) : VALID_USER_DSEL(sel))
sel = gr[_REG_FS] & 0xffff;
- if (sel != 0 && !VALID_USER_DSEL(sel))
+ if (sel != 0 && !VUF(sel))
return EINVAL;
+#define VUG(sel) \
+ ((p->p_flag & PK_32) ? VALID_USER_GSEL32(sel) : VALID_USER_DSEL(sel))
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 XEN
sel = gr[_REG_SS] & 0xffff;
- if (!VALID_USER_DSEL(sel))
+ if (!VUD(sel))
return EINVAL;
#endif
}
#ifndef XEN
+#define VUC(sel) \
+ ((p->p_flag & PK_32) ? VALID_USER_CSEL32(sel) : VALID_USER_CSEL(sel))
sel = gr[_REG_CS] & 0xffff;
- if (!VALID_USER_CSEL(sel))
+ if (!VUC(sel))
return EINVAL;
#endif