| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpu.c,v 1.72 2011/12/30 16:55:21 cherry Exp $ */ | | 1 | /* $NetBSD: cpu.c,v 1.73 2011/12/30 18:01:20 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.72 2011/12/30 16:55:21 cherry Exp $"); | | 69 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.73 2011/12/30 18:01:20 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> |
| @@ -1261,43 +1261,35 @@ pmap_cpu_init_late(struct cpu_info *ci) | | | @@ -1261,43 +1261,35 @@ pmap_cpu_init_late(struct cpu_info *ci) |
1261 | { | | 1261 | { |
1262 | #if defined(PAE) || defined(__x86_64__) | | 1262 | #if defined(PAE) || defined(__x86_64__) |
1263 | /* | | 1263 | /* |
1264 | * The BP has already its own PD page allocated during early | | 1264 | * The BP has already its own PD page allocated during early |
1265 | * MD startup. | | 1265 | * MD startup. |
1266 | */ | | 1266 | */ |
1267 | | | 1267 | |
1268 | if (ci == &cpu_info_primary) | | 1268 | if (ci == &cpu_info_primary) |
1269 | return; | | 1269 | return; |
1270 | | | 1270 | |
1271 | KASSERT(ci != NULL); | | 1271 | KASSERT(ci != NULL); |
1272 | | | 1272 | |
1273 | #if defined(PAE) | | 1273 | #if defined(PAE) |
1274 | ci->ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, | | 1274 | cpu_alloc_l3_page(ci); |
1275 | UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT); | | | |
1276 | | | | |
1277 | if (ci->ci_pae_l3_pdir == NULL) { | | | |
1278 | panic("%s: failed to allocate L3 per-cpu PD for CPU %d\n", | | | |
1279 | __func__, cpu_index(ci)); | | | |
1280 | } | | | |
1281 | ci->ci_pae_l3_pdirpa = vtophys((vaddr_t) ci->ci_pae_l3_pdir); | | | |
1282 | KASSERT(ci->ci_pae_l3_pdirpa != 0); | | 1275 | KASSERT(ci->ci_pae_l3_pdirpa != 0); |
1283 | | | 1276 | |
1284 | /* Initialise L2 entries 0 - 2: Point them to pmap_kernel() */ | | 1277 | /* Initialise L2 entries 0 - 2: Point them to pmap_kernel() */ |
1285 | ci->ci_pae_l3_pdir[0] = | | 1278 | int i; |
1286 | xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[0]) | PG_V; | | 1279 | for (i = 0; i < PTP_LEVELS - 1; i++ ) { |
1287 | ci->ci_pae_l3_pdir[1] = | | 1280 | ci->ci_pae_l3_pdir[i] = |
1288 | xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[1]) | PG_V; | | 1281 | xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[i]) | PG_V; |
1289 | ci->ci_pae_l3_pdir[2] = | | 1282 | } |
1290 | xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[2]) | PG_V; | | | |
1291 | #endif /* PAE */ | | 1283 | #endif /* PAE */ |
1292 | | | 1284 | |
1293 | ci->ci_kpm_pdir = (pd_entry_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, | | 1285 | ci->ci_kpm_pdir = (pd_entry_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, |
1294 | UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT); | | 1286 | UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT); |
1295 | | | 1287 | |
1296 | if (ci->ci_kpm_pdir == NULL) { | | 1288 | if (ci->ci_kpm_pdir == NULL) { |
1297 | panic("%s: failed to allocate L4 per-cpu PD for CPU %d\n", | | 1289 | panic("%s: failed to allocate L4 per-cpu PD for CPU %d\n", |
1298 | __func__, cpu_index(ci)); | | 1290 | __func__, cpu_index(ci)); |
1299 | } | | 1291 | } |
1300 | ci->ci_kpm_pdirpa = vtophys((vaddr_t) ci->ci_kpm_pdir); | | 1292 | ci->ci_kpm_pdirpa = vtophys((vaddr_t) ci->ci_kpm_pdir); |
1301 | KASSERT(ci->ci_kpm_pdirpa != 0); | | 1293 | KASSERT(ci->ci_kpm_pdirpa != 0); |
1302 | | | 1294 | |
1303 | #if defined(__x86_64__) | | 1295 | #if defined(__x86_64__) |