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

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