OBP available region contains grub. Start at grub_phys_end.

This prevents a problem where grub was being overwritten since
grub_phys_start does not start at a zero offset within the memory
map.
This commit is contained in:
Eric Snowberg 2016-02-12 23:16:03 +01:00 committed by Vladimir Serbinenko
parent f96b34224e
commit 080a20861c

View file

@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
if (addr + ctx->size >= end) if (addr + ctx->size >= end)
return 0; return 0;
if (addr >= grub_phys_start && addr < grub_phys_end) /* OBP available region contains grub. Start at grub_phys_end. */
{ /* grub_phys_start does not start at the beginning of the memory region */
addr = ALIGN_UP (grub_phys_end, FOUR_MB); if ((grub_phys_start >= addr && grub_phys_end < end) ||
if (addr + ctx->size >= end) (addr > grub_phys_start && addr < grub_phys_end))
return 0;
}
if ((addr + ctx->size) >= grub_phys_start
&& (addr + ctx->size) < grub_phys_end)
{ {
addr = ALIGN_UP (grub_phys_end, FOUR_MB); addr = ALIGN_UP (grub_phys_end, FOUR_MB);
if (addr + ctx->size >= end) if (addr + ctx->size >= end)
return 0; return 0;
} }
grub_dprintf("loader",
"addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n",
addr, grub_phys_start, grub_phys_end);
if (loaded) if (loaded)
{ {
grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB); grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB);