mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <>
Cc:, Ahmad Fatoum <>
Subject: [PATCH 03/10] memory: define reserve_sdram_region helper
Date: Mon, 15 Aug 2022 17:32:02 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

We use request_sdram_regions both for code that barebox wants to use for
itself (e.g. barebox stack or initrd) and to reserve regions for secure
firmware that barebox shouldn't overwrite. We need to differentiate
between them, so we can apply difference caching flags depending on
region, so add a new reserve_sdram_region helper that may be used and
also add an for_each_reserved_region iterator for use in the MMU code
that applied the different caching flags later on.

Signed-off-by: Ahmad Fatoum <>
 include/memory.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/memory.h b/include/memory.h
index 31da5d74d568..ffd66db02ba0 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -4,6 +4,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/ioport.h>
 void mem_malloc_init(void *start, void *end);
 ulong mem_malloc_start(void);
@@ -22,6 +23,9 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
 				    resource_size_t size);
 #define for_each_memory_bank(mem)	list_for_each_entry(mem, &memory_banks, list)
+#define for_each_reserved_region(mem, rsv) \
+	list_for_each_entry(rsv, &(mem)->res->children, sibling) \
+	if (((rsv)->flags & IORESOURCE_BUSY))
 struct resource *__request_sdram_region(const char *name, unsigned flags,
 					resource_size_t start, resource_size_t size);
@@ -34,6 +38,14 @@ static inline struct resource *request_sdram_region(const char *name,
 	return __request_sdram_region(name, 0, start, size);
+/* use for secure firmware to inhibit speculation */
+static inline struct resource *reserve_sdram_region(const char *name,
+						    resource_size_t start,
+						    resource_size_t size)
+	return __request_sdram_region(name, IORESOURCE_BUSY, start, size);
 int release_sdram_region(struct resource *res);
 void memory_bank_find_space(struct memory_bank *bank, resource_size_t *retstart,

  parent reply	other threads:[~2022-08-15 15:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 15:31 [PATCH 00/10] ARM: mmu: inhibit speculation into secure memory Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 01/10] resource: add flags parameter to __request_region Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 02/10] common: allow requesting SDRAM regions with custom flags Ahmad Fatoum
2022-08-16  7:35   ` Ulrich Ölmann
2022-08-15 15:32 ` Ahmad Fatoum [this message]
2022-08-16  8:46   ` [PATCH 03/10] memory: define reserve_sdram_region helper Sascha Hauer
2022-08-15 15:32 ` [PATCH 04/10] init: define new postmem_initcall() Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 05/10] of: reserved-mem: reserve regions prior to mmu_initcall() Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 06/10] ARM: mmu64: map reserved regions uncached Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 07/10] ARM: mmu: define attrs_uncached_mem() helper Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 08/10] ARM: mmu: use reserve mem entries to modify maps Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 09/10] ARM: early-mmu: don't cache/prefetch OPTEE_SIZE bytes from end of memory Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 10/10] commands: iomem: point out [R]eserved regions Ahmad Fatoum

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox