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

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