Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Axtens <dja@axtens.net>
Date: Wed, 28 Oct 2020 11:44:29 +1100
Subject: [PATCH] ieee1275: claim up to 256MB memory

If we are verifying large kernels, we need more that 32MB. (Many distro
kernels are quite large, and debug kernels can be even bigger!)

We originally went with 512MB: qemu pseries gives you all the memory a
32-bit number can handle, so there was lots left over to place a linux image
and initrd.

Here's what we said then:
| This is possibly not the way we want to go with for upstream as it breaks
| booting on systems with <= 512MB. We're working on a more upstream-friendly
| solution and will post it shortly. However, for an end-user or packager with
| a higher minimum memory requirement, this will work fine.

However, we've since discovered that (at least on one P8 test system), PFW
doesn't expose all of the memory allocated to the LPAR: it looks like it just
exposes 512MB - at least unless we mess with the CHRP note section.
Therefore, if we try to claim 512MB in grub, things _do not_ work when we try
to load linux. As a compromise, and again we'd like a better upstream solution,
go for 256MB. This is at least enough to verify distro kernels.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 grub-core/kern/ieee1275/init.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index e731a57a47b..f8a4f8f4214 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -49,15 +49,13 @@
 #ifdef __i386__
 #define HEAP_MAX_SIZE		(unsigned long) (64 * 1024 * 1024)
 #else
-#define HEAP_MAX_SIZE		(unsigned long) (32 * 1024 * 1024)
+#define HEAP_MAX_SIZE		(unsigned long) (256 * 1024 * 1024)
 #endif
 
-/* If possible, we will avoid claiming heap above this address, because it
-   seems to cause relocation problems with OSes that link at 4 MiB */
 #ifdef __i386__
 #define HEAP_MAX_ADDR		(unsigned long) (64 * 1024 * 1024)
 #else
-#define HEAP_MAX_ADDR		(unsigned long) (32 * 1024 * 1024)
+#define HEAP_MAX_ADDR		(unsigned long) (256 * 1024 * 1024)
 #endif
 
 extern char _end[];