xtensa: extract init_kio
authorMax Filippov <jcmvbkbc@gmail.com>
Sat, 16 Dec 2017 04:45:35 +0000 (20:45 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Sun, 17 Dec 2017 06:37:10 +0000 (22:37 -0800)
KIO region placement may be specified in the device tree, that's why
it's initialized with the rest of MMU after the early_init_devtree. In
order to support KASAN the MMU must be initialized earlier.
Separate KIO initialization from the rest of MMU initialization.
Reinitialize KIO if its location is specified in the device tree.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/include/asm/mmu_context.h
arch/xtensa/include/asm/nommu_context.h
arch/xtensa/kernel/setup.c
arch/xtensa/mm/mmu.c

index f7e186dfc4e44e7694c4cce368a368d63aca13d2..de5e6cbbafe42ca0cd273ee7be460d03769d9f25 100644 (file)
@@ -52,6 +52,7 @@ DECLARE_PER_CPU(unsigned long, asid_cache);
 #define ASID_INSERT(x) (0x03020001 | (((x) & ASID_MASK) << 8))
 
 void init_mmu(void);
+void init_kio(void);
 
 static inline void set_rasid_register (unsigned long val)
 {
index 2cebdbbdb6334666e29662b8e34ff46410e53c4f..37251b2ef871142e5b3b52ff266c76b8fee6a1ba 100644 (file)
@@ -3,6 +3,10 @@ static inline void init_mmu(void)
 {
 }
 
+static inline void init_kio(void)
+{
+}
+
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
 }
index cf7516c52a198c59be2cb96d6dffd9bf89f52a7f..960212e72a701a40cbd40ad29cfc6898c8542eef 100644 (file)
@@ -207,6 +207,8 @@ static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
        /* round down to nearest 256MB boundary */
        xtensa_kio_paddr &= 0xf0000000;
 
+       init_kio();
+
        return 1;
 }
 #else
@@ -245,6 +247,10 @@ void __init early_init_devtree(void *params)
 
 void __init init_arch(bp_tag_t *bp_start)
 {
+       /* Initialize MMU. */
+
+       init_mmu();
+
        /* Parse boot parameters */
 
        if (bp_start)
@@ -262,10 +268,6 @@ void __init init_arch(bp_tag_t *bp_start)
        /* Early hook for platforms */
 
        platform_init(bp_start);
-
-       /* Initialize MMU. */
-
-       init_mmu();
 }
 
 /*
index 358d748d9083f64879bcd404f15774c44bc2bba0..54c01e3ebf056ab7a4926d0a2b54e9eb65cfc625 100644 (file)
@@ -82,6 +82,23 @@ void init_mmu(void)
        set_itlbcfg_register(0);
        set_dtlbcfg_register(0);
 #endif
+       init_kio();
+       local_flush_tlb_all();
+
+       /* Set rasid register to a known value. */
+
+       set_rasid_register(ASID_INSERT(ASID_USER_FIRST));
+
+       /* Set PTEVADDR special register to the start of the page
+        * table, which is in kernel mappable space (ie. not
+        * statically mapped).  This register's value is undefined on
+        * reset.
+        */
+       set_ptevaddr_register(XCHAL_PAGE_TABLE_VADDR);
+}
+
+void init_kio(void)
+{
 #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
        /*
         * Update the IO area mapping in case xtensa_kio_paddr has changed
@@ -95,17 +112,4 @@ void init_mmu(void)
        write_itlb_entry(__pte(xtensa_kio_paddr + CA_BYPASS),
                        XCHAL_KIO_BYPASS_VADDR + 6);
 #endif
-
-       local_flush_tlb_all();
-
-       /* Set rasid register to a known value. */
-
-       set_rasid_register(ASID_INSERT(ASID_USER_FIRST));
-
-       /* Set PTEVADDR special register to the start of the page
-        * table, which is in kernel mappable space (ie. not
-        * statically mapped).  This register's value is undefined on
-        * reset.
-        */
-       set_ptevaddr_register(PGTABLE_START);
 }