Blame SOURCES/0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch

8e15ce
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8e15ce
From: Daniel Axtens <dja@axtens.net>
8e15ce
Date: Wed, 14 Apr 2021 20:10:23 +1000
8e15ce
Subject: [PATCH] ieee1275: drop HEAP_MAX_ADDR, HEAP_MIN_SIZE
8e15ce
8e15ce
HEAP_MAX_ADDR is confusing. Currently it is set to 32MB, except
8e15ce
on ieee1275 on x86, where it is 64MB.
8e15ce
8e15ce
There is a comment which purports to explain it:
8e15ce
8e15ce
/* If possible, we will avoid claiming heap above this address, because it
8e15ce
   seems to cause relocation problems with OSes that link at 4 MiB */
8e15ce
8e15ce
This doesn't make a lot of sense when the constants are well above 4MB
8e15ce
already. It was not always this way. Prior to
8e15ce
commit 7b5d0fe4440c ("Increase heap limit") in 2010, HEAP_MAX_SIZE and
8e15ce
HEAP_MAX_ADDR were indeed 4MB. However, when the constants were increased
8e15ce
the comment was left unchanged.
8e15ce
8e15ce
It's been over a decade. It doesn't seem like we have problems with
8e15ce
claims over 4MB on powerpc or x86 ieee1275. (sparc does things completely
8e15ce
differently and never used the constant.)
8e15ce
8e15ce
Drop the constant and the check.
8e15ce
8e15ce
The only use of HEAP_MIN_SIZE was to potentially override the
8e15ce
HEAP_MAX_ADDR check. It is now unused. Remove it.
8e15ce
8e15ce
Signed-off-by: Daniel Axtens <dja@axtens.net>
8e15ce
---
8e15ce
 grub-core/kern/ieee1275/init.c | 17 -----------------
8e15ce
 1 file changed, 17 deletions(-)
8e15ce
8e15ce
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
b35c50
index fc7d971272..0dcd114ce5 100644
8e15ce
--- a/grub-core/kern/ieee1275/init.c
8e15ce
+++ b/grub-core/kern/ieee1275/init.c
8e15ce
@@ -46,9 +46,6 @@
8e15ce
 #endif
8e15ce
 #include <grub/lockdown.h>
8e15ce
 
8e15ce
-/* The minimal heap size we can live with. */
8e15ce
-#define HEAP_MIN_SIZE		(unsigned long) (2 * 1024 * 1024)
8e15ce
-
8e15ce
 /* The maximum heap size we're going to claim */
8e15ce
 #ifdef __i386__
8e15ce
 #define HEAP_MAX_SIZE		(unsigned long) (64 * 1024 * 1024)
8e15ce
@@ -56,14 +53,6 @@
8e15ce
 #define HEAP_MAX_SIZE		(unsigned long) (32 * 1024 * 1024)
8e15ce
 #endif
8e15ce
 
8e15ce
-/* If possible, we will avoid claiming heap above this address, because it
8e15ce
-   seems to cause relocation problems with OSes that link at 4 MiB */
8e15ce
-#ifdef __i386__
8e15ce
-#define HEAP_MAX_ADDR		(unsigned long) (64 * 1024 * 1024)
8e15ce
-#else
8e15ce
-#define HEAP_MAX_ADDR		(unsigned long) (32 * 1024 * 1024)
8e15ce
-#endif
8e15ce
-
8e15ce
 extern char _end[];
8e15ce
 
8e15ce
 #ifdef __sparc__
8e15ce
@@ -185,12 +174,6 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
8e15ce
   if (*total + len > HEAP_MAX_SIZE)
8e15ce
     len = HEAP_MAX_SIZE - *total;
8e15ce
 
8e15ce
-  /* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */
8e15ce
-  if ((addr < HEAP_MAX_ADDR) &&				/* if it's too late, don't bother */
8e15ce
-      (addr + len > HEAP_MAX_ADDR) &&				/* if it wasn't available anyway, don't bother */
8e15ce
-      (*total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE))	/* only limit ourselves when we can afford to */
8e15ce
-     len = HEAP_MAX_ADDR - addr;
8e15ce
-
8e15ce
   /* In theory, firmware should already prevent this from happening by not
8e15ce
      listing our own image in /memory/available.  The check below is intended
8e15ce
      as a safeguard in case that doesn't happen.  However, it doesn't protect