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

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