All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sparc64: OBP available region contains grub. Start at grub_phys_end
@ 2016-02-12 21:35 Eric Snowberg
  2016-02-12 22:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2016-02-13  5:30 ` Andrei Borzenkov
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Snowberg @ 2016-02-12 21:35 UTC (permalink / raw)
  To: grub-devel; +Cc: Eric Snowberg, daniel.kiper

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.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/loader/sparc64/ieee1275/linux.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
index d44d7a1..67ef048 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);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-13 23:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12 21:35 [PATCH] sparc64: OBP available region contains grub. Start at grub_phys_end Eric Snowberg
2016-02-12 22:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-13  5:30 ` Andrei Borzenkov
2016-02-13 13:56   ` Vladimir 'phcoder' Serbinenko
2016-02-13 14:49     ` Andrei Borzenkov
2016-02-13 16:03   ` Eric Snowberg
2016-02-13 16:06     ` Vladimir 'phcoder' Serbinenko
2016-02-13 23:26       ` Eric Snowberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.