summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2018-08-06 18:39:14 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2018-08-06 18:39:14 +0000
commite312b4b9ce317a99f0161d16658453ef76fe4ab0 (patch)
tree5afec0a16f9c89fe966e0002f2333c180f6705e7 /sys
parent6144ffe81a725d8d8c36e4b94faf193c58cc252d (diff)
Make it possible to build a MULTIPROCESSOR kernel on armv7. While this
doesn't actually spin up any secondary CPUs, it does run. Mostly a cleanup of <machine/cpu.h> along the lines of what I did earlier on arm64. Makes armv7 use the MI mplock implementation and implements copyin32. ok patrick@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm/arm/arm32_machdep.c4
-rw-r--r--sys/arch/arm/arm/bcopy_page.S6
-rw-r--r--sys/arch/arm/arm/bcopyinout.S39
-rw-r--r--sys/arch/arm/arm/copystr.S6
-rw-r--r--sys/arch/arm/arm/cpu.c8
-rw-r--r--sys/arch/arm/arm/cpufunc_asm.S3
-rw-r--r--sys/arch/arm/arm/cpufunc_asm_armv7.S3
-rw-r--r--sys/arch/arm/arm/cpuswitch7.S11
-rw-r--r--sys/arch/arm/arm/exception.S7
-rw-r--r--sys/arch/arm/arm/fault.c15
-rw-r--r--sys/arch/arm/arm/genassym.cf6
-rw-r--r--sys/arch/arm/arm/in_cksum_arm.S5
-rw-r--r--sys/arch/arm/arm/irq_dispatch.S4
-rw-r--r--sys/arch/arm/arm/locore.S8
-rw-r--r--sys/arch/arm/arm/setstack.S4
-rw-r--r--sys/arch/arm/arm/sigcode.S7
-rw-r--r--sys/arch/arm/arm/softintr.c4
-rw-r--r--sys/arch/arm/arm/undefined.c8
-rw-r--r--sys/arch/arm/arm/vectors.S3
-rw-r--r--sys/arch/arm/cortex/ampintc.c19
-rw-r--r--sys/arch/arm/include/cpu.h64
-rw-r--r--sys/arch/arm/include/mplock.h10
-rw-r--r--sys/arch/armv7/armv7/armv7_machdep.c4
-rw-r--r--sys/arch/armv7/armv7/armv7_start.S7
-rw-r--r--sys/arch/armv7/armv7/locore0.S7
-rw-r--r--sys/arch/armv7/include/mplock.h3
26 files changed, 176 insertions, 89 deletions
diff --git a/sys/arch/arm/arm/arm32_machdep.c b/sys/arch/arm/arm/arm32_machdep.c
index f528dc49997..88a14bafad0 100644
--- a/sys/arch/arm/arm/arm32_machdep.c
+++ b/sys/arch/arm/arm/arm32_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arm32_machdep.c,v 1.55 2017/12/11 05:27:40 deraadt Exp $ */
+/* $OpenBSD: arm32_machdep.c,v 1.56 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: arm32_machdep.c,v 1.42 2003/12/30 12:33:15 pk Exp $ */
/*
@@ -202,7 +202,7 @@ bootsync(int howto)
* did not come from a user process e.g. shutdown, but must
* have come from somewhere in the kernel.
*/
- IRQenable;
+ __set_cpsr_c(PSR_I, 0);
printf("Warning IRQ's disabled during boot()\n");
}
diff --git a/sys/arch/arm/arm/bcopy_page.S b/sys/arch/arm/arm/bcopy_page.S
index d49d313165a..7f7aa966cd5 100644
--- a/sys/arch/arm/arm/bcopy_page.S
+++ b/sys/arch/arm/arm/bcopy_page.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy_page.S,v 1.2 2018/06/03 18:58:11 kettenis Exp $ */
+/* $OpenBSD: bcopy_page.S,v 1.3 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: bcopy_page.S,v 1.7 2003/10/13 21:03:13 scw Exp $ */
@@ -40,10 +40,10 @@
* Created : 08/04/95
*/
-#include <machine/asm.h>
-
#include "assym.h"
+#include <machine/asm.h>
+
/* #define BIG_LOOPS */
/*
diff --git a/sys/arch/arm/arm/bcopyinout.S b/sys/arch/arm/arm/bcopyinout.S
index 4834083a73d..3760c575c09 100644
--- a/sys/arch/arm/arm/bcopyinout.S
+++ b/sys/arch/arm/arm/bcopyinout.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopyinout.S,v 1.8 2018/06/03 18:58:11 kettenis Exp $ */
+/* $OpenBSD: bcopyinout.S,v 1.9 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: bcopyinout.S,v 1.13 2003/10/31 16:54:05 scw Exp $ */
/*
@@ -38,6 +38,8 @@
#include "assym.h"
+#include <sys/errno.h>
+
#include <machine/asm.h>
#include <arm/sysreg.h>
@@ -264,6 +266,40 @@ ENTRY(copyin)
mov pc, lr
/*
+ * r0 = user space address
+ * r1 = kernel space address
+ *
+ * Atomically copies a 32-bit word from user space to kernel space
+ *
+ * We save/restore r4-r11:
+ * r4-r11 are scratch
+ */
+ENTRY(copyin32)
+ /* Quick exit if unaligned */
+ tst r0, #0x3
+ movne r0, #EFAULT
+ movne pc, lr
+
+ SAVE_REGS
+
+ /* Get curcpu from TPIDRPRW. */
+ mrc CP15_TPIDRPRW(r4)
+ ldr r4, [r4, #CI_CURPCB]
+
+ ldr r5, [r4, #PCB_ONFAULT]
+ adr r3, .Lcopyfault
+ str r3, [r4, #PCB_ONFAULT]
+
+ ldr r6, [r0]
+ str r6, [r1]
+ mov r0, #0
+
+ str r5, [r4, #PCB_ONFAULT]
+ RESTORE_REGS
+
+ mov pc, lr
+
+/*
* r0 = kernel space address
* r1 = user space address
* r2 = length
@@ -273,7 +309,6 @@ ENTRY(copyin)
* We save/restore r4-r11:
* r4-r11 are scratch
*/
-
ENTRY(copyout)
/* Quick exit if length is zero */
teq r2, #0
diff --git a/sys/arch/arm/arm/copystr.S b/sys/arch/arm/arm/copystr.S
index e38f2903955..b002542b923 100644
--- a/sys/arch/arm/arm/copystr.S
+++ b/sys/arch/arm/arm/copystr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: copystr.S,v 1.8 2017/01/06 00:06:02 jsg Exp $ */
+/* $OpenBSD: copystr.S,v 1.9 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: copystr.S,v 1.8 2002/10/13 14:54:48 bjh21 Exp $ */
/*
@@ -40,9 +40,11 @@
*/
#include "assym.h"
+
+#include <sys/errno.h>
+
#include <machine/asm.h>
#include <arm/sysreg.h>
-#include <sys/errno.h>
.text
.align 2
diff --git a/sys/arch/arm/arm/cpu.c b/sys/arch/arm/arm/cpu.c
index 573aea7ec9b..a702b144117 100644
--- a/sys/arch/arm/arm/cpu.c
+++ b/sys/arch/arm/arm/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.46 2018/02/23 19:08:56 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.47 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.56 2004/04/14 04:01:49 bsh Exp $ */
@@ -341,6 +341,12 @@ cpu_clockspeed(int *freq)
}
#ifdef MULTIPROCESSOR
+
+void
+cpu_boot_secondary_processors(void)
+{
+}
+
int
cpu_alloc_idle_pcb(struct cpu_info *ci)
{
diff --git a/sys/arch/arm/arm/cpufunc_asm.S b/sys/arch/arm/arm/cpufunc_asm.S
index 109e105efe4..87de88c0179 100644
--- a/sys/arch/arm/arm/cpufunc_asm.S
+++ b/sys/arch/arm/arm/cpufunc_asm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc_asm.S,v 1.5 2016/09/21 11:33:05 kettenis Exp $ */
+/* $OpenBSD: cpufunc_asm.S,v 1.6 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: cpufunc_asm.S,v 1.12 2003/09/06 09:14:52 rearnsha Exp $ */
/*
@@ -42,7 +42,6 @@
* Created : 30/01/97
*/
-#include <machine/cpu.h>
#include <machine/asm.h>
#include <arm/sysreg.h>
diff --git a/sys/arch/arm/arm/cpufunc_asm_armv7.S b/sys/arch/arm/arm/cpufunc_asm_armv7.S
index 20e9db1435d..c13411a04b2 100644
--- a/sys/arch/arm/arm/cpufunc_asm_armv7.S
+++ b/sys/arch/arm/arm/cpufunc_asm_armv7.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc_asm_armv7.S,v 1.15 2018/01/15 14:11:16 kettenis Exp $ */
+/* $OpenBSD: cpufunc_asm_armv7.S,v 1.16 2018/08/06 18:39:13 kettenis Exp $ */
/*
* Copyright (c) 2008 Dale Rahn <drahn@openbsd.org>
*
@@ -15,7 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <machine/cpu.h>
#include <machine/asm.h>
#include <arm/armreg.h>
#include <arm/sysreg.h>
diff --git a/sys/arch/arm/arm/cpuswitch7.S b/sys/arch/arm/arm/cpuswitch7.S
index 431a890dc94..2f025aac324 100644
--- a/sys/arch/arm/arm/cpuswitch7.S
+++ b/sys/arch/arm/arm/cpuswitch7.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpuswitch7.S,v 1.13 2016/09/24 21:02:31 patrick Exp $ */
+/* $OpenBSD: cpuswitch7.S,v 1.14 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: cpuswitch.S,v 1.41 2003/11/15 08:44:18 scw Exp $ */
/*
@@ -79,10 +79,11 @@
*/
#include "assym.h"
-#include <machine/cpu.h>
+
#include <machine/frame.h>
#include <machine/intr.h>
#include <machine/asm.h>
+#include <arm/armreg.h>
#include <arm/sysreg.h>
/* LINTSTUB: include <sys/param.h> */
@@ -315,12 +316,12 @@ ENTRY(savectx)
ldmfd sp!, {r4-r7, pc}
ENTRY(proc_trampoline)
- mov r0, #(IPL_NONE)
- bl _C_LABEL(_spllower)
-
#ifdef MULTIPROCESSOR
bl _C_LABEL(proc_trampoline_mp)
#endif
+ mov r0, #(IPL_NONE)
+ bl _C_LABEL(_spllower)
+
mov r0, r5
mov r1, sp
mov lr, pc
diff --git a/sys/arch/arm/arm/exception.S b/sys/arch/arm/arm/exception.S
index 0d34cad7c3d..8e649178c05 100644
--- a/sys/arch/arm/arm/exception.S
+++ b/sys/arch/arm/arm/exception.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: exception.S,v 1.8 2018/06/03 18:58:11 kettenis Exp $ */
+/* $OpenBSD: exception.S,v 1.9 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: exception.S,v 1.13 2003/10/31 16:30:15 scw Exp $ */
/*
@@ -46,10 +46,11 @@
* Based on kate/display/abort.s
*/
+#include "assym.h"
+
#include <machine/asm.h>
-#include <machine/cpu.h>
#include <machine/frame.h>
-#include "assym.h"
+#include <arm/armreg.h>
.text
.align 2
diff --git a/sys/arch/arm/arm/fault.c b/sys/arch/arm/arm/fault.c
index 2661783217c..ea4af0b6970 100644
--- a/sys/arch/arm/arm/fault.c
+++ b/sys/arch/arm/arm/fault.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fault.c,v 1.35 2018/06/22 18:50:42 guenther Exp $ */
+/* $OpenBSD: fault.c,v 1.36 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */
/*
@@ -340,7 +340,9 @@ data_abort_handler(trapframe_t *tf)
onfault = pcb->pcb_onfault;
pcb->pcb_onfault = NULL;
+ KERNEL_LOCK();
error = uvm_fault(map, va, 0, ftype);
+ KERNEL_UNLOCK();
pcb->pcb_onfault = onfault;
#if 0
@@ -385,7 +387,9 @@ data_abort_handler(trapframe_t *tf)
sd.trap = fsr;
do_trapsignal:
sv.sival_int = sd.addr;
+ KERNEL_LOCK();
trapsignal(p, sd.signo, sd.trap, sd.code, sv);
+ KERNEL_UNLOCK();
out:
/* If returning to user mode, make sure to invoke userret() */
if (user)
@@ -595,7 +599,9 @@ prefetch_abort_handler(trapframe_t *tf)
}
#endif
+ KERNEL_LOCK();
error = uvm_fault(map, va, 0, PROT_READ | PROT_EXEC);
+ KERNEL_UNLOCK();
if (__predict_true(error == 0))
goto out;
@@ -604,9 +610,14 @@ prefetch_abort_handler(trapframe_t *tf)
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n", p->p_p->ps_pid, p->p_p->ps_comm,
p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
+ KERNEL_LOCK();
trapsignal(p, SIGKILL, 0, SEGV_MAPERR, sv);
- } else
+ KERNEL_UNLOCK();
+ } else {
+ KERNEL_LOCK();
trapsignal(p, SIGSEGV, 0, SEGV_MAPERR, sv);
+ KERNEL_UNLOCK();
+ }
out:
userret(p);
diff --git a/sys/arch/arm/arm/genassym.cf b/sys/arch/arm/arm/genassym.cf
index 3937b930c39..2a6b57a6605 100644
--- a/sys/arch/arm/arm/genassym.cf
+++ b/sys/arch/arm/arm/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.16 2016/09/24 21:02:31 patrick Exp $
+# $OpenBSD: genassym.cf,v 1.17 2018/08/06 18:39:13 kettenis Exp $
# $NetBSD: genassym.cf,v 1.27 2003/11/04 10:33:16 dsl Exp$
# Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -60,7 +60,6 @@ ifdef __ARM_FIQ_INDIRECT
define __ARM_FIQ_INDIRECT 1
endif
-export DOMAIN_CLIENT
export PMAP_DOMAIN_KERNEL
ifdef PMAP_INCLUDE_PTE_SYNC
@@ -75,8 +74,7 @@ export SONPROC
struct proc
member p_addr
-#member p_priority
-#member p_wchan
+member p_cpu
member p_stat
# XXX use PROC_SIZEOF in new code whenever possible
define PROCSIZE sizeof(struct proc)
diff --git a/sys/arch/arm/arm/in_cksum_arm.S b/sys/arch/arm/arm/in_cksum_arm.S
index 3de8a7c38f0..79ed5058e10 100644
--- a/sys/arch/arm/arm/in_cksum_arm.S
+++ b/sys/arch/arm/arm/in_cksum_arm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_cksum_arm.S,v 1.6 2018/06/03 18:58:11 kettenis Exp $ */
+/* $OpenBSD: in_cksum_arm.S,v 1.7 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: in_cksum_arm.S,v 1.3 2003/11/26 10:31:53 rearnsha Exp $ */
/*
@@ -40,9 +40,10 @@
* Hand-optimised in_cksum() and in4_cksum() implementations for ARM/Xscale
*/
-#include <machine/asm.h>
#include "assym.h"
+#include <machine/asm.h>
+
.syntax unified
/*
diff --git a/sys/arch/arm/arm/irq_dispatch.S b/sys/arch/arm/arm/irq_dispatch.S
index 015c7bb6cb4..032592b516c 100644
--- a/sys/arch/arm/arm/irq_dispatch.S
+++ b/sys/arch/arm/arm/irq_dispatch.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: irq_dispatch.S,v 1.14 2018/01/26 16:22:19 kettenis Exp $ */
+/* $OpenBSD: irq_dispatch.S,v 1.15 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: irq_dispatch.S,v 1.5 2003/10/30 08:57:24 scw Exp $ */
/*
@@ -71,8 +71,8 @@
#include "assym.h"
#include <machine/asm.h>
+#include <arm/armreg.h>
#include <arm/sysreg.h>
-#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/intr.h>
diff --git a/sys/arch/arm/arm/locore.S b/sys/arch/arm/arm/locore.S
index 1426858df4d..3f200a17b34 100644
--- a/sys/arch/arm/arm/locore.S
+++ b/sys/arch/arm/arm/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.16 2018/06/30 15:23:35 deraadt Exp $ */
+/* $OpenBSD: locore.S,v 1.17 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: locore.S,v 1.14 2003/04/20 16:21:40 thorpej Exp $ */
/*
@@ -33,12 +33,14 @@
*/
#include "assym.h"
+
#include <sys/syscall.h>
#include <sys/errno.h>
+
#include <machine/asm.h>
-#include <arm/sysreg.h>
-#include <machine/cpu.h>
#include <machine/frame.h>
+#include <arm/armreg.h>
+#include <arm/sysreg.h>
/* What size should this really be ? It is only used by init_arm() */
#define INIT_ARM_STACK_SIZE 2048
diff --git a/sys/arch/arm/arm/setstack.S b/sys/arch/arm/arm/setstack.S
index a155483575f..991b60ae7f6 100644
--- a/sys/arch/arm/arm/setstack.S
+++ b/sys/arch/arm/arm/setstack.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: setstack.S,v 1.4 2018/06/30 15:23:35 deraadt Exp $ */
+/* $OpenBSD: setstack.S,v 1.5 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: setstack.S,v 1.2 2002/08/15 01:37:02 briggs Exp $ */
/*
@@ -48,8 +48,8 @@
* Based of kate/display/setstack.s
*/
-#include <machine/cpu.h>
#include <machine/asm.h>
+#include <arm/armreg.h>
/* To set the stack pointer for a particular mode we must switch
* to that mode update the banked r13 and then switch back.
diff --git a/sys/arch/arm/arm/sigcode.S b/sys/arch/arm/arm/sigcode.S
index 1ac3d526384..91328f9c0a8 100644
--- a/sys/arch/arm/arm/sigcode.S
+++ b/sys/arch/arm/arm/sigcode.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigcode.S,v 1.6 2018/02/06 09:25:54 patrick Exp $ */
+/* $OpenBSD: sigcode.S,v 1.7 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: sigcode.S,v 1.6 2003/10/05 19:44:58 matt Exp $ */
/*
@@ -32,11 +32,12 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
-
#include "assym.h"
+
#include <sys/syscall.h>
+#include <machine/asm.h>
+
/*
* Signal trampoline;
*/
diff --git a/sys/arch/arm/arm/softintr.c b/sys/arch/arm/arm/softintr.c
index ba10f2b49f0..f6f3f25b5d5 100644
--- a/sys/arch/arm/arm/softintr.c
+++ b/sys/arch/arm/arm/softintr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softintr.c,v 1.8 2014/07/12 18:44:41 tedu Exp $ */
+/* $OpenBSD: softintr.c,v 1.9 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */
/*
@@ -92,7 +92,9 @@ softintr_dispatch(int si)
uvmexp.softs++;
mtx_leave(&siq->siq_mtx);
+ KERNEL_LOCK();
(*sih->sih_func)(sih->sih_arg);
+ KERNEL_UNLOCK();
}
}
diff --git a/sys/arch/arm/arm/undefined.c b/sys/arch/arm/arm/undefined.c
index 2120de0ca2a..b0745f072cc 100644
--- a/sys/arch/arm/arm/undefined.c
+++ b/sys/arch/arm/arm/undefined.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undefined.c,v 1.11 2018/01/26 16:22:19 kettenis Exp $ */
+/* $OpenBSD: undefined.c,v 1.12 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: undefined.c,v 1.22 2003/11/29 22:21:29 bjh21 Exp $ */
/*
@@ -113,7 +113,9 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe *frame, int code)
if (insn == GDB_BREAKPOINT || insn == GDB5_BREAKPOINT) {
if (code == FAULT_USER) {
sv.sival_int = addr;
+ KERNEL_LOCK();
trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv);
+ KERNEL_UNLOCK();
return 0;
}
}
@@ -171,7 +173,9 @@ undefinedinstruction(trapframe_t *frame)
if (__predict_false((fault_pc & 3) != 0)) {
/* Give the user an illegal instruction signal. */
sv.sival_int = (u_int32_t) fault_pc;
+ KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
+ KERNEL_UNLOCK();
userret(p);
return;
}
@@ -255,7 +259,9 @@ undefinedinstruction(trapframe_t *frame)
}
sv.sival_int = frame->tf_pc;
+ KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
+ KERNEL_UNLOCK();
}
if ((fault_code & FAULT_USER) == 0)
diff --git a/sys/arch/arm/arm/vectors.S b/sys/arch/arm/arm/vectors.S
index 608335d719d..6d3722d45b1 100644
--- a/sys/arch/arm/arm/vectors.S
+++ b/sys/arch/arm/arm/vectors.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: vectors.S,v 1.2 2016/09/21 11:33:05 kettenis Exp $ */
+/* $OpenBSD: vectors.S,v 1.3 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: vectors.S,v 1.4 2002/08/17 16:36:32 thorpej Exp $ */
/*
@@ -33,6 +33,7 @@
*/
#include "assym.h"
+
#include <machine/asm.h>
/*
diff --git a/sys/arch/arm/cortex/ampintc.c b/sys/arch/arm/cortex/ampintc.c
index 595c0f5b76b..bdfc14b621d 100644
--- a/sys/arch/arm/cortex/ampintc.c
+++ b/sys/arch/arm/cortex/ampintc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ampintc.c,v 1.21 2018/07/09 09:51:43 patrick Exp $ */
+/* $OpenBSD: ampintc.c,v 1.22 2018/08/06 18:39:13 kettenis Exp $ */
/*
* Copyright (c) 2007,2009,2011 Dale Rahn <drahn@openbsd.org>
*
@@ -153,6 +153,7 @@ struct intrhand {
int (*ih_func)(void *); /* handler */
void *ih_arg; /* arg for handler */
int ih_ipl; /* IPL_* */
+ int ih_flags;
int ih_irq; /* IRQ number */
struct evcount ih_count;
char *ih_name;
@@ -540,6 +541,18 @@ ampintc_irq_handler(void *frame)
pri = sc->sc_ampintc_handler[irq].iq_irq;
s = ampintc_splraise(pri);
TAILQ_FOREACH(ih, &sc->sc_ampintc_handler[irq].iq_list, ih_list) {
+#ifdef MULTIPROCESSOR
+ int need_lock;
+
+ if (ih->ih_flags & IPL_MPSAFE)
+ need_lock = 0;
+ else
+ need_lock = s < IPL_SCHED;
+
+ if (need_lock)
+ KERNEL_LOCK();
+#endif
+
if (ih->ih_arg != 0)
arg = ih->ih_arg;
else
@@ -548,6 +561,10 @@ ampintc_irq_handler(void *frame)
if (ih->ih_func(arg))
ih->ih_count.ec_count++;
+#ifdef MULTIPROCESSOR
+ if (need_lock)
+ KERNEL_UNLOCK();
+#endif
}
ampintc_eoi(iack_val);
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index 3dd159101df..3ef71b06eaf 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.51 2018/06/30 15:23:36 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.52 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -95,42 +95,12 @@
#include <arm/cpuconf.h>
#include <machine/intr.h>
-#ifndef _LOCORE
-#if 0
-#include <sys/user.h>
-#endif
#include <machine/frame.h>
#include <machine/pcb.h>
-#endif /* !_LOCORE */
-
#include <arm/armreg.h>
-#ifndef _LOCORE
/* 1 == use cpu_sleep(), 0 == don't */
extern int cpu_do_powersave;
-#endif
-
-#ifdef _LOCORE
-#define IRQdisable \
- stmfd sp!, {r0} ; \
- mrs r0, cpsr ; \
- orr r0, r0, #(PSR_I) ; \
- msr cpsr_c, r0 ; \
- ldmfd sp!, {r0}
-
-#define IRQenable \
- stmfd sp!, {r0} ; \
- mrs r0, cpsr ; \
- bic r0, r0, #(PSR_I) ; \
- msr cpsr_c, r0 ; \
- ldmfd sp!, {r0}
-
-#else
-#define IRQdisable __set_cpsr_c(PSR_I, PSR_I);
-#define IRQenable __set_cpsr_c(PSR_I, 0);
-#endif /* _LOCORE */
-
-#ifndef _LOCORE
/* All the CLKF_* macros take a struct clockframe * as an argument. */
@@ -179,6 +149,7 @@ void arm32_vector_init(vaddr_t, int);
#include <sys/device.h>
#include <sys/sched.h>
+
struct cpu_info {
struct device *ci_dev; /* Device corresponding to this CPU */
struct cpu_info *ci_next;
@@ -204,6 +175,10 @@ struct cpu_info {
int ci_mutex_level;
#endif
+#ifdef MULTIPROCESSOR
+ struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM];
+#endif
+
#ifdef GPROF
struct gmonparam *ci_gmon;
#endif
@@ -211,9 +186,6 @@ struct cpu_info {
void (*ci_flush_bp)(void);
};
-extern struct cpu_info cpu_info_primary;
-extern struct cpu_info *cpu_info_list;
-
static inline struct cpu_info *
curcpu(void)
{
@@ -222,6 +194,9 @@ curcpu(void)
return (__ci);
}
+extern struct cpu_info cpu_info_primary;
+extern struct cpu_info *cpu_info_list;
+
#ifndef MULTIPROCESSOR
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
@@ -306,8 +281,27 @@ void swi_handler (trapframe_t *);
/* machine_machdep.c */
void board_startup(void);
-#endif /* !_LOCORE */
+static inline u_long
+intr_disable(void)
+{
+ uint32_t cpsr;
+
+ __asm volatile ("mrs %0, cpsr" : "=r"(cpsr));
+ __asm volatile ("msr cpsr_c, %0" :: "r"(cpsr | PSR_I));
+
+ return cpsr;
+}
+
+static inline void
+intr_restore(u_long cpsr)
+{
+ __asm volatile ("msr cpsr_c, %0" :: "r"(cpsr));
+}
#endif /* _KERNEL */
+#ifdef MULTIPROCESSOR
+#include <sys/mplock.h>
+#endif /* MULTIPROCESSOR */
+
#endif /* !_ARM_CPU_H_ */
diff --git a/sys/arch/arm/include/mplock.h b/sys/arch/arm/include/mplock.h
new file mode 100644
index 00000000000..a4da315b7a2
--- /dev/null
+++ b/sys/arch/arm/include/mplock.h
@@ -0,0 +1,10 @@
+/* $OpenBSD: mplock.h,v 1.1 2018/08/06 18:39:13 kettenis Exp $ */
+
+/* public domain */
+
+#ifndef _MACHINE_MPLOCK_H_
+#define _MACHINE_MPLOCK_H_
+
+#define __USE_MI_MPLOCK
+
+#endif /* !_MACHINE_MPLOCK_H */
diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c
index 41abc53ac50..988f64163a2 100644
--- a/sys/arch/armv7/armv7/armv7_machdep.c
+++ b/sys/arch/armv7/armv7/armv7_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: armv7_machdep.c,v 1.54 2018/05/31 09:12:59 kettenis Exp $ */
+/* $OpenBSD: armv7_machdep.c,v 1.55 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
@@ -256,7 +256,7 @@ haltsys:
config_suspend_all(DVACT_POWERDOWN);
/* Make sure IRQ's are disabled */
- IRQdisable;
+ intr_disable();
if ((howto & RB_HALT) != 0) {
if ((howto & RB_POWERDOWN) != 0) {
diff --git a/sys/arch/armv7/armv7/armv7_start.S b/sys/arch/armv7/armv7/armv7_start.S
index db7292f7c65..47160b5c0ac 100644
--- a/sys/arch/armv7/armv7/armv7_start.S
+++ b/sys/arch/armv7/armv7/armv7_start.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: armv7_start.S,v 1.15 2017/10/26 02:48:36 jsg Exp $ */
+/* $OpenBSD: armv7_start.S,v 1.16 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: lubbock_start.S,v 1.1 2003/06/18 10:51:15 bsh Exp $ */
/*
@@ -30,14 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "assym.h"
+
#include <machine/asm.h>
#include <arm/sysreg.h>
#include <arm/armreg.h>
#include <arm/pte.h>
-#undef DOMAIN_CLIENT /* XXX */
-#include "assym.h"
-
#ifdef __clang__
.arch_extension sec
.arch_extension virt
diff --git a/sys/arch/armv7/armv7/locore0.S b/sys/arch/armv7/armv7/locore0.S
index 62bbcb1bc39..13cfb9b3c84 100644
--- a/sys/arch/armv7/armv7/locore0.S
+++ b/sys/arch/armv7/armv7/locore0.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore0.S,v 1.4 2018/01/20 23:57:44 jsg Exp $ */
+/* $OpenBSD: locore0.S,v 1.5 2018/08/06 18:39:13 kettenis Exp $ */
/* $NetBSD: lubbock_start.S,v 1.1 2003/06/18 10:51:15 bsh Exp $ */
/*
@@ -30,14 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "assym.h"
+
#include <machine/asm.h>
#include <arm/sysreg.h>
#include <arm/armreg.h>
#include <arm/pte.h>
-#undef DOMAIN_CLIENT /* XXX */
-#include "assym.h"
-
#ifdef __clang__
.arch_extension virt
#define ELR msr ELR_hyp, lr
diff --git a/sys/arch/armv7/include/mplock.h b/sys/arch/armv7/include/mplock.h
new file mode 100644
index 00000000000..95913991b2e
--- /dev/null
+++ b/sys/arch/armv7/include/mplock.h
@@ -0,0 +1,3 @@
+/* $OpenBSD: mplock.h,v 1.1 2018/08/06 18:39:13 kettenis Exp $ */
+
+#include <arm/mplock.h>