Thu Sep 28 17:35:08 2017 UTC ()
Clean up, and initialize the lwp0 fields in init_x86_64.


(maxv)
diff -r1.129 -r1.130 src/sys/arch/amd64/amd64/locore.S
diff -r1.260 -r1.261 src/sys/arch/amd64/amd64/machdep.c

cvs diff -r1.129 -r1.130 src/sys/arch/amd64/amd64/locore.S (expand / switch to unified diff)

--- src/sys/arch/amd64/amd64/locore.S 2017/09/15 17:32:12 1.129
+++ src/sys/arch/amd64/amd64/locore.S 2017/09/28 17:35:08 1.130
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.S,v 1.129 2017/09/15 17:32:12 maxv Exp $ */ 1/* $NetBSD: locore.S,v 1.130 2017/09/28 17:35:08 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright-o-rama! 4 * Copyright-o-rama!
5 */ 5 */
6 6
7/* 7/*
8 * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc. 8 * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * This code is derived from software contributed to The NetBSD Foundation 11 * This code is derived from software contributed to The NetBSD Foundation
12 * by Charles M. Hannum and by Maxime Villard. 12 * by Charles M. Hannum and by Maxime Villard.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
@@ -318,26 +318,27 @@ @@ -318,26 +318,27 @@
318 318
319 .globl _C_LABEL(tablesize) 319 .globl _C_LABEL(tablesize)
320 .globl _C_LABEL(nox_flag) 320 .globl _C_LABEL(nox_flag)
321 .globl _C_LABEL(cputype) 321 .globl _C_LABEL(cputype)
322 .globl _C_LABEL(cpuid_level) 322 .globl _C_LABEL(cpuid_level)
323 .globl _C_LABEL(esym) 323 .globl _C_LABEL(esym)
324 .globl _C_LABEL(eblob) 324 .globl _C_LABEL(eblob)
325 .globl _C_LABEL(atdevbase) 325 .globl _C_LABEL(atdevbase)
326 .globl _C_LABEL(PDPpaddr) 326 .globl _C_LABEL(PDPpaddr)
327 .globl _C_LABEL(boothowto) 327 .globl _C_LABEL(boothowto)
328 .globl _C_LABEL(bootinfo) 328 .globl _C_LABEL(bootinfo)
329 .globl _C_LABEL(biosbasemem) 329 .globl _C_LABEL(biosbasemem)
330 .globl _C_LABEL(biosextmem) 330 .globl _C_LABEL(biosextmem)
 331 .globl _C_LABEL(lwp0uarea)
331 .globl do_sysret 332 .globl do_sysret
332 .globl do_iret 333 .globl do_iret
333 334
334 .type _C_LABEL(tablesize), @object 335 .type _C_LABEL(tablesize), @object
335_C_LABEL(tablesize): .long TABLESIZE 336_C_LABEL(tablesize): .long TABLESIZE
336END(tablesize) 337END(tablesize)
337 .type _C_LABEL(nox_flag), @object 338 .type _C_LABEL(nox_flag), @object
338LABEL(nox_flag) .long 0 /* 32bit NOX flag, set if supported */ 339LABEL(nox_flag) .long 0 /* 32bit NOX flag, set if supported */
339END(nox_flag) 340END(nox_flag)
340 .type _C_LABEL(cputype), @object 341 .type _C_LABEL(cputype), @object
341LABEL(cputype) .long 0 /* are we 80486, Pentium, or.. */ 342LABEL(cputype) .long 0 /* are we 80486, Pentium, or.. */
342END(cputype) 343END(cputype)
343 .type _C_LABEL(cpuid_level), @object 344 .type _C_LABEL(cpuid_level), @object
@@ -359,26 +360,29 @@ END(PDPpaddr) @@ -359,26 +360,29 @@ END(PDPpaddr)
359#ifndef REALBASEMEM 360#ifndef REALBASEMEM
360LABEL(biosbasemem) .long 0 /* base memory reported by BIOS */ 361LABEL(biosbasemem) .long 0 /* base memory reported by BIOS */
361#else 362#else
362LABEL(biosbasemem) .long REALBASEMEM 363LABEL(biosbasemem) .long REALBASEMEM
363#endif 364#endif
364END(biosbasemem) 365END(biosbasemem)
365 .type _C_LABEL(biosextmem), @object 366 .type _C_LABEL(biosextmem), @object
366#ifndef REALEXTMEM 367#ifndef REALEXTMEM
367LABEL(biosextmem) .long 0 /* extended memory reported by BIOS */ 368LABEL(biosextmem) .long 0 /* extended memory reported by BIOS */
368#else 369#else
369LABEL(biosextmem) .long REALEXTMEM 370LABEL(biosextmem) .long REALEXTMEM
370#endif 371#endif
371END(biosextmem) 372END(biosextmem)
 373 .type _C_LABEL(lwp0uarea), @object
 374LABEL(lwp0uarea) .quad 0
 375END(lwp0uarea)
372 376
373#ifndef XEN 377#ifndef XEN
374 .globl gdt64_lo 378 .globl gdt64_lo
375 .globl gdt64_hi 379 .globl gdt64_hi
376 380
377#define GDT64_LIMIT gdt64_end-gdt64_start-1 381#define GDT64_LIMIT gdt64_end-gdt64_start-1
378/* Temporary gdt64, with base address in low memory */ 382/* Temporary gdt64, with base address in low memory */
379 .type _C_LABEL(gdt64_lo), @object 383 .type _C_LABEL(gdt64_lo), @object
380LABEL(gdt64_lo) 384LABEL(gdt64_lo)
381 .word GDT64_LIMIT 385 .word GDT64_LIMIT
382 .quad _RELOC(gdt64_start) 386 .quad _RELOC(gdt64_start)
383END(gdt64_lo) 387END(gdt64_lo)
384.align 64 388.align 64
@@ -862,29 +866,28 @@ longmode_hi: @@ -862,29 +866,28 @@ longmode_hi:
862 movq $NKL4_KIMG_ENTRIES,%rcx 866 movq $NKL4_KIMG_ENTRIES,%rcx
863 leaq (PROC0_PML4_OFF)(%rsi),%rbx /* old, phys address of PML4 */ 867 leaq (PROC0_PML4_OFF)(%rsi),%rbx /* old, phys address of PML4 */
864 addq %r8,%rbx /* new, virt address of PML4 */ 868 addq %r8,%rbx /* new, virt address of PML4 */
865 killkpt 869 killkpt
866 870
867 /* Relocate atdevbase. */ 871 /* Relocate atdevbase. */
868 movq $(TABLESIZE+KERNBASE),%rdx 872 movq $(TABLESIZE+KERNBASE),%rdx
869 addq %rsi,%rdx 873 addq %rsi,%rdx
870 movq %rdx,_C_LABEL(atdevbase)(%rip) 874 movq %rdx,_C_LABEL(atdevbase)(%rip)
871 875
872 /* Set up bootstrap stack. */ 876 /* Set up bootstrap stack. */
873 leaq (PROC0_STK_OFF)(%rsi),%rax 877 leaq (PROC0_STK_OFF)(%rsi),%rax
874 addq %r8,%rax 878 addq %r8,%rax
875 movq %rax,(_C_LABEL(lwp0)+L_PCB)(%rip) /* XXX L_PCB != uarea */ 879 movq %rax,_C_LABEL(lwp0uarea)(%rip)
876 leaq (USPACE-FRAMESIZE)(%rax),%rsp 880 leaq (USPACE-FRAMESIZE)(%rax),%rsp
877 movq %rsi,PCB_CR3(%rax) /* pcb->pcb_cr3 */ 
878 xorq %rbp,%rbp /* mark end of frames */ 881 xorq %rbp,%rbp /* mark end of frames */
879 882
880 xorw %ax,%ax 883 xorw %ax,%ax
881 movw %ax,%gs 884 movw %ax,%gs
882 movw %ax,%fs 885 movw %ax,%fs
883 886
884 /* The first physical page available. */ 887 /* The first physical page available. */
885 leaq (TABLESIZE)(%rsi),%rdi 888 leaq (TABLESIZE)(%rsi),%rdi
886 889
887#else /* XEN */ 890#else /* XEN */
888 /* First, reset the PSL. */ 891 /* First, reset the PSL. */
889 pushq $2 892 pushq $2
890 popfq 893 popfq
@@ -944,27 +947,27 @@ longmode_hi: @@ -944,27 +947,27 @@ longmode_hi:
944 947
945 movq $cpu_info_primary,%rdi 948 movq $cpu_info_primary,%rdi
946 movq %rdi,CPU_INFO_SELF(%rdi) /* ci->ci_self = ci */ 949 movq %rdi,CPU_INFO_SELF(%rdi) /* ci->ci_self = ci */
947 movq $1,%rsi 950 movq $1,%rsi
948 call cpu_init_msrs /* cpu_init_msrs(ci, true); */ 951 call cpu_init_msrs /* cpu_init_msrs(ci, true); */
949 952
950 call xen_locore 953 call xen_locore
951 954
952 /* 955 /*
953 * The first VA available is returned by xen_locore in %rax. We 956 * The first VA available is returned by xen_locore in %rax. We
954 * use it as the UAREA, and set up the stack here. 957 * use it as the UAREA, and set up the stack here.
955 */ 958 */
956 movq %rax,%rsi 959 movq %rax,%rsi
957 movq %rsi,(_C_LABEL(lwp0)+L_PCB) /* XXX L_PCB != uarea */ 960 movq %rsi,_C_LABEL(lwp0uarea)(%rip)
958 leaq (USPACE-FRAMESIZE)(%rsi),%rsp 961 leaq (USPACE-FRAMESIZE)(%rsi),%rsp
959 xorq %rbp,%rbp 962 xorq %rbp,%rbp
960 963
961 /* Clear segment registers. */ 964 /* Clear segment registers. */
962 xorw %ax,%ax 965 xorw %ax,%ax
963 movw %ax,%gs 966 movw %ax,%gs
964 movw %ax,%fs 967 movw %ax,%fs
965 968
966 /* Set first_avail after the DUMMY PAGE (see xen_locore). */ 969 /* Set first_avail after the DUMMY PAGE (see xen_locore). */
967 movq %rsi,%rdi 970 movq %rsi,%rdi
968 addq $(USPACE+PAGE_SIZE),%rdi 971 addq $(USPACE+PAGE_SIZE),%rdi
969 subq $KERNBASE,%rdi /* init_x86_64 wants a physical address */ 972 subq $KERNBASE,%rdi /* init_x86_64 wants a physical address */
970#endif /* XEN */ 973#endif /* XEN */

cvs diff -r1.260 -r1.261 src/sys/arch/amd64/amd64/machdep.c (expand / switch to unified diff)

--- src/sys/arch/amd64/amd64/machdep.c 2017/07/25 17:43:44 1.260
+++ src/sys/arch/amd64/amd64/machdep.c 2017/09/28 17:35:08 1.261
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1/* $NetBSD: machdep.c,v 1.260 2017/07/25 17:43:44 maxv Exp $ */ 1/* $NetBSD: machdep.c,v 1.261 2017/09/28 17:35:08 maxv Exp $ */
2 2
3/*- 3/*
4 * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 4 * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
5 * The NetBSD Foundation, Inc. 5 * The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace 9 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
10 * Simulation Facility, NASA Ames Research Center. 10 * Simulation Facility, NASA Ames Research Center.
11 * 11 *
12 * This code is derived from software contributed to The NetBSD Foundation 12 * This code is derived from software contributed to The NetBSD Foundation
13 * by Coyote Point Systems, Inc. which was written under contract to Coyote 13 * by Coyote Point Systems, Inc. which was written under contract to Coyote
14 * Point by Jed Davis and Devon O'Dell. 14 * Point by Jed Davis and Devon O'Dell.
15 * 15 *
16 * Redistribution and use in source and binary forms, with or without 16 * Redistribution and use in source and binary forms, with or without
@@ -63,30 +63,29 @@ @@ -63,30 +63,29 @@
63 * notice, this list of conditions and the following disclaimer in the 63 * notice, this list of conditions and the following disclaimer in the
64 * documentation and/or other materials provided with the distribution. 64 * documentation and/or other materials provided with the distribution.
65 * 65 *
66 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 66 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
67 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 67 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
68 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 68 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
69 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 69 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
70 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 70 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
71 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 71 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
72 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 72 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
73 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 73 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 74 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
75 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 75 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76 * 
77 */ 76 */
78 77
79/*- 78/*
80 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 79 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
81 * All rights reserved. 80 * All rights reserved.
82 * 81 *
83 * This code is derived from software contributed to Berkeley by 82 * This code is derived from software contributed to Berkeley by
84 * William Jolitz. 83 * William Jolitz.
85 * 84 *
86 * Redistribution and use in source and binary forms, with or without 85 * Redistribution and use in source and binary forms, with or without
87 * modification, are permitted provided that the following conditions 86 * modification, are permitted provided that the following conditions
88 * are met: 87 * are met:
89 * 1. Redistributions of source code must retain the above copyright 88 * 1. Redistributions of source code must retain the above copyright
90 * notice, this list of conditions and the following disclaimer. 89 * notice, this list of conditions and the following disclaimer.
91 * 2. Redistributions in binary form must reproduce the above copyright 90 * 2. Redistributions in binary form must reproduce the above copyright
92 * notice, this list of conditions and the following disclaimer in the 91 * notice, this list of conditions and the following disclaimer in the
@@ -101,27 +100,27 @@ @@ -101,27 +100,27 @@
101 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 100 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
102 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 101 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
103 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 102 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
104 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 103 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
105 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 104 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
106 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 105 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
107 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 106 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
108 * SUCH DAMAGE. 107 * SUCH DAMAGE.
109 * 108 *
110 * @(#)machdep.c 7.4 (Berkeley) 6/3/91 109 * @(#)machdep.c 7.4 (Berkeley) 6/3/91
111 */ 110 */
112 111
113#include <sys/cdefs.h> 112#include <sys/cdefs.h>
114__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.260 2017/07/25 17:43:44 maxv Exp $"); 113__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.261 2017/09/28 17:35:08 maxv Exp $");
115 114
116/* #define XENDEBUG_LOW */ 115/* #define XENDEBUG_LOW */
117 116
118#include "opt_modular.h" 117#include "opt_modular.h"
119#include "opt_user_ldt.h" 118#include "opt_user_ldt.h"
120#include "opt_ddb.h" 119#include "opt_ddb.h"
121#include "opt_kgdb.h" 120#include "opt_kgdb.h"
122#include "opt_cpureset_delay.h" 121#include "opt_cpureset_delay.h"
123#include "opt_mtrr.h" 122#include "opt_mtrr.h"
124#include "opt_realmem.h" 123#include "opt_realmem.h"
125#include "opt_xen.h" 124#include "opt_xen.h"
126#ifndef XEN 125#ifndef XEN
127#include "opt_physmem.h" 126#include "opt_physmem.h"
@@ -1429,27 +1428,27 @@ set_sys_segment(struct sys_segment_descr @@ -1429,27 +1428,27 @@ set_sys_segment(struct sys_segment_descr
1429 sd->sd_p = 1; 1428 sd->sd_p = 1;
1430 sd->sd_hilimit = (unsigned)limit >> 16; 1429 sd->sd_hilimit = (unsigned)limit >> 16;
1431 sd->sd_gran = gran; 1430 sd->sd_gran = gran;
1432 sd->sd_hibase = (uint64_t)base >> 24; 1431 sd->sd_hibase = (uint64_t)base >> 24;
1433} 1432}
1434 1433
1435void 1434void
1436cpu_init_idt(void) 1435cpu_init_idt(void)
1437{ 1436{
1438#ifndef XEN 1437#ifndef XEN
1439 struct region_descriptor region; 1438 struct region_descriptor region;
1440 1439
1441 setregion(&region, idt, NIDT * sizeof(idt[0]) - 1); 1440 setregion(&region, idt, NIDT * sizeof(idt[0]) - 1);
1442 lidt(&region);  1441 lidt(&region);
1443#else 1442#else
1444 if (HYPERVISOR_set_trap_table(xen_idt)) 1443 if (HYPERVISOR_set_trap_table(xen_idt))
1445 panic("HYPERVISOR_set_trap_table() failed"); 1444 panic("HYPERVISOR_set_trap_table() failed");
1446#endif 1445#endif
1447} 1446}
1448 1447
1449#define IDTVEC(name) __CONCAT(X, name) 1448#define IDTVEC(name) __CONCAT(X, name)
1450typedef void (vector)(void); 1449typedef void (vector)(void);
1451extern vector IDTVEC(syscall); 1450extern vector IDTVEC(syscall);
1452extern vector IDTVEC(syscall32); 1451extern vector IDTVEC(syscall32);
1453extern vector IDTVEC(osyscall); 1452extern vector IDTVEC(osyscall);
1454extern vector *IDTVEC(exceptions)[]; 1453extern vector *IDTVEC(exceptions)[];
1455 1454
@@ -1485,50 +1484,52 @@ init_x86_64_ksyms(void) @@ -1485,50 +1484,52 @@ init_x86_64_ksyms(void)
1485 ((int *)(void *)&end) + 1, esym); 1484 ((int *)(void *)&end) + 1, esym);
1486#endif /* XEN */ 1485#endif /* XEN */
1487#endif 1486#endif
1488} 1487}
1489 1488
1490void 1489void
1491init_x86_64(paddr_t first_avail) 1490init_x86_64(paddr_t first_avail)
1492{ 1491{
1493 extern void consinit(void); 1492 extern void consinit(void);
1494 struct region_descriptor region; 1493 struct region_descriptor region;
1495 struct mem_segment_descriptor *ldt_segp; 1494 struct mem_segment_descriptor *ldt_segp;
1496 int x; 1495 int x;
1497 struct pcb *pcb; 1496 struct pcb *pcb;
 1497 extern vaddr_t lwp0uarea;
1498#ifndef XEN 1498#ifndef XEN
1499 extern paddr_t local_apic_pa; 1499 extern paddr_t local_apic_pa;
1500 int ist; 1500 int ist;
1501#endif 1501#endif
1502 1502
1503 KASSERT(first_avail % PAGE_SIZE == 0); 1503 KASSERT(first_avail % PAGE_SIZE == 0);
1504 1504
1505#ifdef XEN 1505#ifdef XEN
1506 KASSERT(HYPERVISOR_shared_info != NULL); 1506 KASSERT(HYPERVISOR_shared_info != NULL);
1507 cpu_info_primary.ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[0]; 1507 cpu_info_primary.ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[0];
 1508#endif
1508 1509
1509 __PRINTK(("init_x86_64(0x%lx)\n", first_avail)); 1510 uvm_lwp_setuarea(&lwp0, lwp0uarea);
1510#endif /* XEN */ 
1511 1511
1512 cpu_probe(&cpu_info_primary); 1512 cpu_probe(&cpu_info_primary);
1513 cpu_init_msrs(&cpu_info_primary, true); 1513 cpu_init_msrs(&cpu_info_primary, true);
1514 1514
1515 use_pae = 1; /* PAE always enabled in long mode */ 1515 use_pae = 1; /* PAE always enabled in long mode */
1516 1516
1517 pcb = lwp_getpcb(&lwp0); 1517 pcb = lwp_getpcb(&lwp0);
1518#ifdef XEN 1518#ifdef XEN
1519 mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM); 1519 mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
1520 pcb->pcb_cr3 = xen_start_info.pt_base - KERNBASE; 1520 pcb->pcb_cr3 = xen_start_info.pt_base - KERNBASE;
1521 __PRINTK(("pcb_cr3 0x%lx\n", xen_start_info.pt_base - KERNBASE)); 1521#else
 1522 pcb->pcb_cr3 = PDPpaddr;
1522#endif 1523#endif
1523 1524
1524#if NISA > 0 || NPCI > 0 1525#if NISA > 0 || NPCI > 0
1525 x86_bus_space_init(); 1526 x86_bus_space_init();
1526#endif 1527#endif
1527 1528
1528 consinit(); /* XXX SHOULD NOT BE DONE HERE */ 1529 consinit(); /* XXX SHOULD NOT BE DONE HERE */
1529 1530
1530 /* 1531 /*
1531 * Initialize PAGE_SIZE-dependent variables. 1532 * Initialize PAGE_SIZE-dependent variables.
1532 */ 1533 */
1533 uvm_md_init(); 1534 uvm_md_init();
1534 1535
@@ -1780,38 +1781,38 @@ cpu_reset(void) @@ -1780,38 +1781,38 @@ cpu_reset(void)
1780 x86_disable_intr(); 1781 x86_disable_intr();
1781 1782
1782#ifdef XEN 1783#ifdef XEN
1783 HYPERVISOR_reboot(); 1784 HYPERVISOR_reboot();
1784#else 1785#else
1785 1786
1786 x86_reset(); 1787 x86_reset();
1787 1788
1788 /* 1789 /*
1789 * Try to cause a triple fault and watchdog reset by making the IDT 1790 * Try to cause a triple fault and watchdog reset by making the IDT
1790 * invalid and causing a fault. 1791 * invalid and causing a fault.
1791 */ 1792 */
1792 kpreempt_disable(); 1793 kpreempt_disable();
1793 pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE);  1794 pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE);
1794 memset((void *)idt, 0, NIDT * sizeof(idt[0])); 1795 memset((void *)idt, 0, NIDT * sizeof(idt[0]));
1795 kpreempt_enable(); 1796 kpreempt_enable();
1796 breakpoint(); 1797 breakpoint();
1797 1798
1798#if 0 1799#if 0
1799 /* 1800 /*
1800 * Try to cause a triple fault and watchdog reset by unmapping the 1801 * Try to cause a triple fault and watchdog reset by unmapping the
1801 * entire address space and doing a TLB flush. 1802 * entire address space and doing a TLB flush.
1802 */ 1803 */
1803 memset((void *)PTD, 0, PAGE_SIZE); 1804 memset((void *)PTD, 0, PAGE_SIZE);
1804 tlbflush();  1805 tlbflush();
1805#endif 1806#endif
1806#endif /* XEN */ 1807#endif /* XEN */
1807 1808
1808 for (;;); 1809 for (;;);
1809} 1810}
1810 1811
1811void 1812void
1812cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags) 1813cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
1813{ 1814{
1814 const struct trapframe *tf = l->l_md.md_regs; 1815 const struct trapframe *tf = l->l_md.md_regs;
1815 __greg_t ras_rip; 1816 __greg_t ras_rip;
1816 1817
1817 /* Copy general registers member by member */ 1818 /* Copy general registers member by member */
@@ -2031,27 +2032,26 @@ cpu_fsgs_reload(struct lwp *l, int fssel @@ -2031,27 +2032,26 @@ cpu_fsgs_reload(struct lwp *l, int fssel
2031 update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &pcb->pcb_fs); 2032 update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
2032 update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &pcb->pcb_gs); 2033 update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
2033 setfs(fssel); 2034 setfs(fssel);
2034#ifndef XEN 2035#ifndef XEN
2035 setusergs(gssel); 2036 setusergs(gssel);
2036#else 2037#else
2037 HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gssel); 2038 HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gssel);
2038#endif 2039#endif
2039 tf->tf_fs = fssel; 2040 tf->tf_fs = fssel;
2040 tf->tf_gs = gssel; 2041 tf->tf_gs = gssel;
2041 kpreempt_enable(); 2042 kpreempt_enable();
2042} 2043}
2043 2044
2044 
2045#ifdef __HAVE_DIRECT_MAP 2045#ifdef __HAVE_DIRECT_MAP
2046bool 2046bool
2047mm_md_direct_mapped_io(void *addr, paddr_t *paddr) 2047mm_md_direct_mapped_io(void *addr, paddr_t *paddr)
2048{ 2048{
2049 vaddr_t va = (vaddr_t)addr; 2049 vaddr_t va = (vaddr_t)addr;
2050 2050
2051 if (va >= PMAP_DIRECT_BASE && va < PMAP_DIRECT_END) { 2051 if (va >= PMAP_DIRECT_BASE && va < PMAP_DIRECT_END) {
2052 *paddr = PMAP_DIRECT_UNMAP(va); 2052 *paddr = PMAP_DIRECT_UNMAP(va);
2053 return true; 2053 return true;
2054 } 2054 }
2055 return false; 2055 return false;
2056} 2056}
2057 2057