From 080a20861c08397bfef5eb1471b6124a82a0777c Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Fri, 12 Feb 2016 23:16:03 +0100 Subject: [PATCH] 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. --- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index d44d7a113..67ef04883 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, if (addr + ctx->size >= end) return 0; - if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr = ALIGN_UP (grub_phys_end, FOUR_MB); - if (addr + ctx->size >= end) - return 0; - } - if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < 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 */ + if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end)) { addr = ALIGN_UP (grub_phys_end, FOUR_MB); if (addr + ctx->size >= end) 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) { grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB);