[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 00/10] ppc64: Restrict memory allocations for kernel and i
From: |
Stefan Berger |
Subject: |
Re: [PATCH v7 00/10] ppc64: Restrict memory allocations for kernel and initrd |
Date: |
Mon, 27 Nov 2023 09:26:59 -0500 |
User-agent: |
Mozilla Thunderbird |
On 11/27/23 06:58, Stefan Berger wrote:
This series of patches converts the PowerPC ieee1275 memory allocator
for kernel and initrd to use the (PowerPC) regions_claim memory allocator
that takes into account memory regions that are not allowed to be used,
such as the gap between 640MB and 768MB as well as memory regions beyond
an address in case an fadump is present. Otherwise those two could be
loaded into restricted memory regions and either cause a crash or
corruption of the fadump.
I adjusted the kernel and initrd load in loader/powerpc/ieee1275 to use
the new memory allocator only on PowerVM and PowerKVM since this code is
shared with other platforms, such as old PowerMACs and i386.
Regards,
Stefan
v7:
- 1/10: Move header file to include/grub/ieee1275/alloc.h for ieee1275/i386
- 6/10: Make new #defines available for ieee1275/i386 but set KVM on Power
flag only if __powerpc__ is defined
This is the diff between v6 and v7:
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 4f9f3f963..fc9fc6a90 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -153,6 +153,7 @@ endif
if COND_i386_ieee1275
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/alloc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
@@ -240,7 +241,7 @@ endif
if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
-KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/powerpc/ieee1275/alloc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/alloc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
diff --git a/grub-core/kern/ieee1275/cmain.c
b/grub-core/kern/ieee1275/cmain.c
index cc7c32873..e74de3248 100644
--- a/grub-core/kern/ieee1275/cmain.c
+++ b/grub-core/kern/ieee1275/cmain.c
@@ -196,7 +196,9 @@ grub_ieee1275_find_options (void)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM);
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF);
+#if defined(__powerpc__)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_POWER_KVM);
+#endif
}
}
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 72e0292a3..a3cb2a11a 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -46,8 +46,8 @@
#ifdef __sparc__
#include <grub/machine/kernel.h>
#endif
-#ifdef __powerpc__
-#include <grub/powerpc/ieee1275/alloc.h>
+#if defined(__powerpc__) || defined(__i386__)
+#include <grub/ieee1275/alloc.h>
#endif
/* The maximum heap size we're going to claim at boot. Not used by
sparc. */
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c
b/grub-core/loader/powerpc/ieee1275/linux.c
index de174416d..4864e5fb0 100644
--- a/grub-core/loader/powerpc/ieee1275/linux.c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -30,7 +30,7 @@
#include <grub/lib/cmdline.h>
#include <grub/cache.h>
#include <grub/linux.h>
-#include <grub/powerpc/ieee1275/alloc.h>
+#include <grub/ieee1275/alloc.h>
GRUB_MOD_LICENSE ("GPLv3+");
diff --git a/include/grub/powerpc/ieee1275/alloc.h
b/include/grub/ieee1275/alloc.h
similarity index 87%
rename from include/grub/powerpc/ieee1275/alloc.h
rename to include/grub/ieee1275/alloc.h
index c7fee55df..67a785657 100644
--- a/include/grub/powerpc/ieee1275/alloc.h
+++ b/include/grub/ieee1275/alloc.h
@@ -1,4 +1,4 @@
-/* alloc.h - Memory allocation for PowerVM/KVM */
+/* alloc.h - Memory allocation for PowerVM, KVM on Power, and i386 */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2023 Free Software Foundation, Inc.
@@ -18,8 +18,8 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GRUB_POWERPC_IEEE1275_ALLOC_HEADER
-#define GRUB_POWERPC_IEEE1275_ALLOC_HEADER 1
+#ifndef GRUB_IEEE1275_ALLOC_HEADER
+#define GRUB_IEEE1275_ALLOC_HEADER 1
#include <stdbool.h>
@@ -36,4 +36,4 @@ struct regions_claim_request {
int EXPORT_FUNC(grub_regions_claim) (grub_uint64_t addr, grub_uint64_t
len,
grub_memory_type_t type, void *data);
-#endif /* GRUB_POWERPC_IEEE1275_ALLOC_HEADER */
+#endif /* GRUB_IEEE1275_ALLOC_HEADER */
diff --git a/include/grub/ieee1275/ieee1275.h
b/include/grub/ieee1275/ieee1275.h
index 5b7a36ad8..dddb38514 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -140,11 +140,11 @@ enum grub_ieee1275_flag
* only 256MB in size, try asking for more with CAS.
*/
GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY,
+#endif
GRUB_IEEE1275_FLAG_POWER_VM,
GRUB_IEEE1275_FLAG_POWER_KVM,
-#endif
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum
grub_ieee1275_flag flag);
- [PATCH v7 05/10] kern/ieee1275/init: ppc64: Rename regions_claim to grub_regions_claim, (continued)
- [PATCH v7 05/10] kern/ieee1275/init: ppc64: Rename regions_claim to grub_regions_claim, Stefan Berger, 2023/11/27
- [PATCH v7 03/10] kern/ieee1275/init: ppc64: Return allocated address using context, Stefan Berger, 2023/11/27
- [PATCH v7 08/10] kern/ieee1275/ieee1275: debug: Display successful memory claims, Stefan Berger, 2023/11/27
- [PATCH v7 01/10] kern/ieee1275/init: ppc64: Introduce a request for regions_claim, Stefan Berger, 2023/11/27
- [PATCH v7 09/10] kern/ieee1275/init: ppc64: Fix a comment, Stefan Berger, 2023/11/27
- [PATCH v7 10/10] kern/ieee1275/init: ppc64: Display upper_mem_limit for debugging, Stefan Berger, 2023/11/27
- [PATCH v7 06/10] kern/ieee1275/cmain: ppc64: Introduce flags to identify KVM and Power VM, Stefan Berger, 2023/11/27
- Re: [PATCH v7 00/10] ppc64: Restrict memory allocations for kernel and initrd, John Paul Adrian Glaubitz, 2023/11/27
- Re: [PATCH v7 00/10] ppc64: Restrict memory allocations for kernel and initrd,
Stefan Berger <=
- Re: [PATCH v7 00/10] ppc64: Restrict memory allocations for kernel and initrd, Daniel Kiper, 2023/11/30