summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2017-05-18 15:41:59 +0000
committerkettenis <kettenis@openbsd.org>2017-05-18 15:41:59 +0000
commit9f6778bb8c9dd55818505960ccb0028ad7f95d90 (patch)
treeb4b86adf24977304e3fc00471c96021d828ea95b
parentuse mergesort instead of heapsort when comparing results (diff)
downloadwireguard-openbsd-9f6778bb8c9dd55818505960ccb0028ad7f95d90.tar.xz
wireguard-openbsd-9f6778bb8c9dd55818505960ccb0028ad7f95d90.zip
Implement copyin32(9).
"your chicken scratches look fine to me" deraadt@
-rw-r--r--sys/arch/hppa/hppa/locore.S44
-rw-r--r--sys/arch/hppa/hppa/machdep.c11
-rw-r--r--sys/arch/hppa/include/cpu.h4
3 files changed, 54 insertions, 5 deletions
diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S
index dbd995b2472..85e98e8a80e 100644
--- a/sys/arch/hppa/hppa/locore.S
+++ b/sys/arch/hppa/hppa/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.196 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: locore.S,v 1.197 2017/05/18 15:41:59 kettenis Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -2737,6 +2737,48 @@ $spstrcpy_exit
EXIT(spstrcpy)
/*
+ * int spcopy32 (pa_space_t ssp, const uint32_t *src, pa_space_t dsp,
+ * uint32_t *dst)
+ * do an atomic space to space copy of a futex
+ */
+LEAF_ENTRY(spcopy32)
+ extru arg1, 31, 2, t3
+ extru arg3, 31, 2, t4
+ comb,<>,n 0, t3, $spcopy32_misaligned
+ comb,<>,n 0, t4, $spcopy32_misaligned
+
+ ldo 64(sp), sp
+ stw rp, HPPA_FRAME_CRP(sp)
+ /* setup fault handler */
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t3
+ ldil L%copy_on_fault, t2
+ ldw P_ADDR(t3), r2
+ ldo R%copy_on_fault(t2), t2
+ ldw PCB_ONFAULT+U_PCB(r2), r1
+ stw t2, PCB_ONFAULT+U_PCB(r2)
+
+ mtsp arg0, sr1
+ mtsp arg2, sr2
+
+ ldw 0(sr1, arg1), t1
+ stw t1, 0(sr2, arg3)
+
+ mtsp r0, sr1
+ mtsp r0, sr2
+ /* reset fault handler */
+ stw r1, PCB_ONFAULT+U_PCB(r2)
+ ldw HPPA_FRAME_CRP(sp), rp
+ ldo -64(sp), sp
+ bv 0(rp)
+ copy r0, ret0
+
+$spcopy32_misaligned
+ bv 0(rp)
+ ldi EFAULT, ret0
+EXIT(spcopy32)
+
+/*
* int cpu_switchto(struct proc *old, struct proc *new)
* Switch from "old" proc to "new".
*/
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index ec9186f12a7..3a1f4888238 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.247 2016/10/09 11:25:39 tom Exp $ */
+/* $OpenBSD: machdep.c,v 1.248 2017/05/18 15:41:59 kettenis Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1105,7 +1105,6 @@ copyinstr(const void *src, void *dst, size_t size, size_t *lenp)
HPPA_SID_KERNEL, dst, size, lenp);
}
-
int
copyoutstr(const void *src, void *dst, size_t size, size_t *lenp)
{
@@ -1113,7 +1112,6 @@ copyoutstr(const void *src, void *dst, size_t size, size_t *lenp)
curproc->p_addr->u_pcb.pcb_space, dst, size, lenp);
}
-
int
copyin(const void *src, void *dst, size_t size)
{
@@ -1128,6 +1126,13 @@ copyout(const void *src, void *dst, size_t size)
curproc->p_addr->u_pcb.pcb_space, dst, size);
}
+int
+copyin32(const uint32_t *src, uint32_t *dst)
+{
+ return spcopy32(curproc->p_addr->u_pcb.pcb_space, src,
+ HPPA_SID_KERNEL, dst);
+}
+
/*
* Set up tf_sp and tf_r3 (the frame pointer) and copy out the
* frame marker and the old r3
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index 4c9407bf35a..92bcf95b4ca 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.89 2016/05/10 14:52:03 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.90 2017/05/18 15:41:59 kettenis Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -228,6 +228,8 @@ void hppa_init(paddr_t start);
void trap(int type, struct trapframe *frame);
int spcopy(pa_space_t ssp, const void *src,
pa_space_t dsp, void *dst, size_t size);
+int spcopy32(pa_space_t ssp, const uint32_t *src,
+ pa_space_t dsp, uint32_t *dst);
int spstrcpy(pa_space_t ssp, const void *src,
pa_space_t dsp, void *dst, size_t size, size_t *rsize);
int copy_on_fault(void);