summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2017-08-30 15:54:34 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2017-08-30 15:54:34 +0000
commit48aa8ff5be637f4d54aca3c940e4ec4947c885d1 (patch)
tree526cdde94879e6bd847d945ef478951d783f7a5e
parent98a0f06994bed5910f3caaf1a7a318cdc11d62e4 (diff)
Prefer copyin32() to copyin() when fetching instructions
from user space. This improves performance slightly. Discussed with miod@
-rw-r--r--sys/arch/mips64/mips64/fp_emulate.c7
-rw-r--r--sys/arch/mips64/mips64/trap.c16
2 files changed, 15 insertions, 8 deletions
diff --git a/sys/arch/mips64/mips64/fp_emulate.c b/sys/arch/mips64/mips64/fp_emulate.c
index f6bee8e04c6..f60c99932ab 100644
--- a/sys/arch/mips64/mips64/fp_emulate.c
+++ b/sys/arch/mips64/mips64/fp_emulate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fp_emulate.c,v 1.16 2017/08/26 15:21:48 visa Exp $ */
+/* $OpenBSD: fp_emulate.c,v 1.17 2017/08/30 15:54:33 visa Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -188,7 +188,7 @@ MipsFPTrap(struct trapframe *tf)
* if it does, it's probably not your lucky day.
*/
- if (copyin((void *)pc, &insn, sizeof insn) != 0) {
+ if (copyin32((const void *)pc, &insn) != 0) {
sig = SIGBUS;
fault_type = BUS_OBJERR;
goto deliver;
@@ -1613,8 +1613,7 @@ nofpu_emulate_cop1(struct proc *p, struct trapframe *tf, uint32_t insn,
*/
/* inline MipsEmulateBranch(tf, tf->pc, tf->fsr, insn)*/
dest = tf->pc + 4 + ((short)inst.IType.imm << 2);
- if (copyin((const void *)(tf->pc + 4), &dinsn,
- sizeof dinsn)) {
+ if (copyin32((const void *)(tf->pc + 4), &dinsn) != 0) {
sv->sival_ptr = (void *)(tf->pc + 4);
return SIGSEGV;
}
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index 9e2980dd18b..c93d1db3187 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.128 2017/08/26 15:21:48 visa Exp $ */
+/* $OpenBSD: trap.c,v 1.129 2017/08/30 15:54:33 visa Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -606,7 +606,11 @@ fault_common_no_miss:
}
/* read break instruction */
- copyin(va, &instr, sizeof(int32_t));
+ if (copyin32((const void *)va, &instr) != 0) {
+ signal = SIGBUS;
+ sicode = BUS_OBJERR;
+ break;
+ }
switch ((instr & BREAK_VAL_MASK) >> BREAK_VAL_SHIFT) {
case 6: /* gcc range error */
@@ -723,7 +727,11 @@ fault_common_no_miss:
}
/* read break instruction */
- copyin(va, &instr, sizeof(int32_t));
+ if (copyin32((const void *)va, &instr) != 0) {
+ signal = SIGBUS;
+ sicode = BUS_OBJERR;
+ break;
+ }
if (trapframe->cause & CR_BR_DELAY)
locr0->pc = MipsEmulateBranch(locr0,
@@ -768,7 +776,7 @@ fault_common_no_miss:
}
/* Get the faulting instruction. */
- if (copyin32((void *)va, &inst.word) != 0) {
+ if (copyin32((const void *)va, &inst.word) != 0) {
signal = SIGBUS;
sicode = BUS_OBJERR;
break;