]> git.ipfire.org Git - thirdparty/grub.git/commit
kern/ieee1275/init: Restrict high memory in presence of fadump on ppc64
authorStefan Berger <stefanb@linux.ibm.com>
Wed, 4 Oct 2023 15:32:35 +0000 (11:32 -0400)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 12 Oct 2023 16:54:58 +0000 (18:54 +0200)
commit4bcf6f747c3ab0b998c6f5a361804e38bc9c4334
tree39ea333c4d077d7f58098cd13c6d21fada25fa39
parentcf58eca2a2f55a8086a7cbd37c5b6435c168548a
kern/ieee1275/init: Restrict high memory in presence of fadump on ppc64

When a kernel dump is present then restrict the high memory regions to
avoid allocating memory where the kernel dump resides. Use the
ibm,kernel-dump node under /rtas to determine whether a kernel dump
exists and up to which limit GRUB can use available memory. Set the
upper_mem_limit to the size of the kernel dump section of type
REAL_MODE_REGION and therefore only allow GRUB's memory usage for high
addresses from RMO_ADDR_MAX to upper_mem_limit. This means that GRUB can
use high memory in the range of RMO_ADDR_MAX (768MB) to upper_mem_limit
and the kernel-dump memory regions above upper_mem_limit remain
untouched. This change has no effect on memory allocations below
linux_rmo_save (typically at 640MB).

Also, fall back to allocating below rmo_linux_save in case the chunk of
memory there would be larger than the chunk of memory above RMO_ADDR_MAX.
This can for example occur if a free memory area is found starting at 300MB
extending up to 1GB but a kernel dump is located at 768MB and therefore
does not allow the allocation of the high memory area but requiring to use
the chunk starting at 300MB to avoid an unnecessary out-of-memory condition.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
Cc: Pavithra Prakash <pavrampu@in.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Carolyn Scherrer <cpscherr@us.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/ieee1275/init.c