mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: rcz@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 04/10] init: define new postmem_initcall()
Date: Mon, 15 Aug 2022 17:32:03 +0200	[thread overview]
Message-ID: <20220815153209.2422662-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220815153209.2422662-1-a.fatoum@pengutronix.de>

Memory banks are added in mem_initcall() and are used in mmu_initcall()
which directly follows it to set caching attributes for the banks.

Code that requires memory banks to be registered, thus has to use
mmu_initcall(), but this is not possible for code that reliably needs to
run before MMU init: We need to give board code and device tree parsing
code the chance to reserve_sdram_region parts of SDRAM that contain
secure firmware to avoid speculative execution into them once the MMU is
turned on. For this reason, define a new postmem_initcall() level and
already use it for add_mem_devices, which has nothing to do with
mmu_initcall. Another user that can't be mmu_initcall() will follow in a
later commit.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/memory.c                   |  2 +-
 include/asm-generic/barebox.lds.h |  1 +
 include/init.h                    | 21 +++++++++++----------
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/common/memory.c b/common/memory.c
index 347f83fd4cf8..40c795d2cde1 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -195,7 +195,7 @@ static int add_mem_devices(void)
 
 	return 0;
 }
-mmu_initcall(add_mem_devices);
+postmem_initcall(add_mem_devices);
 
 /*
  * Request a region from the registered sdram
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index a22e251c9d64..48c10b173852 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -35,6 +35,7 @@
 	KEEP(*(.initcall.13))			\
 	KEEP(*(.initcall.14))			\
 	KEEP(*(.initcall.15))			\
+	KEEP(*(.initcall.16))			\
 	__barebox_initcalls_end = .;
 
 #define BAREBOX_EXITCALLS			\
diff --git a/include/init.h b/include/init.h
index c695f99867ff..d0343fdf05cc 100644
--- a/include/init.h
+++ b/include/init.h
@@ -58,16 +58,17 @@ typedef void (*exitcall_t)(void);
 #define console_initcall(fn)		__define_initcall("3",fn,3)
 #define postconsole_initcall(fn)	__define_initcall("4",fn,4)
 #define mem_initcall(fn)		__define_initcall("5",fn,5)
-#define mmu_initcall(fn)		__define_initcall("6",fn,6)
-#define postmmu_initcall(fn)		__define_initcall("7",fn,7)
-#define coredevice_initcall(fn)		__define_initcall("8",fn,8)
-#define fs_initcall(fn)			__define_initcall("9",fn,9)
-#define device_initcall(fn)		__define_initcall("10",fn,10)
-#define crypto_initcall(fn)		__define_initcall("11",fn,11)
-#define of_populate_initcall(fn)	__define_initcall("12",fn,12)
-#define late_initcall(fn)		__define_initcall("13",fn,13)
-#define environment_initcall(fn)	__define_initcall("14",fn,14)
-#define postenvironment_initcall(fn)	__define_initcall("15",fn,15)
+#define postmem_initcall(fn)		__define_initcall("6",fn,6)
+#define mmu_initcall(fn)		__define_initcall("7",fn,7)
+#define postmmu_initcall(fn)		__define_initcall("8",fn,8)
+#define coredevice_initcall(fn)		__define_initcall("9",fn,9)
+#define fs_initcall(fn)			__define_initcall("10",fn,10)
+#define device_initcall(fn)		__define_initcall("11",fn,11)
+#define crypto_initcall(fn)		__define_initcall("12",fn,12)
+#define of_populate_initcall(fn)	__define_initcall("13",fn,13)
+#define late_initcall(fn)		__define_initcall("14",fn,14)
+#define environment_initcall(fn)	__define_initcall("15",fn,15)
+#define postenvironment_initcall(fn)	__define_initcall("16",fn,16)
 
 #define early_exitcall(fn)		__define_exitcall("0",fn,0)
 #define predevshutdown_exitcall(fn)	__define_exitcall("1",fn,1)
-- 
2.30.2




  parent reply	other threads:[~2022-08-15 15:41 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 ` [PATCH 03/10] memory: define reserve_sdram_region helper Ahmad Fatoum
2022-08-16  8:46   ` Sascha Hauer
2022-08-15 15:32 ` Ahmad Fatoum [this message]
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:
  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=20220815153209.2422662-5-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rcz@pengutronix.de \
    /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
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