As patrick@ found earlier, on Cortex-A53 we have to enable the data
cache before doing any atomic operations.  Currently we do this in
cpu_configure(), which is really late, after several kernel subsystems
get initialized.  And some of those subsystems use mutexes, which use
atomic operations...

Patrck's solution was to just set the data cache enable bit in the cpu
control register early on in initarm().  That seems to work, but I'm
not entirely confident about this.  It means we run a significant
amount of code in the half-enabled cache state.  So here is a diff
that moves the cpu_setup() call to the tail of initarm() on all
OpenBSD/arm platforms.  This seems to work fine on armv7.  Can
somebody give this a spin on zaurus and/or armish?

Thanks,

Mark


Index: arm/arm/arm32_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/arm32_machdep.c,v
retrieving revision 1.48
diff -u -p -r1.48 arm32_machdep.c
--- arm/arm/arm32_machdep.c     31 Jan 2016 00:14:50 -0000      1.48
+++ arm/arm/arm32_machdep.c     8 Aug 2016 13:27:12 -0000
@@ -165,7 +165,7 @@ arm32_vector_init(vaddr_t va, int which)
                 *
                 * Note: This has to be done here (and not just in
                 * cpu_setup()) because the vector page needs to be
-                * accessible *before* cpu_startup() is called.
+                * accessible *before* main() is called.
                 * Think ddb(9) ...
                 *
                 * NOTE: If the CPU control register is not readable,
@@ -236,12 +236,6 @@ cpu_startup()
        u_int loop;
        paddr_t minaddr;
        paddr_t maxaddr;
-
-       proc0paddr = (struct user *)kernelstack.pv_va;
-       proc0.p_addr = proc0paddr;
-
-       /* Set the cpu control register */
-       cpu_setup();
 
        /* Lock down zero page */
        vector_page_setprot(PROT_READ | PROT_EXEC);
Index: armv7/armv7/armv7_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/armv7_machdep.c,v
retrieving revision 1.34
diff -u -p -r1.34 armv7_machdep.c
--- armv7/armv7/armv7_machdep.c 30 Jul 2016 08:07:01 -0000      1.34
+++ armv7/armv7/armv7_machdep.c 8 Aug 2016 13:27:12 -0000
@@ -795,6 +795,8 @@ initarm(void *arg0, void *arg1, void *ar
 #endif
        printf("board type: %u\n", board_id);
 
+       cpu_setup();
+
        /* We return the new stack pointer address */
        return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
 }
Index: armish/armish/armish_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armish/armish/armish_machdep.c,v
retrieving revision 1.39
diff -u -p -r1.39 armish_machdep.c
--- armish/armish/armish_machdep.c      10 May 2015 15:56:28 -0000      1.39
+++ armish/armish/armish_machdep.c      8 Aug 2016 13:27:12 -0000
@@ -770,6 +770,8 @@ initarm(void *arg0, void *arg1, void *ar
                Debugger();
 #endif
     
+       cpu_setup();
+
        /* We return the new stack pointer address */
        return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
 }
Index: zaurus/zaurus/zaurus_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/zaurus/zaurus/zaurus_machdep.c,v
retrieving revision 1.59
diff -u -p -r1.59 zaurus_machdep.c
--- zaurus/zaurus/zaurus_machdep.c      10 May 2015 15:56:28 -0000      1.59
+++ zaurus/zaurus/zaurus_machdep.c      8 Aug 2016 13:27:12 -0000
@@ -1110,6 +1110,8 @@ initarm(void *arg0, void *arg1, void *ar
                Debugger();
 #endif
 
+       cpu_setup();
+
        /* We return the new stack pointer address */
        return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
 }

Reply via email to