Further tweaks to the ram_attach() routine:

- Use > 2^32 - 1 instead of >= when checking for memory regions above 4G.
- Skip SMAP entries > 4G on i386 rather than breaking out of the loop
  since SMAP entries are not guaranteed to be in order.
- Remove 'i' and loop over 'rid' directly in the dump_avail[] case.
- Only check for 4G regions in the dump_avail[] case on i386 if PAE is
  enabled since vm_paddr_t is 32-bit in the !PAE case.

Submitted by:	alc
This commit is contained in:
John Baldwin 2010-11-02 17:56:16 +00:00
parent 736fc28680
commit 239da85bbc
2 changed files with 9 additions and 10 deletions

View File

@ -1970,7 +1970,7 @@ add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp)
return (1);
#ifndef PAE
if (smap->base >= 0xffffffff) {
if (smap->base > 0xffffffff) {
printf("%uK of memory above 4GB ignored\n",
(u_int)(smap->length / 1024));
return (1);

View File

@ -674,7 +674,7 @@ ram_attach(device_t dev)
vm_paddr_t *p;
caddr_t kmdp;
uint32_t smapsize;
int error, i, rid;
int error, rid;
/* Retrieve the system memory map from the loader. */
kmdp = preload_search_by_type("elf kernel");
@ -699,8 +699,8 @@ ram_attach(device_t dev)
* Resources use long's to track resources, so
* we can't include memory regions above 4GB.
*/
if (smap->base >= ~0ul)
break;
if (smap->base > ~0ul)
continue;
#endif
error = bus_set_resource(dev, SYS_RES_MEMORY, rid,
smap->base, smap->length);
@ -727,24 +727,23 @@ ram_attach(device_t dev)
* instead of the start since the start address for the first
* segment is 0.
*/
for (i = 0, p = dump_avail; p[1] != 0; i++, p += 2) {
rid = i;
#ifdef __i386__
for (rid = 0, p = dump_avail; p[1] != 0; rid++, p += 2) {
#if defined(__i386__) && defined(PAE)
/*
* Resources use long's to track resources, so we can't
* include memory regions above 4GB.
*/
if (p[0] >= ~0ul)
if (p[0] > ~0ul)
break;
#endif
error = bus_set_resource(dev, SYS_RES_MEMORY, rid, p[0],
p[1] - p[0]);
if (error)
panic("ram_attach: resource %d failed set with %d", i,
panic("ram_attach: resource %d failed set with %d", rid,
error);
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0);
if (res == NULL)
panic("ram_attach: resource %d failed to attach", i);
panic("ram_attach: resource %d failed to attach", rid);
}
return (0);
}