diff mbox series

[PATCHv2,5/7] x86/mm: Reserve unaccepted memory bitmap

Message ID 20220111113314.27173-6-kirill.shutemov@linux.intel.com
State New
Headers show
Series Implement support for unaccepted memory | expand

Commit Message

Kirill A. Shutemov Jan. 11, 2022, 11:33 a.m. UTC
Unaccepted memory bitmap is allocated during decompression stage and
handed over to main kernel image via boot_params. The bitmap is used to
track if memory has been accepted.

Reserve unaccepted memory bitmap has to prevent reallocating memory for
other means.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 arch/x86/kernel/e820.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index bc0657f0deed..dc9048e2d421 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1290,6 +1290,16 @@  void __init e820__memory_setup(void)
 
 	pr_info("BIOS-provided physical RAM map:\n");
 	e820__print_table(who);
+
+	/* Mark unaccepted memory bitmap reserved */
+	if (boot_params.unaccepted_memory) {
+		unsigned long size;
+
+		/* One bit per 2MB */
+		size = DIV_ROUND_UP(e820__end_of_ram_pfn() * PAGE_SIZE,
+				    PMD_SIZE * BITS_PER_BYTE);
+		memblock_reserve(boot_params.unaccepted_memory, size);
+	}
 }
 
 void __init e820__memblock_setup(void)