Fri Jan 6 15:15:28 2012 UTC ()
Address those pesky DIAGNOSTIC messages. \n
Take a performance hit at fork() for not DTRT. \n
Note: Only applicable for kernels built with "options DIAGNOSTIC" \n


(cherry)
diff -r1.149 -r1.150 src/sys/arch/x86/x86/pmap.c
diff -r1.75 -r1.76 src/sys/arch/xen/x86/cpu.c

cvs diff -r1.149 -r1.150 src/sys/arch/x86/x86/pmap.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/pmap.c 2011/12/30 17:57:49 1.149
+++ src/sys/arch/x86/x86/pmap.c 2012/01/06 15:15:27 1.150
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.149 2011/12/30 17:57:49 cherry Exp $ */ 1/* $NetBSD: pmap.c,v 1.150 2012/01/06 15:15:27 cherry Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -161,27 +161,27 @@ @@ -161,27 +161,27 @@
161 * Hibler/Jolitz pmap, as modified for FreeBSD by John S. Dyson 161 * Hibler/Jolitz pmap, as modified for FreeBSD by John S. Dyson
162 * and David Greenman. 162 * and David Greenman.
163 * 163 *
164 * [3] the Mach pmap. this pmap, from CMU, seems to have migrated 164 * [3] the Mach pmap. this pmap, from CMU, seems to have migrated
165 * between several processors. the VAX version was done by 165 * between several processors. the VAX version was done by
166 * Avadis Tevanian, Jr., and Michael Wayne Young. the i386 166 * Avadis Tevanian, Jr., and Michael Wayne Young. the i386
167 * version was done by Lance Berc, Mike Kupfer, Bob Baron, 167 * version was done by Lance Berc, Mike Kupfer, Bob Baron,
168 * David Golub, and Richard Draves. the alpha version was 168 * David Golub, and Richard Draves. the alpha version was
169 * done by Alessandro Forin (CMU/Mach) and Chris Demetriou 169 * done by Alessandro Forin (CMU/Mach) and Chris Demetriou
170 * (NetBSD/alpha). 170 * (NetBSD/alpha).
171 */ 171 */
172 172
173#include <sys/cdefs.h> 173#include <sys/cdefs.h>
174__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.149 2011/12/30 17:57:49 cherry Exp $"); 174__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.150 2012/01/06 15:15:27 cherry Exp $");
175 175
176#include "opt_user_ldt.h" 176#include "opt_user_ldt.h"
177#include "opt_lockdebug.h" 177#include "opt_lockdebug.h"
178#include "opt_multiprocessor.h" 178#include "opt_multiprocessor.h"
179#include "opt_xen.h" 179#include "opt_xen.h"
180#if !defined(__x86_64__) 180#if !defined(__x86_64__)
181#include "opt_kstack_dr0.h" 181#include "opt_kstack_dr0.h"
182#endif /* !defined(__x86_64__) */ 182#endif /* !defined(__x86_64__) */
183 183
184#include <sys/param.h> 184#include <sys/param.h>
185#include <sys/systm.h> 185#include <sys/systm.h>
186#include <sys/proc.h> 186#include <sys/proc.h>
187#include <sys/pool.h> 187#include <sys/pool.h>
@@ -2110,26 +2110,29 @@ pmap_pdp_ctor(void *arg, void *v, int fl @@ -2110,26 +2110,29 @@ pmap_pdp_ctor(void *arg, void *v, int fl
2110 } 2110 }
2111 2111
2112#ifdef __HAVE_DIRECT_MAP 2112#ifdef __HAVE_DIRECT_MAP
2113 pdir[PDIR_SLOT_DIRECT] = PDP_BASE[PDIR_SLOT_DIRECT]; 2113 pdir[PDIR_SLOT_DIRECT] = PDP_BASE[PDIR_SLOT_DIRECT];
2114#endif 2114#endif
2115 2115
2116#endif /* XEN && __x86_64__*/ 2116#endif /* XEN && __x86_64__*/
2117#ifdef XEN 2117#ifdef XEN
2118 s = splvm(); 2118 s = splvm();
2119 object = (vaddr_t)v; 2119 object = (vaddr_t)v;
2120 for (i = 0; i < PDP_SIZE; i++, object += PAGE_SIZE) { 2120 for (i = 0; i < PDP_SIZE; i++, object += PAGE_SIZE) {
2121 (void) pmap_extract(pmap_kernel(), object, &pdirpa); 2121 (void) pmap_extract(pmap_kernel(), object, &pdirpa);
2122 /* FIXME: This should use pmap_protect() .. */ 2122 /* FIXME: This should use pmap_protect() .. */
 2123#ifdef DIAGNOSTIC
 2124 pmap_kremove(object, PAGE_SIZE);
 2125#endif /* DIAGNOSTIC */
2123 pmap_kenter_pa(object, pdirpa, VM_PROT_READ, 0); 2126 pmap_kenter_pa(object, pdirpa, VM_PROT_READ, 0);
2124 pmap_update(pmap_kernel()); 2127 pmap_update(pmap_kernel());
2125 /* 2128 /*
2126 * pin as L2/L4 page, we have to do the page with the 2129 * pin as L2/L4 page, we have to do the page with the
2127 * PDIR_SLOT_PTE entries last 2130 * PDIR_SLOT_PTE entries last
2128 */ 2131 */
2129#ifdef PAE 2132#ifdef PAE
2130 if (i == l2tol3(PDIR_SLOT_PTE)) 2133 if (i == l2tol3(PDIR_SLOT_PTE))
2131 continue; 2134 continue;
2132#endif 2135#endif
2133 2136
2134#ifdef __x86_64__ 2137#ifdef __x86_64__
2135 xpq_queue_pin_l4_table(xpmap_ptom_masked(pdirpa)); 2138 xpq_queue_pin_l4_table(xpmap_ptom_masked(pdirpa));

cvs diff -r1.75 -r1.76 src/sys/arch/xen/x86/cpu.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/cpu.c 2012/01/04 10:30:23 1.75
+++ src/sys/arch/xen/x86/cpu.c 2012/01/06 15:15:28 1.76
@@ -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.