summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2020-10-21 16:51:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-10-22 09:30:49 +0200
commit92e123a3d66bff3f773f0c2b5eec4463aca34052 (patch)
tree19e612e83fe9162a91b89914d236514276488677 /arch
parent7ef4cf1a432257f99bee06232929e76292de47ae (diff)
downloadbarebox-92e123a3d66bff3f773f0c2b5eec4463aca34052.tar.gz
barebox-92e123a3d66bff3f773f0c2b5eec4463aca34052.tar.xz
ARM: mmu64: allow to disable null pointer trap on zero page
Barebox uses the zero page to trap NULL pointer dereferences. However, if the SDRAM starts at address 0x0, this makes the first page of the SDRAM inaccessible and makes it impossible to load images to offset 0x0 in the SDRAM. Trapping NULL pointer dereferences on such systems is still desirable. Therefore, add a function to disable the traps if accessing the zero page is necessary and to re-enable the traps after the access is done. The zero_page_memcpy function simplifies copying to the SDRAM, because this is the most common required functionality, but memtest also accesses the zero page and does not use memcpy. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/Kconfig1
-rw-r--r--arch/arm/cpu/mmu_64.c13
2 files changed, 13 insertions, 1 deletions
diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index f9f52a6252..ca3bd98962 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -89,6 +89,7 @@ config CPU_V8
select ARM_EXCEPTIONS
select GENERIC_FIND_NEXT_BIT
select ARCH_HAS_STACK_DUMP
+ select ARCH_HAS_ZERO_PAGE
config CPU_XSC3
bool
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 7e9ae84810..06049e0003 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -10,6 +10,7 @@
#include <init.h>
#include <mmu.h>
#include <errno.h>
+#include <zero_page.h>
#include <linux/sizes.h>
#include <asm/memory.h>
#include <asm/pgtable64.h>
@@ -168,6 +169,16 @@ static void mmu_enable(void)
set_cr(get_cr() | CR_M | CR_C | CR_I);
}
+void zero_page_access(void)
+{
+ create_sections(0x0, 0x0, PAGE_SIZE, CACHED_MEM);
+}
+
+void zero_page_faulting(void)
+{
+ create_sections(0x0, 0x0, PAGE_SIZE, 0x0);
+}
+
/*
* Prepare MMU for usage enable it.
*/
@@ -194,7 +205,7 @@ void __mmu_init(bool mmu_on)
create_sections(bank->start, bank->start, bank->size, CACHED_MEM);
/* Make zero page faulting to catch NULL pointer derefs */
- create_sections(0x0, 0x0, 0x1000, 0x0);
+ zero_page_faulting();
mmu_enable();
}