Module Name:    src
Committed By:   maxv
Date:           Thu Jan  4 14:02:24 UTC 2018

Modified Files:
        src/sys/arch/amd64/include: tss.h
        src/sys/arch/i386/i386: genassym.cf locore.S
        src/sys/arch/i386/include: tss.h
        src/sys/arch/x86/x86: sys_machdep.c

Log Message:
Declare IOMAP_VALIDOFF, not to use ci_tss pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/include/tss.h
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.155 -r1.156 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/include/tss.h
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/x86/sys_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/include/tss.h
diff -u src/sys/arch/amd64/include/tss.h:1.6 src/sys/arch/amd64/include/tss.h:1.7
--- src/sys/arch/amd64/include/tss.h:1.6	Wed Jul 12 17:52:18 2017
+++ src/sys/arch/amd64/include/tss.h	Thu Jan  4 14:02:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tss.h,v 1.6 2017/07/12 17:52:18 maxv Exp $	*/
+/*	$NetBSD: tss.h,v 1.7 2018/01/04 14:02:23 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -65,6 +65,11 @@ struct x86_64_tss {
  */
 #define	IOMAP_INVALOFF	0xffff
 
+/*
+ * If we have an I/O bitmap, there is only one valid offset.
+ */
+#define	IOMAP_VALIDOFF	sizeof(struct x86_64_tss)
+
 #else	/*	__x86_64__	*/
 
 #include <i386/tss.h>

Index: src/sys/arch/i386/i386/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.106 src/sys/arch/i386/i386/genassym.cf:1.107
--- src/sys/arch/i386/i386/genassym.cf:1.106	Thu Jan  4 13:36:30 2018
+++ src/sys/arch/i386/i386/genassym.cf	Thu Jan  4 14:02:23 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.106 2018/01/04 13:36:30 maxv Exp $
+#	$NetBSD: genassym.cf,v 1.107 2018/01/04 14:02:23 maxv Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -256,6 +256,7 @@ define	CPU_INFO_IDLELWP	offsetof(struct 
 define	CPU_INFO_PMAP		offsetof(struct cpu_info, ci_pmap)
 define	CPU_INFO_TSS		offsetof(struct cpu_info, ci_tss)
 define	IOMAP_INVALOFF		IOMAP_INVALOFF
+define	IOMAP_VALIDOFF		IOMAP_VALIDOFF
 define	CPU_INFO_NSYSCALL	offsetof(struct cpu_info, ci_data.cpu_nsyscall)
 define	CPU_INFO_NTRAP		offsetof(struct cpu_info, ci_data.cpu_ntrap)
 define	CPU_INFO_NINTR		offsetof(struct cpu_info, ci_data.cpu_nintr)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.155 src/sys/arch/i386/i386/locore.S:1.156
--- src/sys/arch/i386/i386/locore.S:1.155	Thu Jan  4 13:36:30 2018
+++ src/sys/arch/i386/i386/locore.S	Thu Jan  4 14:02:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.155 2018/01/04 13:36:30 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.156 2018/01/04 14:02:23 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.155 2018/01/04 13:36:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.156 2018/01/04 14:02:23 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1209,7 +1209,7 @@ switch_return:
 	popl	%edi
 	popl	%esi
 	movl	CPUVAR(TSS),%eax
-	movl	$((TSS_IOMAP - TSS_TSS) << 16),TSS_IOBASE(%eax)
+	movl	$(IOMAP_VALIDOFF << 16),TSS_IOBASE(%eax)
 	jmp	.Liobitmap_done
 END(cpu_switchto)
 

Index: src/sys/arch/i386/include/tss.h
diff -u src/sys/arch/i386/include/tss.h:1.10 src/sys/arch/i386/include/tss.h:1.11
--- src/sys/arch/i386/include/tss.h:1.10	Sat Jan  5 21:45:00 2008
+++ src/sys/arch/i386/include/tss.h	Thu Jan  4 14:02:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tss.h,v 1.10 2008/01/05 21:45:00 yamt Exp $	*/
+/*	$NetBSD: tss.h,v 1.11 2018/01/04 14:02:23 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -76,4 +76,9 @@ struct i386tss {
  */
 #define	IOMAP_INVALOFF	0xffff
 
+/*
+ * If we have an I/O bitmap, there is only one valid offset.
+ */
+#define	IOMAP_VALIDOFF	sizeof(struct i386tss)
+
 #endif /* #ifndef _I386_TSS_H_ */

Index: src/sys/arch/x86/x86/sys_machdep.c
diff -u src/sys/arch/x86/x86/sys_machdep.c:1.45 src/sys/arch/x86/x86/sys_machdep.c:1.46
--- src/sys/arch/x86/x86/sys_machdep.c:1.45	Thu Jan  4 13:36:30 2018
+++ src/sys/arch/x86/x86/sys_machdep.c	Thu Jan  4 14:02:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_machdep.c,v 1.45 2018/01/04 13:36:30 maxv Exp $	*/
+/*	$NetBSD: sys_machdep.c,v 1.46 2018/01/04 14:02:23 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2009, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.45 2018/01/04 13:36:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.46 2018/01/04 14:02:23 maxv Exp $");
 
 #include "opt_mtrr.h"
 #include "opt_pmc.h"
@@ -480,11 +480,13 @@ x86_set_ioperm(struct lwp *l, void *args
 		kmem_free(old, IOMAPSIZE);
 	}
 
+	CTASSERT(offsetof(struct cpu_tss, iomap) -
+	    offsetof(struct cpu_tss, tss) == IOMAP_VALIDOFF);
+
 	kpreempt_disable();
 	ci = curcpu();
 	memcpy(ci->ci_tss->iomap, pcb->pcb_iomap, IOMAPSIZE);
-	ci->ci_tss->tss.tss_iobase =
-	    ((uintptr_t)&ci->ci_tss->iomap - (uintptr_t)&ci->ci_tss->tss) << 16;
+	ci->ci_tss->tss.tss_iobase = IOMAP_VALIDOFF << 16;
 	kpreempt_enable();
 
 	return error;

Reply via email to