| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpu.c,v 1.75 2012/01/04 10:30:23 cherry Exp $ */ | | 1 | /* $NetBSD: cpu.c,v 1.76 2012/01/06 15:15:28 cherry Exp $ */ |
2 | /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */ | | 2 | /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
6 | * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, | | 6 | * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * This code is derived from software contributed to The NetBSD Foundation | | 9 | * This code is derived from software contributed to The NetBSD Foundation |
10 | * by RedBack Networks Inc. | | 10 | * by RedBack Networks Inc. |
11 | * | | 11 | * |
12 | * Author: Bill Sommerfeld | | 12 | * Author: Bill Sommerfeld |
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 |
| @@ -56,27 +56,27 @@ | | | @@ -56,27 +56,27 @@ |
56 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 56 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
57 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 57 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
58 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE | | 58 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE |
59 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 59 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
60 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 60 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
61 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 61 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
62 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 62 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
63 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 63 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
64 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 64 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
65 | * SUCH DAMAGE. | | 65 | * SUCH DAMAGE. |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | #include <sys/cdefs.h> | | 68 | #include <sys/cdefs.h> |
69 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.75 2012/01/04 10:30:23 cherry Exp $"); | | 69 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.76 2012/01/06 15:15:28 cherry Exp $"); |
70 | | | 70 | |
71 | #include "opt_ddb.h" | | 71 | #include "opt_ddb.h" |
72 | #include "opt_multiprocessor.h" | | 72 | #include "opt_multiprocessor.h" |
73 | #include "opt_mpbios.h" /* for MPDEBUG */ | | 73 | #include "opt_mpbios.h" /* for MPDEBUG */ |
74 | #include "opt_mtrr.h" | | 74 | #include "opt_mtrr.h" |
75 | #include "opt_xen.h" | | 75 | #include "opt_xen.h" |
76 | | | 76 | |
77 | #include "lapic.h" | | 77 | #include "lapic.h" |
78 | #include "ioapic.h" | | 78 | #include "ioapic.h" |
79 | | | 79 | |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/proc.h> | | 81 | #include <sys/proc.h> |
82 | #include <sys/systm.h> | | 82 | #include <sys/systm.h> |
| @@ -1297,38 +1297,46 @@ pmap_cpu_init_late(struct cpu_info *ci) | | | @@ -1297,38 +1297,46 @@ pmap_cpu_init_late(struct cpu_info *ci) |
1297 | * Copy over the pmap_kernel() shadow L4 entries | | 1297 | * Copy over the pmap_kernel() shadow L4 entries |
1298 | */ | | 1298 | */ |
1299 | | | 1299 | |
1300 | memcpy(ci->ci_kpm_pdir, pmap_kernel()->pm_pdir, PAGE_SIZE); | | 1300 | memcpy(ci->ci_kpm_pdir, pmap_kernel()->pm_pdir, PAGE_SIZE); |
1301 | | | 1301 | |
1302 | /* Recursive kernel mapping */ | | 1302 | /* Recursive kernel mapping */ |
1303 | ci->ci_kpm_pdir[PDIR_SLOT_PTE] = xpmap_ptom_masked(ci->ci_kpm_pdirpa) | PG_k | PG_V; | | 1303 | ci->ci_kpm_pdir[PDIR_SLOT_PTE] = xpmap_ptom_masked(ci->ci_kpm_pdirpa) | PG_k | PG_V; |
1304 | #elif defined(PAE) | | 1304 | #elif defined(PAE) |
1305 | /* Copy over the pmap_kernel() shadow L2 entries that map the kernel */ | | 1305 | /* Copy over the pmap_kernel() shadow L2 entries that map the kernel */ |
1306 | memcpy(ci->ci_kpm_pdir, pmap_kernel()->pm_pdir + PDIR_SLOT_KERN, nkptp[PTP_LEVELS - 1] * sizeof(pd_entry_t)); | | 1306 | memcpy(ci->ci_kpm_pdir, pmap_kernel()->pm_pdir + PDIR_SLOT_KERN, nkptp[PTP_LEVELS - 1] * sizeof(pd_entry_t)); |
1307 | #endif /* __x86_64__ else PAE */ | | 1307 | #endif /* __x86_64__ else PAE */ |
1308 | | | 1308 | |
1309 | /* Xen wants R/O */ | | 1309 | /* Xen wants R/O */ |
| | | 1310 | /* FIXME: This should use pmap_protect() .. */ |
| | | 1311 | #ifdef DIAGNOSTIC |
| | | 1312 | pmap_kremove((vaddr_t)ci->ci_kpm_pdir, PAGE_SIZE); |
| | | 1313 | #endif /* DIAGNOSTIC */ |
1310 | pmap_kenter_pa((vaddr_t)ci->ci_kpm_pdir, ci->ci_kpm_pdirpa, | | 1314 | pmap_kenter_pa((vaddr_t)ci->ci_kpm_pdir, ci->ci_kpm_pdirpa, |
1311 | VM_PROT_READ, 0); | | 1315 | VM_PROT_READ, 0); |
1312 | | | 1316 | |
1313 | #if defined(PAE) | | 1317 | #if defined(PAE) |
1314 | /* Initialise L3 entry 3. This mapping is shared across all | | 1318 | /* Initialise L3 entry 3. This mapping is shared across all |
1315 | * pmaps and is static, ie; loading a new pmap will not update | | 1319 | * pmaps and is static, ie; loading a new pmap will not update |
1316 | * this entry. | | 1320 | * this entry. |
1317 | */ | | 1321 | */ |
1318 | | | 1322 | |
1319 | ci->ci_pae_l3_pdir[3] = xpmap_ptom_masked(ci->ci_kpm_pdirpa) | PG_k | PG_V; | | 1323 | ci->ci_pae_l3_pdir[3] = xpmap_ptom_masked(ci->ci_kpm_pdirpa) | PG_k | PG_V; |
1320 | | | 1324 | |
1321 | /* Mark L3 R/O (Xen wants this) */ | | 1325 | /* Mark L3 R/O (Xen wants this) */ |
| | | 1326 | #ifdef DIAGNOSTIC |
| | | 1327 | /* FIXME: This should use pmap_protect() .. */ |
| | | 1328 | pmap_kremove((vaddr_t)ci->ci_pae_l3_pdir, PAGE_SIZE); |
| | | 1329 | #endif /* DIAGNOSTIC */ |
1322 | pmap_kenter_pa((vaddr_t)ci->ci_pae_l3_pdir, ci->ci_pae_l3_pdirpa, | | 1330 | pmap_kenter_pa((vaddr_t)ci->ci_pae_l3_pdir, ci->ci_pae_l3_pdirpa, |
1323 | VM_PROT_READ, 0); | | 1331 | VM_PROT_READ, 0); |
1324 | | | 1332 | |
1325 | xpq_queue_pin_l3_table(xpmap_ptom_masked(ci->ci_pae_l3_pdirpa)); | | 1333 | xpq_queue_pin_l3_table(xpmap_ptom_masked(ci->ci_pae_l3_pdirpa)); |
1326 | | | 1334 | |
1327 | #elif defined(__x86_64__) | | 1335 | #elif defined(__x86_64__) |
1328 | xpq_queue_pin_l4_table(xpmap_ptom_masked(ci->ci_kpm_pdirpa)); | | 1336 | xpq_queue_pin_l4_table(xpmap_ptom_masked(ci->ci_kpm_pdirpa)); |
1329 | #endif /* PAE */ | | 1337 | #endif /* PAE */ |
1330 | #endif /* defined(PAE) || defined(__x86_64__) */ | | 1338 | #endif /* defined(PAE) || defined(__x86_64__) */ |
1331 | } | | 1339 | } |
1332 | | | 1340 | |
1333 | /* | | 1341 | /* |
1334 | * Notify all other cpus to halt. | | 1342 | * Notify all other cpus to halt. |