Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Initialize ist0 in cpu_init_tss. On amd64 this is t...



details:   https://anonhg.NetBSD.org/src/rev/69e2aa0b7ec5
branches:  trunk
changeset: 828951:69e2aa0b7ec5
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Jan 11 10:30:26 2018 +0000

description:
Initialize ist0 in cpu_init_tss. On amd64 this is the DDB stack, and it has
nothing to do with ci_intrstack. While here, style, and don't forget to
pass UVM_KMF_ZERO in uvm_km_alloc.

diffstat:

 sys/arch/amd64/amd64/machdep.c |  13 ++++++++-----
 sys/arch/amd64/include/param.h |   3 +--
 sys/arch/x86/x86/intr.c        |  37 ++++++++++++++++++-------------------
 3 files changed, 27 insertions(+), 26 deletions(-)

diffs (192 lines):

diff -r e03984964e1d -r 69e2aa0b7ec5 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Thu Jan 11 09:53:55 2018 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Thu Jan 11 10:30:26 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.286 2018/01/11 09:00:04 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.287 2018/01/11 10:30:26 maxv 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.286 2018/01/11 09:00:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.287 2018/01/11 10:30:26 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -520,13 +520,16 @@
 #endif
 
        cputss->tss.tss_iobase = IOMAP_INVALOFF << 16;
-       /* cputss->tss.tss_ist[0] is filled by cpu_intr_init */
+
+       /* DDB stack */
+       p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
+       cputss->tss.tss_ist[0] = p + PAGE_SIZE - 16;
 
        /* double fault */
 #ifdef __HAVE_PCPU_AREA
        p = (vaddr_t)&pcpuarea->ent[cid].ist1;
 #else
-       p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
+       p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
 #endif
        cputss->tss.tss_ist[1] = p + PAGE_SIZE - 16;
 
@@ -534,7 +537,7 @@
 #ifdef __HAVE_PCPU_AREA
        p = (vaddr_t)&pcpuarea->ent[cid].ist2;
 #else
-       p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
+       p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
 #endif
        cputss->tss.tss_ist[2] = p + PAGE_SIZE - 16;
 
diff -r e03984964e1d -r 69e2aa0b7ec5 sys/arch/amd64/include/param.h
--- a/sys/arch/amd64/include/param.h    Thu Jan 11 09:53:55 2018 +0000
+++ b/sys/arch/amd64/include/param.h    Thu Jan 11 10:30:26 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.22 2017/06/14 12:27:24 maxv Exp $  */
+/*     $NetBSD: param.h,v 1.23 2018/01/11 10:30:26 maxv Exp $  */
 
 #ifdef __x86_64__
 
@@ -63,7 +63,6 @@
 #define        UPAGES          3               /* pages of u-area */
 #endif
 #define        USPACE          (UPAGES * NBPG) /* total size of u-area */
-#define        INTRSTACKSIZE   4096
 
 #ifndef MSGBUFSIZE
 #define MSGBUFSIZE     (8*NBPG)        /* default message buffer size */
diff -r e03984964e1d -r 69e2aa0b7ec5 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Thu Jan 11 09:53:55 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Thu Jan 11 10:30:26 2018 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: intr.c,v 1.116 2018/01/04 13:36:30 maxv Exp $  */
+/*     $NetBSD: intr.c,v 1.117 2018/01/11 10:30:26 maxv Exp $  */
 
-/*-
+/*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.116 2018/01/04 13:36:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.117 2018/01/11 10:30:26 maxv Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -168,7 +168,7 @@
 #include "acpica.h"
 
 #if NIOAPIC > 0 || NACPICA > 0
-#include <machine/i82093var.h> 
+#include <machine/i82093var.h>
 #include <machine/mpbiosvar.h>
 #include <machine/mpacpi.h>
 #endif
@@ -372,7 +372,7 @@
 
 /*
  * List to keep track of PCI buses that are probed but not known
- * to the firmware. Used to 
+ * to the firmware. Used to
  *
  * XXX should maintain one list, not an array and a linked list.
  */
@@ -791,7 +791,7 @@
        }
        KASSERT(ci != NULL);
 
-       /* 
+       /*
         * Now allocate an IDT vector.
         * For the 8259 these are reserved up front.
         */
@@ -1034,7 +1034,7 @@
                /* NOTREACHED */
        }
 
-        /*
+       /*
         * If the establishing interrupt uses shared IRQ, the interrupt uses
         * "ci->ci_isources[slot]" instead of allocated by the establishing
         * device's pci_intr_alloc() or this function.
@@ -1149,7 +1149,7 @@
        source = ci->ci_isources[ih->ih_slot];
        idtvec = source->is_idtvec;
 
-       (*pic->pic_hwmask)(pic, ih->ih_pin);    
+       (*pic->pic_hwmask)(pic, ih->ih_pin);
        atomic_and_32(&ci->ci_ipending, ~(1 << ih->ih_slot));
 
        /*
@@ -1457,9 +1457,6 @@
        int i;
        static int first = 1;
 #endif
-#ifdef INTRSTACKSIZE
-       vaddr_t istack;
-#endif
 
 #if NLAPIC > 0
        isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
@@ -1504,34 +1501,36 @@
 #else /* XEN */
        int i; /* XXX: duplicate */
        vaddr_t istack; /* XXX: duplicate */
-               ci->ci_iunmask[0] = 0xfffffffe;
+       ci->ci_iunmask[0] = 0xfffffffe;
        for (i = 1; i < NIPL; i++)
                ci->ci_iunmask[i] = ci->ci_iunmask[i - 1] & ~(1 << i);
 #endif /* XEN */
 
 #if defined(INTRSTACKSIZE)
+       vaddr_t istack;
+
        /*
         * If the red zone is activated, protect both the top and
         * the bottom of the stack with an unmapped page.
         */
        istack = uvm_km_alloc(kernel_map,
            INTRSTACKSIZE + redzone_const_or_zero(2 * PAGE_SIZE), 0,
-           UVM_KMF_WIRED);
+           UVM_KMF_WIRED|UVM_KMF_ZERO);
        if (redzone_const_or_false(true)) {
                pmap_kremove(istack, PAGE_SIZE);
                pmap_kremove(istack + INTRSTACKSIZE + PAGE_SIZE, PAGE_SIZE);
                pmap_update(pmap_kernel());
        }
-       /* 33 used to be 1.  Arbitrarily reserve 32 more register_t's
+
+       /*
+        * 33 used to be 1.  Arbitrarily reserve 32 more register_t's
         * of space for ddb(4) to examine some subroutine arguments
         * and to hunt for the next stack frame.
         */
        ci->ci_intrstack = (char *)istack + redzone_const_or_zero(PAGE_SIZE) +
            INTRSTACKSIZE - 33 * sizeof(register_t);
-#if defined(__x86_64__)
-       ci->ci_tss->tss.tss_ist[0] = (uintptr_t)ci->ci_intrstack & ~0xf;
-#endif /* defined(__x86_64__) */
-#endif /* defined(INTRSTACKSIZE) */
+#endif
+
        ci->ci_idepth = -1;
 }
 
@@ -1826,7 +1825,7 @@
        where = xc_unicast(0, intr_redistribute_xc_t, isp,
            (void *)(intptr_t)nslot, nci);
        xc_wait(where);
-       
+
        /*
         * We're ready to go on the target CPU.  Run a cross call to
         * reroute the interrupt away from the source CPU.



Home | Main Index | Thread Index | Old Index