LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bert Vermeulen <bert@biot.com>
To: Russell King <linux@armlinux.org.uk>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Nicolas Pitre <nico@fluxnic.net>,
Ard Biesheuvel <ardb@kernel.org>, Bert Vermeulen <bert@biot.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: John Crispin <john@phrozen.org>
Subject: [PATCH v2] ARM: decompress: Use /memreserve/ DTS nodes when validating memory
Date: Tue, 7 Sep 2021 16:56:50 +0200 [thread overview]
Message-ID: <20210907145652.63362-1-bert@biot.com> (raw)
If the bootloader needs the start of memory to be preserved, for example
because it dropped the Trusted Firmware blob there, this chunk of memory
shouldn't be used by the kernel.
To avoid adding yet another SoC-specific text offset to arch/arm/Makefile,
this patch allows for a /memreserve/ entry in the DTS to mark off the
memory chunk instead.
Signed-off-by: Bert Vermeulen <bert@biot.com>
---
arch/arm/boot/compressed/fdt_check_mem_start.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/compressed/fdt_check_mem_start.c b/arch/arm/boot/compressed/fdt_check_mem_start.c
index 62450d824c3c..1d47de1e860b 100644
--- a/arch/arm/boot/compressed/fdt_check_mem_start.c
+++ b/arch/arm/boot/compressed/fdt_check_mem_start.c
@@ -64,7 +64,7 @@ uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
uint32_t addr_cells, size_cells, base;
uint32_t fdt_mem_start = 0xffffffff;
const fdt32_t *reg, *endp;
- uint64_t size, end;
+ uint64_t rsvaddr, size, end;
const char *type;
int offset, len;
@@ -74,6 +74,19 @@ uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
if (fdt_magic(fdt) != FDT_MAGIC)
return mem_start;
+ for (offset = fdt_off_mem_rsvmap(fdt); ; offset += 16) {
+ rsvaddr = get_val(fdt + offset, 2);
+ size = get_val(fdt + offset + 8, 2);
+
+ if (!rsvaddr && !size)
+ break;
+
+ end = rsvaddr + size;
+ if (mem_start >= rsvaddr && mem_start <= end)
+ /* Relocate past reserved block */
+ mem_start = round_up(end, SZ_2M);
+ }
+
/* There may be multiple cells on LPAE platforms */
addr_cells = get_cells(fdt, "#address-cells");
size_cells = get_cells(fdt, "#size-cells");
--
2.25.1
next reply other threads:[~2021-09-07 14:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 14:56 Bert Vermeulen [this message]
2021-09-07 15:09 ` Geert Uytterhoeven
2021-09-09 11:29 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210907145652.63362-1-bert@biot.com \
--to=bert@biot.com \
--cc=ardb@kernel.org \
--cc=geert+renesas@glider.be \
--cc=john@phrozen.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nico@fluxnic.net \
--subject='Re: [PATCH v2] ARM: decompress: Use /memreserve/ DTS nodes when validating memory' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).