Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Declare IOMAP_VALIDOFF, not to use ci_tss pointers.



details:   https://anonhg.NetBSD.org/src/rev/c08b93ea29a6
branches:  trunk
changeset: 358507:c08b93ea29a6
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Jan 04 14:02:23 2018 +0000

description:
Declare IOMAP_VALIDOFF, not to use ci_tss pointers.

diffstat:

 sys/arch/amd64/include/tss.h   |   7 ++++++-
 sys/arch/i386/i386/genassym.cf |   3 ++-
 sys/arch/i386/i386/locore.S    |   6 +++---
 sys/arch/i386/include/tss.h    |   7 ++++++-
 sys/arch/x86/x86/sys_machdep.c |  10 ++++++----
 5 files changed, 23 insertions(+), 10 deletions(-)

diffs (118 lines):

diff -r c8140f524477 -r c08b93ea29a6 sys/arch/amd64/include/tss.h
--- a/sys/arch/amd64/include/tss.h      Thu Jan 04 13:36:30 2018 +0000
+++ b/sys/arch/amd64/include/tss.h      Thu Jan 04 14:02:23 2018 +0000
@@ -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 @@
  */
 #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>
diff -r c8140f524477 -r c08b93ea29a6 sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf    Thu Jan 04 13:36:30 2018 +0000
+++ b/sys/arch/i386/i386/genassym.cf    Thu Jan 04 14:02:23 2018 +0000
@@ -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_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)
diff -r c8140f524477 -r c08b93ea29a6 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Thu Jan 04 13:36:30 2018 +0000
+++ b/sys/arch/i386/i386/locore.S       Thu Jan 04 14:02:23 2018 +0000
@@ -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 @@
        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)
 
diff -r c8140f524477 -r c08b93ea29a6 sys/arch/i386/include/tss.h
--- a/sys/arch/i386/include/tss.h       Thu Jan 04 13:36:30 2018 +0000
+++ b/sys/arch/i386/include/tss.h       Thu Jan 04 14:02:23 2018 +0000
@@ -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 @@
  */
 #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_ */
diff -r c8140f524477 -r c08b93ea29a6 sys/arch/x86/x86/sys_machdep.c
--- a/sys/arch/x86/x86/sys_machdep.c    Thu Jan 04 13:36:30 2018 +0000
+++ b/sys/arch/x86/x86/sys_machdep.c    Thu Jan 04 14:02:23 2018 +0000
@@ -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 @@
                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;



Home | Main Index | Thread Index | Old Index