[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250417221938.579452-3-jaszczyk@chromium.org>
Date: Thu, 17 Apr 2025 22:19:38 +0000
From: Grzegorz Jaszczyk <jaszczyk@...omium.org>
To: tglx@...utronix.de,
robh@...nel.org
Cc: mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
hpa@...or.com,
saravanak@...gle.com,
dmaluka@...omium.org,
bgrzesik@...gle.com,
jaszczyk@...gle.com,
ilpo.jarvinen@...ux.intel.com,
usamaarif642@...il.com,
linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
tnowicki@...gle.com,
mazurekm@...gle.com,
vineethrp@...gle.com
Subject: [PATCH 2/2] x86/of: add support for reserved memory defined by DT
From: Grzegorz Jaszczyk <jaszczyk@...gle.com>
The DT reserved-memory nodes can be present in DT as described in
Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml.
Similar to other architecture, which supports DT, there is a need to
create reserved memory regions for such nodes.
Additionally, the x86 architecture builds its memory map based on E820
description passed by bootloader and not on DT. Since x86 already has
some DT support and allows booting with both ACPI and DT at the same
time, let's register an arch specific hook which will validate if a
reserved-memory region passed by DT is valid (covered by E820 reserved
region entry).
Without this check, the reserved memory from DT could be successfully
registered, even though such a region could conflict with e820
description e.g. it could be described as E820_RAM and could be already
used at early x86 boot stage for memblock initialization (which happens
before DT parsing).
Co-developed-by: Bartłomiej Grzesik <bgrzesik@...gle.com>
Signed-off-by: Bartłomiej Grzesik <bgrzesik@...gle.com>
Signed-off-by: Grzegorz Jaszczyk <jaszczyk@...gle.com>
---
arch/x86/kernel/devicetree.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index dd8748c45529..0c2b95300c6a 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -18,6 +18,7 @@
#include <linux/of_pci.h>
#include <linux/initrd.h>
+#include <asm/e820/api.h>
#include <asm/irqdomain.h>
#include <asm/hpet.h>
#include <asm/apic.h>
@@ -289,6 +290,14 @@ static void __init x86_dtb_parse_smp_config(void)
dtb_apic_setup();
}
+static bool __init x86_is_region_reserved(phys_addr_t base, phys_addr_t size)
+{
+ if (!e820__mapped_all(base, base + size - 1, E820_TYPE_RESERVED))
+ return false;
+
+ return true;
+}
+
void __init x86_flattree_get_config(void)
{
#ifdef CONFIG_OF_EARLY_FLATTREE
@@ -307,6 +316,9 @@ void __init x86_flattree_get_config(void)
}
early_init_dt_verify(dt, __pa(dt));
+
+ early_init_set_rsv_region_verifier(x86_is_region_reserved);
+ early_init_fdt_scan_reserved_mem();
}
unflatten_and_copy_device_tree();
--
2.49.0.805.g082f7c87e0-goog
Powered by blists - more mailing lists