-/* $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 $ */
/*
* 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");
}
-/* $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 $ */
* Created : 08/04/95
*/
-#include <machine/asm.h>
-
#include "assym.h"
+#include <machine/asm.h>
+
/* #define BIG_LOOPS */
/*
-/* $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 $ */
/*
#include "assym.h"
+#include <sys/errno.h>
+
#include <machine/asm.h>
#include <arm/sysreg.h>
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
* We save/restore r4-r11:
* r4-r11 are scratch
*/
-
ENTRY(copyout)
/* Quick exit if length is zero */
teq r2, #0
-/* $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 $ */
/*
*/
#include "assym.h"
+
+#include <sys/errno.h>
+
#include <machine/asm.h>
#include <arm/sysreg.h>
-#include <sys/errno.h>
.text
.align 2
-/* $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 $ */
}
#ifdef MULTIPROCESSOR
+
+void
+cpu_boot_secondary_processors(void)
+{
+}
+
int
cpu_alloc_idle_pcb(struct cpu_info *ci)
{
-/* $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 $ */
/*
* Created : 30/01/97
*/
-#include <machine/cpu.h>
#include <machine/asm.h>
#include <arm/sysreg.h>
-/* $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>
*
* 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>
-/* $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 $ */
/*
*/
#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> */
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
-/* $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 $ */
/*
* 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
-/* $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 $ */
/*
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
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)
}
#endif
+ KERNEL_LOCK();
error = uvm_fault(map, va, 0, PROT_READ | PROT_EXEC);
+ KERNEL_UNLOCK();
if (__predict_true(error == 0))
goto out;
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);
-# $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.
define __ARM_FIQ_INDIRECT 1
endif
-export DOMAIN_CLIENT
export PMAP_DOMAIN_KERNEL
ifdef PMAP_INCLUDE_PTE_SYNC
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)
-/* $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 $ */
/*
* Hand-optimised in_cksum() and in4_cksum() implementations for ARM/Xscale
*/
-#include <machine/asm.h>
#include "assym.h"
+#include <machine/asm.h>
+
.syntax unified
/*
-/* $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 $ */
/*
#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>
-/* $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 $ */
/*
*/
#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
-/* $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 $ */
/*
* 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.
-/* $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 $ */
/*
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
-
#include "assym.h"
+
#include <sys/syscall.h>
+#include <machine/asm.h>
+
/*
* Signal trampoline;
*/
-/* $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 $ */
/*
uvmexp.softs++;
mtx_leave(&siq->siq_mtx);
+ KERNEL_LOCK();
(*sih->sih_func)(sih->sih_arg);
+ KERNEL_UNLOCK();
}
}
-/* $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 $ */
/*
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;
}
}
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;
}
}
sv.sival_int = frame->tf_pc;
+ KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
+ KERNEL_UNLOCK();
}
if ((fault_code & FAULT_USER) == 0)
-/* $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 $ */
/*
*/
#include "assym.h"
+
#include <machine/asm.h>
/*
-/* $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>
*
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;
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
if (ih->ih_func(arg))
ih->ih_count.ec_count++;
+#ifdef MULTIPROCESSOR
+ if (need_lock)
+ KERNEL_UNLOCK();
+#endif
}
ampintc_eoi(iack_val);
-/* $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 $ */
/*
#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. */
#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;
int ci_mutex_level;
#endif
+#ifdef MULTIPROCESSOR
+ struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM];
+#endif
+
#ifdef GPROF
struct gmonparam *ci_gmon;
#endif
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)
{
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
/* 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_ */
--- /dev/null
+/* $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 */
-/* $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 $ */
/*
config_suspend_all(DVACT_POWERDOWN);
/* Make sure IRQ's are disabled */
- IRQdisable;
+ intr_disable();
if ((howto & RB_HALT) != 0) {
if ((howto & RB_POWERDOWN) != 0) {
-/* $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 $ */
/*
* 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
-/* $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 $ */
/*
* 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
--- /dev/null
+/* $OpenBSD: mplock.h,v 1.1 2018/08/06 18:39:13 kettenis Exp $ */
+
+#include <arm/mplock.h>