[PATCHv6 11/15] x86: Disable kexec if system has unaccepted memory

From: Kirill A. Shutemov
Date: Tue May 17 2022 - 11:36:58 EST


On kexec, the target kernel has to know what memory has been accepted.
Information in EFI map is out of date and cannot be used.

boot_params.unaccepted_memory can be used to pass the bitmap between two
kernels on kexec, but the use-case is not yet implemented.

Disable kexec on machines with unaccepted memory for now.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
---
arch/x86/mm/unaccepted_memory.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/x86/mm/unaccepted_memory.c b/arch/x86/mm/unaccepted_memory.c
index 1ca71eb98c24..b4c43e6089b0 100644
--- a/arch/x86/mm/unaccepted_memory.c
+++ b/arch/x86/mm/unaccepted_memory.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/kexec.h>
#include <linux/memblock.h>
#include <linux/mm.h>
#include <linux/pfn.h>
@@ -114,6 +115,15 @@ static int __init unaccepted_init(void)
if (!boot_params.unaccepted_memory)
return 0;

+#ifdef CONFIG_KEXEC_CORE
+ /*
+ * TODO: Information on memory acceptance status has to be communicated
+ * between kernel.
+ */
+ pr_warn("Disable kexec: not yet supported on systems with unaccepted memory\n");
+ kexec_load_disabled = 1;
+#endif
+
bitmap_size = e820__end_of_ram_pfn() * PAGE_SIZE / PMD_SIZE;
unaccepted_memory = __va(boot_params.unaccepted_memory);

--
2.35.1