Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/arch Pull up following revision(s) (requested by maxv...



details:   https://anonhg.NetBSD.org/src/rev/518953f1a807
branches:  netbsd-8
changeset: 434716:518953f1a807
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 08 11:33:15 2018 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #611):
        sys/arch/x86/x86/cpu.c: revision 1.134 (patch)
        sys/arch/x86/include/cpu.h: revision 1.78 (patch)
        sys/arch/i386/i386/machdep.c: revision 1.792 (patch)

style, and move some i386-specific code into i386/

diffstat:

 sys/arch/i386/i386/machdep.c |  78 ++++++++++++++++++++++++++++++++-
 sys/arch/x86/include/cpu.h   |  10 ++--
 sys/arch/x86/x86/cpu.c       |  99 +++++--------------------------------------
 3 files changed, 91 insertions(+), 96 deletions(-)

diffs (truncated from 338 to 300 lines):

diff -r 209e7d8a3c33 -r 518953f1a807 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Wed Mar 07 14:55:49 2018 +0000
+++ b/sys/arch/i386/i386/machdep.c      Thu Mar 08 11:33:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.782.6.2 2018/01/01 19:09:03 snj Exp $    */
+/*     $NetBSD: machdep.c,v 1.782.6.3 2018/03/08 11:33:15 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.782.6.2 2018/01/01 19:09:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.782.6.3 2018/03/08 11:33:15 martin Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -578,7 +578,78 @@
 }
 #endif /* XEN */
 
+/* XXX */
+#define IDTVEC(name)   __CONCAT(X, name)
+typedef void (vector)(void);
+
 #ifndef XEN
+static void    tss_init(struct i386tss *, void *, void *);
+
+static void
+tss_init(struct i386tss *tss, void *stack, void *func)
+{
+       KASSERT(curcpu()->ci_pmap == pmap_kernel());
+
+       memset(tss, 0, sizeof *tss);
+       tss->tss_esp0 = tss->tss_esp = (int)((char *)stack + USPACE - 16);
+       tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
+       tss->__tss_cs = GSEL(GCODE_SEL, SEL_KPL);
+       tss->tss_fs = GSEL(GCPU_SEL, SEL_KPL);
+       tss->tss_gs = tss->__tss_es = tss->__tss_ds =
+           tss->__tss_ss = GSEL(GDATA_SEL, SEL_KPL);
+       /* %cr3 contains the value associated to pmap_kernel */
+       tss->tss_cr3 = rcr3();
+       tss->tss_esp = (int)((char *)stack + USPACE - 16);
+       tss->tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
+       tss->__tss_eflags = PSL_MBO | PSL_NT;   /* XXX not needed? */
+       tss->__tss_eip = (int)func;
+}
+
+extern vector IDTVEC(tss_trap08);
+#if defined(DDB) && defined(MULTIPROCESSOR)
+extern vector Xintrddbipi, Xx2apic_intrddbipi;
+extern int ddb_vec;
+#endif
+
+void
+cpu_set_tss_gates(struct cpu_info *ci)
+{
+       struct segment_descriptor sd;
+
+       ci->ci_doubleflt_stack = (char *)uvm_km_alloc(kernel_map, USPACE, 0,
+           UVM_KMF_WIRED);
+
+       tss_init(&ci->ci_doubleflt_tss, ci->ci_doubleflt_stack,
+           IDTVEC(tss_trap08));
+       setsegment(&sd, &ci->ci_doubleflt_tss, sizeof(struct i386tss) - 1,
+           SDT_SYS386TSS, SEL_KPL, 0, 0);
+       ci->ci_gdt[GTRAPTSS_SEL].sd = sd;
+
+       setgate(&idt[8], NULL, 0, SDT_SYSTASKGT, SEL_KPL,
+           GSEL(GTRAPTSS_SEL, SEL_KPL));
+
+#if defined(DDB) && defined(MULTIPROCESSOR)
+       /*
+        * Set up separate handler for the DDB IPI, so that it doesn't
+        * stomp on a possibly corrupted stack.
+        *
+        * XXX overwriting the gate set in db_machine_init.
+        * Should rearrange the code so that it's set only once.
+        */
+       ci->ci_ddbipi_stack = (char *)uvm_km_alloc(kernel_map, USPACE, 0,
+           UVM_KMF_WIRED);
+       tss_init(&ci->ci_ddbipi_tss, ci->ci_ddbipi_stack,
+           x2apic_mode ? Xx2apic_intrddbipi : Xintrddbipi);
+
+       setsegment(&sd, &ci->ci_ddbipi_tss, sizeof(struct i386tss) - 1,
+           SDT_SYS386TSS, SEL_KPL, 0, 0);
+       ci->ci_gdt[GIPITSS_SEL].sd = sd;
+
+       setgate(&idt[ddb_vec], NULL, 0, SDT_SYSTASKGT, SEL_KPL,
+           GSEL(GIPITSS_SEL, SEL_KPL));
+#endif
+}
+
 /*
  * Set up TSS and I/O bitmap.
  */
@@ -930,8 +1001,7 @@
        sd->sd_hibase = (int)base >> 24;
 }
 
-#define        IDTVEC(name)    __CONCAT(X, name)
-typedef void (vector)(void);
+/* XXX */
 extern vector IDTVEC(syscall);
 extern vector *IDTVEC(exceptions)[];
 extern vector IDTVEC(svr4_fasttrap);
diff -r 209e7d8a3c33 -r 518953f1a807 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Wed Mar 07 14:55:49 2018 +0000
+++ b/sys/arch/x86/include/cpu.h        Thu Mar 08 11:33:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.71 2017/05/23 08:48:34 nonaka Exp $  */
+/*     $NetBSD: cpu.h,v 1.71.2.1 2018/03/08 11:33:15 martin Exp $      */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -406,6 +406,9 @@
 #define        cpu_idle() (*x86_cpu_idle)()
 
 /* machdep.c */
+#ifdef i386
+void   cpu_set_tss_gates(struct cpu_info *);
+#endif
 void   dumpconf(void);
 void   cpu_reset(void);
 void   i386_proc0_tss_ldt_init(void);
@@ -438,9 +441,6 @@
 /* cpu_topology.c */
 void   x86_cpu_topology(struct cpu_info *);
 
-/* vm_machdep.c */
-void   cpu_proc_fork(struct proc *, struct proc *);
-
 /* locore.s */
 struct region_descriptor;
 void   lgdt(struct region_descriptor *);
@@ -467,10 +467,10 @@
 #endif
 
 /* cpu.c */
-
 void   cpu_probe_features(struct cpu_info *);
 
 /* vm_machdep.c */
+void   cpu_proc_fork(struct proc *, struct proc *);
 paddr_t        kvtop(void *);
 
 #ifdef USER_LDT
diff -r 209e7d8a3c33 -r 518953f1a807 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Wed Mar 07 14:55:49 2018 +0000
+++ b/sys/arch/x86/x86/cpu.c    Thu Mar 08 11:33:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.130.2.2 2018/03/07 14:50:57 martin Exp $     */
+/*     $NetBSD: cpu.c,v 1.130.2.3 2018/03/08 11:33:15 martin Exp $     */
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.2 2018/03/07 14:50:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.3 2018/03/08 11:33:15 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -164,15 +164,13 @@
        .ci_curldt = -1,
 #ifdef TRAPLOG
        .ci_tlog_base = &tlog_primary,
-#endif /* !TRAPLOG */
+#endif
 };
 
 struct cpu_info *cpu_info_list = &cpu_info_primary;
 
-static void    cpu_set_tss_gates(struct cpu_info *);
-
 #ifdef i386
-static void    tss_init(struct i386tss *, void *, void *);
+void           cpu_set_tss_gates(struct cpu_info *);
 #endif
 
 static void    cpu_init_idle_lwp(struct cpu_info *);
@@ -187,8 +185,6 @@
                         * [6] structured extended features cpuid.7:%ecx
                         */
 
-extern char x86_64_doubleflt_stack[];
-
 #ifdef MULTIPROCESSOR
 bool x86_mp_online;
 paddr_t mp_trampoline_paddr = MP_TRAMPOLINE;
@@ -395,7 +391,9 @@
                cpu_intr_init(ci);
                cpu_get_tsc_freq(ci);
                cpu_init(ci);
+#ifdef i386
                cpu_set_tss_gates(ci);
+#endif
                pmap_cpu_init_late(ci);
 #if NLAPIC > 0
                if (caa->cpu_role != CPU_ROLE_SP) {
@@ -434,7 +432,9 @@
                 */
                cpu_intr_init(ci);
                gdt_alloc_cpu(ci);
+#ifdef i386
                cpu_set_tss_gates(ci);
+#endif
                pmap_cpu_init_late(ci);
                cpu_start_secondary(ci);
                if (ci->ci_flags & CPUF_PRESENT) {
@@ -501,7 +501,6 @@
        cfaa.ci = ci;
 
        if (ifattr_match(ifattr, "cpufeaturebus")) {
-
                if (ci->ci_frequency == NULL) {
                        cfaa.name = "frequency";
                        ci->ci_frequency = config_found_ia(self,
@@ -808,7 +807,7 @@
        cpu_probe(ci);
 
        ci->ci_data.cpu_cc_freq = cpu_info_primary.ci_data.cpu_cc_freq;
-       /* cpu_get_tsc_freq(ci); */ 
+       /* cpu_get_tsc_freq(ci); */
 
        KDASSERT((ci->ci_flags & CPUF_PRESENT) == 0);
 
@@ -824,7 +823,7 @@
        /*
         * Wait to be brought online.  Use 'monitor/mwait' if available,
         * in order to make the TSC drift as much as possible. so that
-        * we can detect it later.  If not available, try 'pause'. 
+        * we can detect it later.  If not available, try 'pause'.
         * We'd like to use 'hlt', but we have interrupts off.
         */
        while ((ci->ci_flags & CPUF_GO) == 0) {
@@ -933,7 +932,7 @@
         */
        extern u_char cpu_spinup_trampoline[];
        extern u_char cpu_spinup_trampoline_end[];
-       
+
        vaddr_t mp_trampoline_vaddr;
 
        mp_trampoline_vaddr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
@@ -952,80 +951,6 @@
 }
 #endif
 
-#ifdef i386
-static void
-tss_init(struct i386tss *tss, void *stack, void *func)
-{
-       KASSERT(curcpu()->ci_pmap == pmap_kernel());
-
-       memset(tss, 0, sizeof *tss);
-       tss->tss_esp0 = tss->tss_esp = (int)((char *)stack + USPACE - 16);
-       tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
-       tss->__tss_cs = GSEL(GCODE_SEL, SEL_KPL);
-       tss->tss_fs = GSEL(GCPU_SEL, SEL_KPL);
-       tss->tss_gs = tss->__tss_es = tss->__tss_ds =
-           tss->__tss_ss = GSEL(GDATA_SEL, SEL_KPL);
-       /* %cr3 contains the value associated to pmap_kernel */
-       tss->tss_cr3 = rcr3();
-       tss->tss_esp = (int)((char *)stack + USPACE - 16);
-       tss->tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
-       tss->__tss_eflags = PSL_MBO | PSL_NT;   /* XXX not needed? */
-       tss->__tss_eip = (int)func;
-}
-
-/* XXX */
-#define IDTVEC(name)   __CONCAT(X, name)
-typedef void (vector)(void);
-extern vector IDTVEC(tss_trap08);
-#if defined(DDB) && defined(MULTIPROCESSOR)
-extern vector Xintrddbipi, Xx2apic_intrddbipi;
-extern int ddb_vec;
-#endif
-
-static void
-cpu_set_tss_gates(struct cpu_info *ci)
-{
-       struct segment_descriptor sd;
-
-       ci->ci_doubleflt_stack = (char *)uvm_km_alloc(kernel_map, USPACE, 0,
-           UVM_KMF_WIRED);
-       tss_init(&ci->ci_doubleflt_tss, ci->ci_doubleflt_stack,
-           IDTVEC(tss_trap08));
-       setsegment(&sd, &ci->ci_doubleflt_tss, sizeof(struct i386tss) - 1,
-           SDT_SYS386TSS, SEL_KPL, 0, 0);
-       ci->ci_gdt[GTRAPTSS_SEL].sd = sd;
-       setgate(&idt[8], NULL, 0, SDT_SYSTASKGT, SEL_KPL,
-           GSEL(GTRAPTSS_SEL, SEL_KPL));
-
-#if defined(DDB) && defined(MULTIPROCESSOR)
-       /*
-        * Set up separate handler for the DDB IPI, so that it doesn't



Home | Main Index | Thread Index | Old Index