[PATCH 1/8] ARM: MMU: add zero_page_{access,faulting}

Rouven Czerwinski r.czerwinski at pengutronix.de
Mon Nov 9 08:44:23 EST 2020


On the qemu virt machine, the cfi flash is mapped at 0x0.
Therefore implement zero_page_{access,faulting} to allow usage of the
cfi_flash driver on this machine.

Signed-off-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
---
 arch/arm/cpu/Kconfig |  1 -
 arch/arm/cpu/mmu.c   | 13 +++++++++++++
 include/zero_page.h  | 14 --------------
 lib/Kconfig          |  3 ---
 4 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index ca3bd98962..f9f52a6252 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -89,7 +89,6 @@ 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.c b/arch/arm/cpu/mmu.c
index 6af228505d..bfb8eab5f5 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -17,6 +17,7 @@
 #include <memory.h>
 #include <asm/system_info.h>
 #include <asm/sections.h>
+#include <zero_page.h>
 
 #include "mmu.h"
 
@@ -354,6 +355,18 @@ static void create_zero_page(void)
 	}
 }
 
+void zero_page_access(void)
+{
+	arm_create_pte(0x0, pte_flags_cached);
+}
+
+void zero_page_faulting(void)
+{
+	u32 *zero;
+	zero = arm_create_pte(0x0, pte_flags_uncached);
+	zero[0] = 0;
+}
+
 /*
  * Map vectors and zero page
  */
diff --git a/include/zero_page.h b/include/zero_page.h
index ad6861f240..b0efb814db 100644
--- a/include/zero_page.h
+++ b/include/zero_page.h
@@ -4,8 +4,6 @@
 
 #include <common.h>
 
-#if defined CONFIG_ARCH_HAS_ZERO_PAGE
-
 /*
  * zero_page_faulting - fault when accessing the zero page
  */
@@ -20,18 +18,6 @@ void zero_page_faulting(void);
  */
 void zero_page_access(void);
 
-#else
-
-static inline void zero_page_faulting(void)
-{
-}
-
-static inline void zero_page_access(void)
-{
-}
-
-#endif
-
 static inline bool zero_page_contains(unsigned long addr)
 {
 	return addr < PAGE_SIZE;
diff --git a/lib/Kconfig b/lib/Kconfig
index e5831ecdb9..887f50ff00 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -182,9 +182,6 @@ config ARCH_HAS_STACK_DUMP
 config ARCH_HAS_DATA_ABORT_MASK
 	bool
 
-config ARCH_HAS_ZERO_PAGE
-	bool
-
 config HAVE_EFFICIENT_UNALIGNED_ACCESS
 	bool
 
-- 
2.28.0




More information about the barebox mailing list