Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Fixes regarding paddr_t/pd_entry_t types in MD x86 ...
details: https://anonhg.NetBSD.org/src/rev/7de18100b12c
branches: trunk
changeset: 752460:7de18100b12c
user: jym <jym%NetBSD.org@localhost>
date: Fri Feb 26 19:25:07 2010 +0000
description:
Fixes regarding paddr_t/pd_entry_t types in MD x86 code, exposed by PAE:
- NBPD_* macros are set to the types that better match their architecture
(UL for i386 and amd64, ULL for i386 PAE) - will revisit when paddr_t is
set to 64 bits for i386 non-PAE.
- type fixes in printf/printk messages (Use PRIxPADDR when printing paddr_t
values, instead of %lx - paddr_t/pd_entry_t being 64 bits with PAE)
- remove casts that are no more needed now that Xen2 support has been dropped
Some fixes are from jmorse@ patches for PAE.
Compile + tested for i386 GENERIC and XEN3 kernels. Only compile tested for
amd64.
Reviewed by bouyer@.
See also http://mail-index.netbsd.org/tech-kern/2010/02/22/msg007373.html
diffstat:
sys/arch/amd64/include/pte.h | 10 +-
sys/arch/i386/i386/dumpsys.c | 7 +-
sys/arch/i386/include/pte.h | 6 +-
sys/arch/i386/pci/elan520.c | 24 +++++---
sys/arch/x86/x86/bus_dma.c | 6 +-
sys/arch/x86/x86/pmap.c | 46 ++++++++--------
sys/arch/xen/x86/x86_xpmap.c | 115 +++++++++++++++++++++---------------------
7 files changed, 108 insertions(+), 106 deletions(-)
diffs (truncated from 593 to 300 lines):
diff -r fda7973f5424 -r 7de18100b12c sys/arch/amd64/include/pte.h
--- a/sys/arch/amd64/include/pte.h Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/amd64/include/pte.h Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pte.h,v 1.5 2010/01/28 14:10:54 mbalmer Exp $ */
+/* $NetBSD: pte.h,v 1.6 2010/02/26 19:25:07 jym Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -81,10 +81,10 @@
#define L2_SHIFT 21
#define L3_SHIFT 30
#define L4_SHIFT 39
-#define NBPD_L1 (1ULL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
-#define NBPD_L2 (1ULL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */
-#define NBPD_L3 (1ULL << L3_SHIFT) /* # bytes mapped by L3 ent (1G) */
-#define NBPD_L4 (1ULL << L4_SHIFT) /* # bytes mapped by L4 ent (512G) */
+#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
+#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */
+#define NBPD_L3 (1UL << L3_SHIFT) /* # bytes mapped by L3 ent (1G) */
+#define NBPD_L4 (1UL << L4_SHIFT) /* # bytes mapped by L4 ent (512G) */
#define L4_MASK 0x0000ff8000000000
#define L3_MASK 0x0000007fc0000000
diff -r fda7973f5424 -r 7de18100b12c sys/arch/i386/i386/dumpsys.c
--- a/sys/arch/i386/i386/dumpsys.c Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/i386/i386/dumpsys.c Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dumpsys.c,v 1.8 2009/11/07 07:27:44 cegger Exp $ */
+/* $NetBSD: dumpsys.c,v 1.9 2010/02/26 19:25:07 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.8 2009/11/07 07:27:44 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.9 2010/02/26 19:25:07 jym Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -342,8 +342,7 @@
max_paddr = top;
}
#ifdef DUMP_DEBUG
- printf("dump_misc_init: max_paddr = 0x%lx\n",
- (unsigned long)max_paddr);
+ printf("dump_misc_init: max_paddr = %#" PRIxPADDR "\n", max_paddr);
#endif
sparse_dump_physmap = (void*)uvm_km_alloc(kernel_map,
diff -r fda7973f5424 -r 7de18100b12c sys/arch/i386/include/pte.h
--- a/sys/arch/i386/include/pte.h Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/i386/include/pte.h Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pte.h,v 1.20 2009/11/17 22:35:43 dyoung Exp $ */
+/* $NetBSD: pte.h,v 1.21 2010/02/26 19:25:07 jym Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -221,8 +221,8 @@
#else /* PAE */
#define L1_SHIFT 12
#define L2_SHIFT 22
-#define NBPD_L1 (1ULL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
-#define NBPD_L2 (1ULL << L2_SHIFT) /* # bytes mapped by L2 ent (4MB) */
+#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
+#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (4MB) */
#define L2_MASK 0xffc00000
#define L1_MASK 0x003ff000
diff -r fda7973f5424 -r 7de18100b12c sys/arch/i386/pci/elan520.c
--- a/sys/arch/i386/pci/elan520.c Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/i386/pci/elan520.c Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: elan520.c,v 1.47 2010/02/24 22:37:55 dyoung Exp $ */
+/* $NetBSD: elan520.c,v 1.48 2010/02/26 19:25:07 jym Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elan520.c,v 1.47 2010/02/24 22:37:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elan520.c,v 1.48 2010/02/26 19:25:07 jym Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -725,8 +725,9 @@
par = bus_space_read_4(memt, memh, MMCR_PAR(pidx));
aprint_debug_dev(self,
- "protect kernel text at physical addresses %p - %p\n",
- (void *)region0.start, (void *)region0.end);
+ "protect kernel text at physical addresses "
+ "%#" PRIxPADDR " - %#" PRIxPADDR "\n",
+ region0.start, region0.end);
nregion = region_paddr_to_par(®ion0, regions, sfkb);
if (nregion == 0) {
@@ -742,8 +743,9 @@
end_pa = regions[0].end;
aprint_debug_dev(self,
- "actually protect kernel text at physical addresses %p - %p\n",
- (void *)start_pa, (void *)end_pa);
+ "actually protect kernel text at physical addresses "
+ "%#" PRIxPADDR " - %#" PRIxPADDR "\n",
+ start_pa, end_pa);
aprint_verbose_dev(self,
"%" PRIu32 " bytes of kernel text are unprotected\n", unprotsize);
@@ -758,8 +760,9 @@
for (i = 1; i < nregion; i++) {
xnregion = region_paddr_to_par(®ions[i], xregions, fkb);
if (xnregion == 0) {
- aprint_verbose_dev(self, "skip region %p - %p\n",
- (void *)regions[i].start, (void *)regions[i].end);
+ aprint_verbose_dev(self, "skip region "
+ "%#" PRIxPADDR " - %#" PRIxPADDR "\n",
+ regions[i].start, regions[i].end);
continue;
}
if ((pidx = elansc_alloc_par(memt, memh)) == -1) {
@@ -771,8 +774,9 @@
sc->sc_textpar[tidx++] = pidx;
aprint_debug_dev(self,
- "protect add'l kernel text at physical addresses %p - %p\n",
- (void *)xregions[0].start, (void *)xregions[0].end);
+ "protect add'l kernel text at physical addresses "
+ "%#" PRIxPADDR " - %#" PRIxPADDR "\n",
+ xregions[0].start, xregions[0].end);
for (j = 1; j < xnregion; j++)
unprotsize += xregions[j].end - xregions[j].start;
diff -r fda7973f5424 -r 7de18100b12c sys/arch/x86/x86/bus_dma.c
--- a/sys/arch/x86/x86/bus_dma.c Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/x86/x86/bus_dma.c Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.52 2009/11/06 23:10:10 dsl Exp $ */
+/* $NetBSD: bus_dma.c,v 1.53 2010/02/26 19:25:07 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.52 2009/11/06 23:10:10 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.53 2010/02/26 19:25:07 jym Exp $");
/*
* The following is included because _bus_dma_uiomove is derived from
@@ -182,7 +182,7 @@
#ifdef DIAGNOSTIC
if (curaddr < low || curaddr >= high) {
printf("vm_page_alloc_memory returned non-sensical"
- " address 0x%lx\n", curaddr);
+ " address %#" PRIxPADDR "\n", curaddr);
panic("_bus_dmamem_alloc_range");
}
#endif
diff -r fda7973f5424 -r 7de18100b12c sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Fri Feb 26 18:57:06 2010 +0000
+++ b/sys/arch/x86/x86/pmap.c Fri Feb 26 19:25:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.104 2010/02/16 00:48:17 jym Exp $ */
+/* $NetBSD: pmap.c,v 1.105 2010/02/26 19:25:07 jym Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@@ -149,7 +149,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.104 2010/02/16 00:48:17 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.105 2010/02/26 19:25:07 jym Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1397,11 +1397,10 @@
tlbflush();
}
#if defined(DEBUG)
- aprint_normal("kernel text is mapped with "
- "%lu large pages and %lu normal pages\n",
- (unsigned long)howmany(kva - KERNBASE, NBPD_L2),
- (unsigned long)howmany((vaddr_t)&__data_start - kva,
- NBPD_L1));
+ aprint_normal("kernel text is mapped with %" PRIuPSIZE " large "
+ "pages and %" PRIuPSIZE " normal pages\n",
+ howmany(kva - KERNBASE, NBPD_L2),
+ howmany((vaddr_t)&__data_start - kva, NBPD_L1));
#endif /* defined(DEBUG) */
}
#endif /* !XEN */
@@ -1416,7 +1415,7 @@
*/
early_zerop = (void *)(KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2);
- early_zero_pte = PTE_BASE + pl1_i((unsigned long)early_zerop);
+ early_zero_pte = PTE_BASE + pl1_i((vaddr_t)early_zerop);
}
/*
@@ -2038,8 +2037,8 @@
ptp = pmap_find_ptp(pmap, va, ppa, 1);
#ifdef DIAGNOSTIC
if (ptp == NULL) {
- printf("va %lx ppa %lx\n", (unsigned long)va,
- (unsigned long)ppa);
+ printf("va %" PRIxVADDR " ppa %" PRIxPADDR "\n",
+ va, ppa);
panic("pmap_get_ptp: unmanaged user PTP");
}
#endif
@@ -2094,8 +2093,8 @@
* PG_V) value at the right place.
*/
pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] =
- (unsigned long)-1 & PG_FRAME;
-#else /* XEN && __x86_64__*/
+ (pd_entry_t)-1 & PG_FRAME;
+#else /* XEN && __x86_64__*/
/* zero init area */
memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t));
@@ -2780,7 +2779,7 @@
int i;
int s = splvm();
/* don't update the kernel L3 slot */
- for (i = 0 ; i < PDP_SIZE - 1 ; i++, l3_pd += sizeof(pd_entry_t)) {
+ for (i = 0 ; i < PDP_SIZE - 1; i++, l3_pd += sizeof(pd_entry_t)) {
xpq_queue_pte_update(l3_pd,
xpmap_ptom(pmap->pm_pdirpa[i]) | PG_V);
}
@@ -2916,7 +2915,7 @@
pd_entry_t * const *pdes;
struct pmap *pmap2;
struct cpu_info *ci;
- vaddr_t pa;
+ paddr_t pa;
lwp_t *l;
bool hard, rv;
@@ -3303,7 +3302,7 @@
#if defined(DIAGNOSTIC) && !defined(DOM0OPS)
if (PHYS_TO_VM_PAGE(pmap_pte2pa(opte)) != NULL)
panic("pmap_remove_ptes: managed page without "
- "PG_PVLIST for 0x%lx", startva);
+ "PG_PVLIST for %#" PRIxVADDR, startva);
#endif
continue;
}
@@ -3312,8 +3311,9 @@
#ifdef DIAGNOSTIC
if (pg == NULL)
panic("pmap_remove_ptes: unmanaged page marked "
- "PG_PVLIST, va = 0x%lx, pa = 0x%lx",
- startva, (u_long)pmap_pte2pa(opte));
+ "PG_PVLIST, va = %#" PRIxVADDR ", "
+ "pa = %#" PRIxPADDR,
+ startva, (paddr_t)pmap_pte2pa(opte));
#endif
/* sync R/M bits */
@@ -3388,7 +3388,7 @@
#if defined(DIAGNOSTIC) && !defined(DOM0OPS)
if (PHYS_TO_VM_PAGE(pmap_pte2pa(opte)) != NULL)
panic("pmap_remove_pte: managed page without "
- "PG_PVLIST for 0x%lx", va);
+ "PG_PVLIST for %#" PRIxVADDR, va);
#endif
return(true);
}
@@ -3397,8 +3397,8 @@
#ifdef DIAGNOSTIC
if (pg == NULL)
panic("pmap_remove_pte: unmanaged page marked "
- "PG_PVLIST, va = 0x%lx, pa = 0x%lx", va,
- (u_long)(pmap_pte2pa(opte)));
+ "PG_PVLIST, va = %#" PRIxVADDR ", pa = %#" PRIxPADDR,
+ va, (paddr_t)pmap_pte2pa(opte));
#endif
/* sync R/M bits */
@@ -4483,9 +4483,9 @@
for (/* null */; sva < blkendva ; sva += PAGE_SIZE, pte++) {
if (!pmap_valid_entry(*pte))
continue;
- printf("va %#lx -> pa %#lx (pte=%#lx)\n",
- sva, (unsigned long)*pte,
- (unsigned long)pmap_pte2pa(*pte));
+ printf("va %#" PRIxVADDR " -> pa %#" PRIxPADDR
+ " (pte=%#" PRIxPADDR ")\n",
+ sva, (paddr_t)pmap_pte2pa(*pte), (paddr_t)*pte);
}
Home |
Main Index |
Thread Index |
Old Index