Ensure we don't overflow the phys_avail array. Some firmware may provide
more memory locations than we have space to record. Sponsored by: ABT Systems Ltd
This commit is contained in:
parent
50d9282660
commit
332b343376
@ -596,7 +596,8 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
|
|||||||
* up to the physical address KERNBASE points at.
|
* up to the physical address KERNBASE points at.
|
||||||
*/
|
*/
|
||||||
map_slot = avail_slot = 0;
|
map_slot = avail_slot = 0;
|
||||||
for (; map_slot < (physmap_idx * 2); map_slot += 2) {
|
for (; map_slot < (physmap_idx * 2) &&
|
||||||
|
avail_slot < (PHYS_AVAIL_SIZE - 2); map_slot += 2) {
|
||||||
if (physmap[map_slot] == physmap[map_slot + 1])
|
if (physmap[map_slot] == physmap[map_slot + 1])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -612,7 +613,7 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add the memory before the kernel */
|
/* Add the memory before the kernel */
|
||||||
if (physmap[avail_slot] < pa) {
|
if (physmap[avail_slot] < pa && avail_slot < (PHYS_AVAIL_SIZE - 2)) {
|
||||||
phys_avail[avail_slot] = physmap[map_slot];
|
phys_avail[avail_slot] = physmap[map_slot];
|
||||||
phys_avail[avail_slot + 1] = pa;
|
phys_avail[avail_slot + 1] = pa;
|
||||||
physmem += (phys_avail[avail_slot + 1] -
|
physmem += (phys_avail[avail_slot + 1] -
|
||||||
|
Loading…
x
Reference in New Issue
Block a user