From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH master 5/8] ARM: mmu: provide setup_trap_pages for both 32- and 64-bit
Date: Tue, 5 Aug 2025 19:45:38 +0200 [thread overview]
Message-ID: <20250805174541.2606267-6-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250805174541.2606267-1-a.fatoum@barebox.org>
In preparation for moving the remapping of memory banks into the common
code, rename vectors_init to setup_trap_pages and export it for both
32-bit and 64-bit ARM, so it can be called from the common code as well.
This needs to happen after the remapping, because otherwise the trap
pages would be switched cached by the SDRAM remapping loop.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/cpu/mmu-common.h | 1 +
arch/arm/cpu/mmu_32.c | 4 ++--
arch/arm/cpu/mmu_64.c | 12 +++++++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/arm/cpu/mmu-common.h b/arch/arm/cpu/mmu-common.h
index 3bca5cc3b821..f76c7c4c38d6 100644
--- a/arch/arm/cpu/mmu-common.h
+++ b/arch/arm/cpu/mmu-common.h
@@ -18,6 +18,7 @@ struct device;
void dma_inv_range(void *ptr, size_t size);
void dma_flush_range(void *ptr, size_t size);
void *dma_alloc_map(struct device *dev, size_t size, dma_addr_t *dma_handle, unsigned flags);
+void setup_trap_pages(void);
void __mmu_init(bool mmu_on);
static inline unsigned arm_mmu_maybe_skip_permissions(unsigned map_type)
diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
index 5f303ae1dc87..151e786c9b2d 100644
--- a/arch/arm/cpu/mmu_32.c
+++ b/arch/arm/cpu/mmu_32.c
@@ -542,7 +542,7 @@ static void create_guard_page(void)
/*
* Map vectors and zero page
*/
-static void vectors_init(void)
+void setup_trap_pages(void)
{
create_guard_page();
@@ -632,7 +632,7 @@ void __mmu_init(bool mmu_on)
remap_range((void *)pos, bank->start + bank->size - pos, MAP_CACHED);
}
- vectors_init();
+ setup_trap_pages();
remap_range((void *)code_start, code_size, MAP_CODE);
remap_range((void *)rodata_start, rodata_size, ARCH_MAP_CACHED_RO);
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 0db95bceba1b..7e6e89cb98c2 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -360,6 +360,14 @@ static void create_guard_page(void)
pr_debug("Created guard page\n");
}
+void setup_trap_pages(void)
+{
+ /* Vectors are already registered by aarch64_init_vectors */
+ /* Make zero page faulting to catch NULL pointer derefs */
+ zero_page_faulting();
+ create_guard_page();
+}
+
/*
* Prepare MMU for usage enable it.
*/
@@ -412,9 +420,7 @@ void __mmu_init(bool mmu_on)
remap_range((void *)code_start, code_size, MAP_CODE);
remap_range((void *)rodata_start, rodata_size, ARCH_MAP_CACHED_RO);
- /* Make zero page faulting to catch NULL pointer derefs */
- zero_page_faulting();
- create_guard_page();
+ setup_trap_pages();
}
void mmu_disable(void)
--
2.39.5
next prev parent reply other threads:[~2025-08-05 18:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 17:45 [PATCH master 0/8] ARM: mmu: fix hang reserving memory after text area Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 1/8] partition: rename region_overlap_end to region_overlap_end_inclusive Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 2/8] partition: define new region_overlap_end_exclusive helper Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 3/8] ARM: mmu: skip TLB invalidation if remapping zero bytes Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 4/8] ARM64: mmu: pass map type not PTE flags to early_remap_range Ahmad Fatoum
2025-08-05 17:45 ` Ahmad Fatoum [this message]
2025-08-05 17:45 ` [PATCH master 6/8] ARM: mmu: setup trap pages before remapping R/O Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 7/8] ARM: mmu: share common memory bank remapping code Ahmad Fatoum
2025-08-05 17:45 ` [PATCH master 8/8] ARM: mmu: fix hang reserving memory after text area Ahmad Fatoum
2025-08-06 6:31 ` [PATCH master 0/8] " Sascha Hauer
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=20250805174541.2606267-6-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/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