Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Do not forget that ptoa() casts the result to vaddr...
details: https://anonhg.NetBSD.org/src/rev/baa8d0b18a3d
branches: trunk
changeset: 752543:baa8d0b18a3d
user: jym <jym%NetBSD.org@localhost>
date: Mon Mar 01 01:35:11 2010 +0000
description:
Do not forget that ptoa() casts the result to vaddr_t, which is bad
for paddr_t values under i386 PAE. Use ctob() instead.
Although amd64 is not affected by this vaddr_t vs paddr_t issue (both
having the same size), for the sake of completeness, switch to
ctob() when manipulating paddr_t/psize_t entities in amd64 machdep.c.
Compile tested for i386 and amd64. No regression expected.
diffstat:
sys/arch/amd64/amd64/machdep.c | 16 ++++++++--------
sys/arch/i386/i386/machdep.c | 14 +++++++-------
2 files changed, 15 insertions(+), 15 deletions(-)
diffs (129 lines):
diff -r 3b555e8faba2 -r baa8d0b18a3d sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Mon Mar 01 01:15:23 2010 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Mon Mar 01 01:35:11 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.142 2010/02/08 19:02:26 joerg Exp $ */
+/* $NetBSD: machdep.c,v 1.143 2010/03/01 01:35:11 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.142 2010/02/08 19:02:26 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.143 2010/03/01 01:35:11 jym Exp $");
/* #define XENDEBUG_LOW */
@@ -906,7 +906,7 @@
if ((error = cpu_dump()) != 0)
goto err;
- totalbytesleft = ptoa(cpu_dump_mempagecnt());
+ totalbytesleft = ctob(cpu_dump_mempagecnt());
blkno = dumplo + cpu_dumpsize();
dump = bdev->d_dump;
error = 0;
@@ -1151,7 +1151,7 @@
for (x = 0; x < vm_nphysseg; x++) {
vps = &vm_physmem[x];
- if (ptoa(vps->avail_end) == avail_end)
+ if (ctob(vps->avail_end) == avail_end)
break;
}
if (x == vm_nphysseg)
@@ -1159,12 +1159,12 @@
/* Shrink so it'll fit in the last segment. */
if ((vps->avail_end - vps->avail_start) < atop(sz))
- sz = ptoa(vps->avail_end - vps->avail_start);
+ sz = ctob(vps->avail_end - vps->avail_start);
vps->avail_end -= atop(sz);
vps->end -= atop(sz);
msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
- msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end);
+ msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(vps->avail_end);
/* Remove the last segment if it now has no pages. */
if (vps->start == vps->end) {
@@ -1176,7 +1176,7 @@
for (avail_end = 0, x = 0; x < vm_nphysseg; x++)
if (vm_physmem[x].avail_end > avail_end)
avail_end = vm_physmem[x].avail_end;
- avail_end = ptoa(avail_end);
+ avail_end = ctob(avail_end);
if (sz == reqsz)
return;
@@ -1293,7 +1293,7 @@
/* Determine physical address space */
avail_start = first_avail;
- avail_end = ptoa(xen_start_info.nr_pages);
+ avail_end = ctob(xen_start_info.nr_pages);
pmap_pa_start = (KERNTEXTOFF - KERNBASE);
pmap_pa_end = avail_end;
__PRINTK(("pmap_pa_start 0x%lx avail_start 0x%lx avail_end 0x%lx\n",
diff -r 3b555e8faba2 -r baa8d0b18a3d sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Mon Mar 01 01:15:23 2010 +0000
+++ b/sys/arch/i386/i386/machdep.c Mon Mar 01 01:35:11 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.683 2010/03/01 01:15:23 jym Exp $ */
+/* $NetBSD: machdep.c,v 1.684 2010/03/01 01:35:11 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.683 2010/03/01 01:15:23 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.684 2010/03/01 01:35:11 jym Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -1188,7 +1188,7 @@
vps = NULL;
for (x = 0; x < vm_nphysseg; ++x) {
vps = &vm_physmem[x];
- if (ptoa(vps->avail_end) == avail_end) {
+ if (ctob(vps->avail_end) == avail_end) {
break;
}
}
@@ -1197,12 +1197,12 @@
/* Shrink so it'll fit in the last segment. */
if (vps->avail_end - vps->avail_start < atop(sz))
- sz = ptoa(vps->avail_end - vps->avail_start);
+ sz = ctob(vps->avail_end - vps->avail_start);
vps->avail_end -= atop(sz);
vps->end -= atop(sz);
msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
- msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end);
+ msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(vps->avail_end);
/* Remove the last segment if it now has no pages. */
if (vps->start == vps->end) {
@@ -1214,7 +1214,7 @@
for (avail_end = 0, x = 0; x < vm_nphysseg; x++)
if (vm_physmem[x].avail_end > avail_end)
avail_end = vm_physmem[x].avail_end;
- avail_end = ptoa(avail_end);
+ avail_end = ctob(avail_end);
if (sz == reqsz)
return;
@@ -1386,7 +1386,7 @@
/* Make sure the end of the space used by the kernel is rounded. */
first_avail = round_page(first_avail);
avail_start = first_avail;
- avail_end = ptoa(xen_start_info.nr_pages) + XPMAP_OFFSET;
+ avail_end = ctob(xen_start_info.nr_pages) + XPMAP_OFFSET;
pmap_pa_start = (KERNTEXTOFF - KERNBASE);
pmap_pa_end = avail_end;
mem_clusters[0].start = avail_start;
Home |
Main Index |
Thread Index |
Old Index