Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/amd64 Clean up, and initialize the lwp0 field...



details:   https://anonhg.NetBSD.org/src/rev/9d7881a2acb7
branches:  trunk
changeset: 356476:9d7881a2acb7
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Sep 28 17:35:08 2017 +0000

description:
Clean up, and initialize the lwp0 fields in init_x86_64.

diffstat:

 sys/arch/amd64/amd64/locore.S  |  11 +++++++----
 sys/arch/amd64/amd64/machdep.c |  24 ++++++++++++------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diffs (145 lines):

diff -r 4f43df721946 -r 9d7881a2acb7 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Thu Sep 28 17:21:42 2017 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Thu Sep 28 17:35:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.129 2017/09/15 17:32:12 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.130 2017/09/28 17:35:08 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -328,6 +328,7 @@
        .globl  _C_LABEL(bootinfo)
        .globl  _C_LABEL(biosbasemem)
        .globl  _C_LABEL(biosextmem)
+       .globl  _C_LABEL(lwp0uarea)
        .globl  do_sysret
        .globl  do_iret
 
@@ -369,6 +370,9 @@
 LABEL(biosextmem)      .long   REALEXTMEM
 #endif
 END(biosextmem)
+       .type   _C_LABEL(lwp0uarea), @object
+LABEL(lwp0uarea)       .quad   0
+END(lwp0uarea)
 
 #ifndef XEN
        .globl  gdt64_lo
@@ -872,9 +876,8 @@
        /* Set up bootstrap stack. */
        leaq    (PROC0_STK_OFF)(%rsi),%rax
        addq    %r8,%rax
-       movq    %rax,(_C_LABEL(lwp0)+L_PCB)(%rip) /* XXX L_PCB != uarea */
+       movq    %rax,_C_LABEL(lwp0uarea)(%rip)
        leaq    (USPACE-FRAMESIZE)(%rax),%rsp
-       movq    %rsi,PCB_CR3(%rax)              /* pcb->pcb_cr3 */
        xorq    %rbp,%rbp                       /* mark end of frames */
 
        xorw    %ax,%ax
@@ -954,7 +957,7 @@
         * use it as the UAREA, and set up the stack here.
         */
        movq    %rax,%rsi
-       movq    %rsi,(_C_LABEL(lwp0)+L_PCB)     /* XXX L_PCB != uarea */
+       movq    %rsi,_C_LABEL(lwp0uarea)(%rip)
        leaq    (USPACE-FRAMESIZE)(%rsi),%rsp
        xorq    %rbp,%rbp
 
diff -r 4f43df721946 -r 9d7881a2acb7 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Thu Sep 28 17:21:42 2017 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Thu Sep 28 17:35:08 2017 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: machdep.c,v 1.260 2017/07/25 17:43:44 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.261 2017/09/28 17:35:08 maxv Exp $       */
 
-/*-
+/*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
  *     The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -73,10 +73,9 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
  */
 
-/*-
+/*
  * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
  * All rights reserved.
  *
@@ -111,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.260 2017/07/25 17:43:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.261 2017/09/28 17:35:08 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1439,7 +1438,7 @@
        struct region_descriptor region;
 
        setregion(&region, idt, NIDT * sizeof(idt[0]) - 1);
-       lidt(&region); 
+       lidt(&region);
 #else
        if (HYPERVISOR_set_trap_table(xen_idt))
                panic("HYPERVISOR_set_trap_table() failed");
@@ -1495,6 +1494,7 @@
        struct mem_segment_descriptor *ldt_segp;
        int x;
        struct pcb *pcb;
+       extern vaddr_t lwp0uarea;
 #ifndef XEN
        extern paddr_t local_apic_pa;
        int ist;
@@ -1505,9 +1505,9 @@
 #ifdef XEN
        KASSERT(HYPERVISOR_shared_info != NULL);
        cpu_info_primary.ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[0];
+#endif
 
-       __PRINTK(("init_x86_64(0x%lx)\n", first_avail));
-#endif /* XEN */
+       uvm_lwp_setuarea(&lwp0, lwp0uarea);
 
        cpu_probe(&cpu_info_primary);
        cpu_init_msrs(&cpu_info_primary, true);
@@ -1518,7 +1518,8 @@
 #ifdef XEN
        mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
        pcb->pcb_cr3 = xen_start_info.pt_base - KERNBASE;
-       __PRINTK(("pcb_cr3 0x%lx\n", xen_start_info.pt_base - KERNBASE));
+#else
+       pcb->pcb_cr3 = PDPpaddr;
 #endif
 
 #if NISA > 0 || NPCI > 0
@@ -1790,7 +1791,7 @@
         * invalid and causing a fault.
         */
        kpreempt_disable();
-       pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE);           
+       pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE);
        memset((void *)idt, 0, NIDT * sizeof(idt[0]));
        kpreempt_enable();
        breakpoint();
@@ -1801,7 +1802,7 @@
         * entire address space and doing a TLB flush.
         */
        memset((void *)PTD, 0, PAGE_SIZE);
-       tlbflush(); 
+       tlbflush();
 #endif
 #endif /* XEN */
 
@@ -2041,7 +2042,6 @@
        kpreempt_enable();
 }
 
-
 #ifdef __HAVE_DIRECT_MAP
 bool
 mm_md_direct_mapped_io(void *addr, paddr_t *paddr)



Home | Main Index | Thread Index | Old Index