summaryrefslogtreecommitdiffstats
path: root/sys/sun4v
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2006-12-09 23:11:30 +0000
committerkmacy <kmacy@FreeBSD.org>2006-12-09 23:11:30 +0000
commita890a19a05e940554007739163e7e62992767e13 (patch)
treeb9dfb84cbb94c1bc1d3f919953ee5ff205663513 /sys/sun4v
parent516c13f08d06fc735cb873bac1b6c15a75b91407 (diff)
downloadFreeBSD-src-a890a19a05e940554007739163e7e62992767e13.zip
FreeBSD-src-a890a19a05e940554007739163e7e62992767e13.tar.gz
Fix handling of the hw.physmem loader variable use real_phys_avail[] which
is already bounded by hw.physmem to calculate phys_avail[] - previously only real_phys_avail[] was being bound by hw.physmem so we were allocating memory that wasn't mapped in the direct map
Diffstat (limited to 'sys/sun4v')
-rw-r--r--sys/sun4v/sun4v/pmap.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/sys/sun4v/sun4v/pmap.c b/sys/sun4v/sun4v/pmap.c
index 76654e4..f611abf 100644
--- a/sys/sun4v/sun4v/pmap.c
+++ b/sys/sun4v/sun4v/pmap.c
@@ -553,25 +553,7 @@ pmap_bootstrap(vm_offset_t ekva)
j += 2;
}
physmem = btoc(physsz);
- /*
- * Merge nucleus memory in to real_phys_avail
- *
- */
- for (i = 0; real_phys_avail[i] != 0; i += 2) {
- if (real_phys_avail[i] == nucleus_memory_start + nucleus_memory)
- real_phys_avail[i] -= nucleus_memory;
-
- if (real_phys_avail[i + 1] == nucleus_memory_start)
- real_phys_avail[i + 1] += nucleus_memory;
-
- if (real_phys_avail[i + 1] == real_phys_avail[i + 2]) {
- real_phys_avail[i + 1] = real_phys_avail[i + 3];
- for (k = i + 2; real_phys_avail[k] != 0; k += 2) {
- real_phys_avail[k] = real_phys_avail[k + 2];
- real_phys_avail[k + 1] = real_phys_avail[k + 3];
- }
- }
- }
+
/*
@@ -579,27 +561,22 @@ pmap_bootstrap(vm_offset_t ekva)
* and then forget to remove it from the available ranges ...
* as well as for compensating for the above move of nucleus pages
*/
-
- for (i = 0, j = 0; i < sz; i++) {
- vm_paddr_t start = mra[i].mr_start;
- uint64_t size = mra[i].mr_size;
+ for (i = 0; real_phys_avail[i] != 0; i += 2) {
+ vm_paddr_t start = real_phys_avail[i];
+ uint64_t size = real_phys_avail[i + 1] - real_phys_avail[i];
CTR2(KTR_PMAP, "start=%#lx size=%#lx\n", mra[i].mr_start, mra[i].mr_size);
KDPRINTF("start=%#lx size=%#lx\n", mra[i].mr_start, mra[i].mr_size);
-
- if (mra[i].mr_size < PAGE_SIZE_4M)
- continue;
/*
* Is kernel memory at the beginning of range?
*/
- if (nucleus_memory_start == mra[i].mr_start) {
- mra[i].mr_start += nucleus_memory;
- mra[i].mr_size -= nucleus_memory;
+ if (nucleus_memory_start == start) {
+ start = start + nucleus_memory;
}
/*
* Is kernel memory at the end of range?
*/
if (nucleus_memory_start == (start + size - nucleus_memory))
- mra[i].mr_size -= nucleus_memory;
+ size -= nucleus_memory;
/*
* Is kernel memory in the middle somewhere?
@@ -609,16 +586,34 @@ pmap_bootstrap(vm_offset_t ekva)
uint64_t firstsize = (nucleus_memory_start - start);
phys_avail[j] = start;
phys_avail[j+1] = nucleus_memory_start;
+ start = nucleus_memory_start + nucleus_memory;
size = size - firstsize - nucleus_memory;
- mra[i].mr_start = nucleus_memory_start + nucleus_memory;
- mra[i].mr_size = size;
j += 2;
}
- phys_avail[j] = mra[i].mr_start;
- phys_avail[j + 1] = mra[i].mr_start + mra[i].mr_size;
+ phys_avail[j] = start;
+ phys_avail[j + 1] = start + size;
j += 2;
}
+ /*
+ * Merge nucleus memory in to real_phys_avail
+ *
+ */
+ for (i = 0; real_phys_avail[i] != 0; i += 2) {
+ if (real_phys_avail[i] == nucleus_memory_start + nucleus_memory)
+ real_phys_avail[i] -= nucleus_memory;
+
+ if (real_phys_avail[i + 1] == nucleus_memory_start)
+ real_phys_avail[i + 1] += nucleus_memory;
+
+ if (real_phys_avail[i + 1] == real_phys_avail[i + 2]) {
+ real_phys_avail[i + 1] = real_phys_avail[i + 3];
+ for (k = i + 2; real_phys_avail[k] != 0; k += 2) {
+ real_phys_avail[k] = real_phys_avail[k + 2];
+ real_phys_avail[k + 1] = real_phys_avail[k + 3];
+ }
+ }
+ }
for (i = 0; phys_avail[i] != 0; i += 2)
if (pmap_debug_range || pmap_debug)
printf("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n",
OpenPOWER on IntegriCloud