diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-01-09 22:27:13 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-01-09 22:27:13 +0000 |
commit | 332a483dedd5c976b45635d3ef8337dfdd377f08 (patch) | |
tree | bcd0800a8732b7099fd64ce366155836b0f6e6ce /sys/arch | |
parent | c88cb37963768d4ddbf78335478986b31599e25a (diff) |
Remove fetch(9) and store(9) functions from the kernel, and replace the few
remaining instances of them with appropriate copy(9) usage.
ok art@, tested on all arches unless my memory is non-ECC
Diffstat (limited to 'sys/arch')
39 files changed, 397 insertions, 1799 deletions
diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s index 3d4e3958bc5..bccc145fad8 100644 --- a/sys/arch/alpha/alpha/locore.s +++ b/sys/arch/alpha/alpha/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.19 2002/05/02 23:05:27 millert Exp $ */ +/* $OpenBSD: locore.s,v 1.20 2003/01/09 22:27:03 miod Exp $ */ /* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */ /*- @@ -1460,319 +1460,6 @@ END(copyerr) /**************************************************************************/ /* - * {fu,su},{ibyte,isword,iword}, fetch or store a byte, short or word to - * user text space. - * {fu,su},{byte,sword,word}, fetch or store a byte, short or word to - * user data space. - */ -LEAF(fuword, 1) -XLEAF(fuiword, 1) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - ldq v0, 0(a0) - zap v0, 0xf0, v0 - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - RET - END(fuword) - -LEAF(fusword, 1) -XLEAF(fuisword, 1) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - /* XXX FETCH IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - RET - END(fusword) - -LEAF(fubyte, 1) -XLEAF(fuibyte, 1) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - /* XXX FETCH IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - RET - END(fubyte) - -LEAF(suword, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - stq a1, 0(a0) /* do the store. */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - mov zero, v0 - RET - END(suword) - -#ifdef notdef -LEAF(suiword, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - /* XXX STORE IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - call_pal PAL_OSF1_imb /* sync instruction stream */ - mov zero, v0 - RET - END(suiword) - -LEAF(susword, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - /* XXX STORE IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - mov zero, v0 - RET - END(susword) - -LEAF(suisword, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - /* XXX STORE IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - call_pal PAL_OSF1_imb /* sync instruction stream */ - mov zero, v0 - RET - END(suisword) -#endif /* notdef */ - -LEAF(subyte, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - zap a1, 0xfe, a1 /* kill arg's high bytes */ - insbl a1, a0, a1 /* move it to the right byte */ - ldq_u t0, 0(a0) /* load quad around byte */ - mskbl t0, a0, t0 /* kill the target byte */ - or t0, a1, a1 /* put the result together */ - stq_u a1, 0(a0) /* and store it. */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - mov zero, v0 - RET - END(subyte) - -LEAF(suibyte, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - .set at - zap a1, 0xfe, a1 /* kill arg's high bytes */ - insbl a1, a0, a1 /* move it to the right byte */ - ldq_u t0, 0(a0) /* load quad around byte */ - mskbl t0, a0, t0 /* kill the target byte */ - or t0, a1, a1 /* put the result together */ - stq_u a1, 0(a0) /* and store it. */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - call_pal PAL_OSF1_imb /* sync instruction stream */ - mov zero, v0 - RET - END(suibyte) - -LEAF(fswberr, 0) - LDGP(pv) - ldiq v0, -1 - RET - END(fswberr) - -/**************************************************************************/ - -#ifdef notdef -/* - * fuswintr and suswintr are just like fusword and susword except that if - * the page is not in memory or would cause a trap, then we return an error. - * The important thing is to prevent sleep() and switch(). - */ - -LEAF(fuswintr, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswintrberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswintrberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - stq a0, U_PCB_ACCESSADDR(at_reg) - .set at - /* XXX FETCH IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - RET - END(fuswintr) - -LEAF(suswintr, 2) - LDGP(pv) - ldiq t0, VM_MAX_ADDRESS /* make sure that addr */ - cmpult a0, t0, t1 /* is in user space. */ - beq t1, fswintrberr /* if it's not, error out. */ - /* Note: GET_CURPROC clobbers v0, t0, t8...t11. */ - GET_CURPROC - mov v0, t1 - lda t0, fswintrberr - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq t0, U_PCB_ONFAULT(at_reg) - stq a0, U_PCB_ACCESSADDR(at_reg) - .set at - /* XXX STORE IT */ - .set noat - ldq at_reg, 0(t1) - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) - .set at - mov zero, v0 - RET - END(suswintr) -#endif - -LEAF(fswintrberr, 0) -XLEAF(fuswintr, 2) /* XXX what is a 'word'? */ -XLEAF(suswintr, 2) /* XXX what is a 'word'? */ - LDGP(pv) - ldiq v0, -1 - RET - END(fswberr) - -/**************************************************************************/ - -/* * Some bogus data, to keep vmstat happy, for now. */ diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 56c5a9b2f0e..040952ddc30 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.38 2002/07/24 00:33:49 art Exp $ */ +/* $OpenBSD: trap.c,v 1.39 2003/01/09 22:27:03 miod Exp $ */ /* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */ /*- @@ -456,24 +456,6 @@ trap(a0, a1, a2, entry, framep) do_fault: /* - * If it was caused by fuswintr or suswintr, - * just punt. Note that we check the faulting - * address against the address accessed by - * [fs]uswintr, in case another fault happens - * when they are running. - */ - if (!user && - p != NULL && - p->p_addr->u_pcb.pcb_onfault == - (unsigned long)fswintrberr && - p->p_addr->u_pcb.pcb_accessaddr == a0) { - framep->tf_regs[FRAME_PC] = - p->p_addr->u_pcb.pcb_onfault; - p->p_addr->u_pcb.pcb_onfault = 0; - goto out; - } - - /* * It is only a kernel address space fault iff: * 1. !user and * 2. pcb_onfault not set or diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c index 0ff3b6a102d..a14831ebe73 100644 --- a/sys/arch/hp300/hp300/hpux_machdep.c +++ b/sys/arch/hp300/hp300/hpux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_machdep.c,v 1.14 2002/08/02 16:11:11 millert Exp $ */ +/* $OpenBSD: hpux_machdep.c,v 1.15 2003/01/09 22:27:08 miod Exp $ */ /* $NetBSD: hpux_machdep.c,v 1.19 1998/02/16 20:58:30 thorpej Exp $ */ /* @@ -614,17 +614,13 @@ hpux_sys_sigreturn(p, v, retval) * See if there is anything to do before we go to the * expense of copying in close to 1/2K of data */ - flags = fuword((caddr_t)rf); + if (copyin((caddr_t)rf, &flags, sizeof(int)) != 0) + return (EINVAL); #ifdef DEBUG if (hpuxsigdebug & SDB_FOLLOW) printf("sigreturn(%d): sc_ap %x flags %x\n", p->p_pid, rf, flags); #endif - /* - * fuword failed (bogus _hsc_ap value). - */ - if (flags == -1) - return (EINVAL); if (flags == 0 || copyin((caddr_t)rf, (caddr_t)&tstate, sizeof tstate)) return (EJUSTRETURN); #ifdef DEBUG diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index 02aef00e1d2..072f726eb0c 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.39 2002/12/09 00:45:37 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.40 2003/01/09 22:27:08 miod Exp $ */ /* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */ /* @@ -284,7 +284,6 @@ trap(type, code, v, frame) unsigned v; struct frame frame; { - extern char fubail[], subail[]; struct proc *p; int i, s; u_int ucode; @@ -591,15 +590,6 @@ dopanic: goto out; case T_MMUFLT: /* kernel mode page fault */ - /* - * If we were doing profiling ticks or other user mode - * stuff from interrupt code, Just Say No. - */ - if (p->p_addr->u_pcb.pcb_onfault == fubail || - p->p_addr->u_pcb.pcb_onfault == subail) - goto copyfault; - /* FALLTHROUGH */ - case T_MMUFLT|T_USER: /* page fault */ { vaddr_t va; @@ -845,7 +835,8 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb1s)) *(long *)f->f_wb1a = wb1d; else - err = suword((caddr_t)f->f_wb1a, wb1d); + err = copyout(&wb1d, (caddr_t)f->f_wb1a, + sizeof(int)); break; case SSW4_SZB: off = 24 - off; @@ -853,8 +844,12 @@ writeback(fp, docachepush) wb1d >>= off; if (KDFAULT(f->f_wb1s)) *(char *)f->f_wb1a = wb1d; - else - err = subyte((caddr_t)f->f_wb1a, wb1d); + else { + char tmp = wb1d; + + err = copyout(&tmp, (caddr_t)f->f_wb1a, + sizeof(char)); + } break; case SSW4_SZW: off = (off + 16) % 32; @@ -862,8 +857,12 @@ writeback(fp, docachepush) wb1d = (wb1d >> (32 - off)) | (wb1d << off); if (KDFAULT(f->f_wb1s)) *(short *)f->f_wb1a = wb1d; - else - err = susword((caddr_t)f->f_wb1a, wb1d); + else { + short tmp = wb1d; + + err = copyout(&tmp, (caddr_t)f->f_wb1a, + sizeof(short)); + } break; } if (err) { @@ -895,19 +894,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb2s)) *(long *)f->f_wb2a = f->f_wb2d; else - err = suword((caddr_t)f->f_wb2a, f->f_wb2d); + err = copyout(&f->f_wb2d, (caddr_t)f->f_wb2a, + sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb2s)) *(char *)f->f_wb2a = f->f_wb2d; - else - err = subyte((caddr_t)f->f_wb2a, f->f_wb2d); + else { + char tmp = f->f_wb2d; + + err = copyout(&tmp, (caddr_t)f->f_wb2a, + sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb2s)) *(short *)f->f_wb2a = f->f_wb2d; - else - err = susword((caddr_t)f->f_wb2a, f->f_wb2d); + else { + short tmp = f->f_wb2d; + + err = copyout(&tmp, (caddr_t)f->f_wb2a, + sizeof(short)); + } break; } if (err) { @@ -935,19 +943,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb3s)) *(long *)f->f_wb3a = f->f_wb3d; else - err = suword((caddr_t)f->f_wb3a, f->f_wb3d); + err = copyout(&f->f_wb3d, (caddr_t)f->f_wb3a, + sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb3s)) *(char *)f->f_wb3a = f->f_wb3d; - else - err = subyte((caddr_t)f->f_wb3a, f->f_wb3d); + else { + char tmp = f->f_wb3d; + + err = copyout(&tmp, (caddr_t)f->f_wb3a, + sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb3s)) *(short *)f->f_wb3a = f->f_wb3d; - else - err = susword((caddr_t)f->f_wb3a, f->f_wb3d); + else { + short tmp = f->f_wb3d; + + err = copyout(&tmp, (caddr_t)f->f_wb3a, + sizeof(short)); + } break; #ifdef DEBUG case SSW4_SZLN: @@ -1009,6 +1026,7 @@ dumpwb(num, s, a, d) { struct proc *p = curproc; paddr_t pa; + int tmp; printf(" writeback #%d: VA %x, data %x, SZ=%s, TT=%s, TM=%s\n", num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], @@ -1016,8 +1034,12 @@ dumpwb(num, s, a, d) printf(" PA "); if (pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a, &pa) == FALSE) printf("<invalid address>"); - else - printf("%lx, current value %lx", pa, fuword((caddr_t)a)); + else { + if (copyin((caddr_t)a, &tmp, sizeof(int)) == 0) + printf("%lx, current value %lx", pa, tmp); + else + printf("%lx, current value inaccessible", pa); + } printf("\n"); } #endif @@ -1059,7 +1081,9 @@ syscall(code, frame) * code assumes the kernel pops the syscall argument the * glue pushed on the stack. Sigh... */ - code = fuword((caddr_t)frame.f_regs[SP]); + if (copyin((caddr_t)frame.f_regs[SP], &code, + sizeof(register_t)) != 0) + code = -1; /* * XXX @@ -1087,7 +1111,8 @@ syscall(code, frame) /* * Code is first argument, followed by actual args. */ - code = fuword(params); + if (copyin(params, &code, sizeof(register_t)) != 0) + code = -1; params += sizeof(int); /* * XXX sigreturn requires special stack manipulation @@ -1104,7 +1129,9 @@ syscall(code, frame) */ if (callp != sysent) break; - code = fuword(params + _QUAD_LOWWORD * sizeof(int)); + if (copyin(params + _QUAD_LOWWORD * sizeof(int), &code, + sizeof(register_t)) != 0) + code = -1; params += sizeof(quad_t); break; default: diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S index e4d4ee50686..4783c209598 100644 --- a/sys/arch/hppa/hppa/locore.S +++ b/sys/arch/hppa/hppa/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.100 2002/12/17 22:46:31 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.101 2003/01/09 22:27:08 miod Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -2444,55 +2444,6 @@ EXIT(longjmp) .align 32 -#define FUSUX(name) \ -LEAF_ENTRY(name) ! \ - ldil L%VM_MAXUSER_ADDRESS, t1 ! \ - comb,>>= arg0, t1, fusubadaddr ! \ - ldil L%curproc, t1 ! \ - ldw R%curproc(t1), t1 ! \ - ldw P_ADDR(t1), t1 ! \ - ldil L%fusufault, t2 ! \ - ldo R%fusufault(t2), t2 ! \ - ldw U_PCB+PCB_ONFAULT(t1), r1 ! \ - stw t2, U_PCB+PCB_ONFAULT(t1) ! \ - ldw U_PCB+PCB_SPACE(t1), t2 ! \ - mtsp t2, sr1 - -#define FUX(name,insn) \ - FUSUX(name) ! \ - insn 0(sr1, arg0), ret0 ! \ - mtsp r0, sr1 ! \ - bv r0(rp) ! \ - stw r1, U_PCB+PCB_ONFAULT(t1) ! \ -EXIT(name) - -#define SUX(name,insn) \ - FUSUX(name) ! \ - insn arg1, 0(sr1, arg0) ! \ - mtsp r0, sr1 ! \ - bv r0(rp) ! \ - stw r1, U_PCB+PCB_ONFAULT(t1) ! \ -EXIT(name) - -LEAF_ENTRY(fusufault) - mtsp r0, sr1 - stw r1, U_PCB+PCB_ONFAULT(t1) -ALTENTRY(fusubadaddr) - bv 0(rp) - ldi -1, ret0 -EXIT(fusuexit) - -FUX(fubyte, ldb) -FUX(fusword, ldh) -FUX(fuword, ldw) -FUX(fuswintr, ldh) -SUX(subyte, stb) -SUX(susword, sth) -SUX(suword, stw) -SUX(suswintr, sth) - - .align 32 - LEAF_ENTRY(copy_on_fault) mtsp r0, sr1 mtsp r0, sr2 diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index 97aa80b8f41..178d1d7ddcb 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.93 2002/12/19 00:46:21 mickey Exp $ */ +/* $OpenBSD: machdep.c,v 1.94 2003/01/09 22:27:09 miod Exp $ */ /* * Copyright (c) 1999-2002 Michael Shalayeff @@ -1163,14 +1163,15 @@ copyout(src, dst, size) */ void setregs(p, pack, stack, retval) - register struct proc *p; + struct proc *p; struct exec_package *pack; u_long stack; register_t *retval; { extern paddr_t fpu_curpcb; /* from locore.S */ - register struct trapframe *tf = p->p_md.md_regs; - register struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = p->p_md.md_regs; + struct pcb *pcb = &p->p_addr->u_pcb; + register_t zero; #ifdef DEBUG /*extern int pmapdebug;*/ /*pmapdebug = 13; @@ -1189,8 +1190,9 @@ setregs(p, pack, stack, retval) stack = hppa_round_page(stack); tf->tf_r3 = stack; tf->tf_sp = stack += HPPA_FRAME_SIZE; - suword((caddr_t)(stack - HPPA_FRAME_SIZE), 0); - suword((caddr_t)(stack + HPPA_FRAME_CRP), 0); + zero = 0; + copyout(&zero, (caddr_t)(stack - HPPA_FRAME_SIZE), sizeof(register_t)); + copyout(&zero, (caddr_t)(stack + HPPA_FRAME_CRP), sizeof(register_t)); /* reset any of the pending FPU exceptions */ pcb->pcb_fpregs[0] = ((u_int64_t)HPPA_FPU_INIT) << 32; @@ -1224,6 +1226,7 @@ sendsig(catcher, sig, mask, code, type, val) struct sigcontext ksc, *scp; siginfo_t ksi, *sip; int sss; + register_t zero; #ifdef DEBUG if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid)) @@ -1264,8 +1267,11 @@ sendsig(catcher, sig, mask, code, type, val) sigexit(p, SIGILL); sss += HPPA_FRAME_SIZE; - if (suword((caddr_t)scp + sss - HPPA_FRAME_SIZE, 0) || - suword((caddr_t)scp + sss + HPPA_FRAME_CRP, 0)) + zero = 0; + if (copyout(&zero, (caddr_t)scp + sss - HPPA_FRAME_SIZE, + sizeof(register_t)) || + copyout(&zero, (caddr_t)scp + sss + HPPA_FRAME_CRP, + sizeof(register_t))) sigexit(p, SIGILL); #ifdef DEBUG diff --git a/sys/arch/i386/i386/linux_machdep.c b/sys/arch/i386/i386/linux_machdep.c index fc3989a98fd..8d580b53ec1 100644 --- a/sys/arch/i386/i386/linux_machdep.c +++ b/sys/arch/i386/i386/linux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_machdep.c,v 1.23 2002/07/20 19:24:56 art Exp $ */ +/* $OpenBSD: linux_machdep.c,v 1.24 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: linux_machdep.c,v 1.29 1996/05/03 19:42:11 christos Exp $ */ /* @@ -574,8 +574,12 @@ linux_machdepioctl(p, v, retval) com = VT_GETSTATE; break; case LINUX_KDGKBTYPE: + { + char tmp = KB_101; + /* This is what Linux does */ - return (subyte(SCARG(uap, data), KB_101)); + return copyout(&tmp, SCARG(uap, data), sizeof(char)); + } #endif default: /* diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 09522831414..40dc899926c 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.67 2002/10/29 01:52:46 art Exp $ */ +/* $OpenBSD: locore.s,v 1.68 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -1231,243 +1231,33 @@ ENTRY(copystr) /* * fuword(caddr_t uaddr); * Fetch an int from the user's address space. + * Not used outside locore anymore. */ -ENTRY(fuword) +ASENTRY(fuword) movl 4(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx - ja _C_LABEL(fusuaddrfault) + ja _ASM_LABEL(fusuaddrfault) movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) + movl $_ASM_LABEL(fusufault),PCB_ONFAULT(%ecx) movl (%edx),%eax movl $0,PCB_ONFAULT(%ecx) ret /* - * fusword(caddr_t uaddr); - * Fetch a short from the user's address space. + * Handle faults from fuword. Clean up and return -1. */ -ENTRY(fusword) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-2,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) - movzwl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -/* - * fuswintr(caddr_t uaddr); - * Fetch a short from the user's address space. Can be called during an - * interrupt. - */ -ENTRY(fuswintr) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-2,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusubail),PCB_ONFAULT(%ecx) - movzwl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -/* - * fubyte(caddr_t uaddr); - * Fetch a byte from the user's address space. - */ -ENTRY(fubyte) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-1,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) - movzbl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -/* - * Handle faults from [fs]u*(). Clean up and return -1. - */ -ENTRY(fusufault) +ASENTRY(fusufault) movl $0,PCB_ONFAULT(%ecx) movl $-1,%eax ret /* - * Handle faults from [fs]u*(). Clean up and return -1. This differs from - * fusufault() in that trap() will recognize it and return immediately rather - * than trying to page fault. + * Handle earlier faults from fuword, due to our of range addresses. */ -ENTRY(fusubail) - movl $0,PCB_ONFAULT(%ecx) +ASENTRY(fusuaddrfault) movl $-1,%eax ret -/* - * Handle earlier faults from [fs]u*(), due to our of range addresses. - */ -ENTRY(fusuaddrfault) - movl $-1,%eax - ret - -/* - * suword(caddr_t uaddr, int x); - * Store an int in the user's address space. - */ -ENTRY(suword) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-4,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) - -#if defined(I386_CPU) -#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) - cmpl $CPUCLASS_386,_C_LABEL(cpu_class) - jne 2f -#endif /* I486_CPU || I586_CPU || I686_CPU */ - - movl %edx,%eax - shrl $PGSHIFT,%eax # calculate pte address - testb $PG_RW,_C_LABEL(PTmap)(,%eax,4) - jnz 1f - - /* Simulate a trap. */ - pushl %edx - pushl %edx - call _C_LABEL(trapwrite) # trapwrite(addr) - addl $4,%esp # clear parameter from the stack - popl %edx - movl _C_LABEL(curpcb),%ecx - testl %eax,%eax - jnz _C_LABEL(fusufault) - -1: /* XXX also need to check the following 3 bytes for validity! */ -#endif - -2: movl 8(%esp),%eax - movl %eax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -/* - * susword(caddr_t uaddr, short x); - * Store a short in the user's address space. - */ -ENTRY(susword) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-2,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) - -#if defined(I386_CPU) -#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) - cmpl $CPUCLASS_386,_C_LABEL(cpu_class) - jne 2f -#endif /* I486_CPU || I586_CPU || I686_CPU */ - - movl %edx,%eax - shrl $PGSHIFT,%eax # calculate pte address - testb $PG_RW,_C_LABEL(PTmap)(,%eax,4) - jnz 1f - - /* Simulate a trap. */ - pushl %edx - pushl %edx - call _C_LABEL(trapwrite) # trapwrite(addr) - addl $4,%esp # clear parameter from the stack - popl %edx - movl _C_LABEL(curpcb),%ecx - testl %eax,%eax - jnz _C_LABEL(fusufault) - -1: /* XXX also need to check the following byte for validity! */ -#endif - -2: movl 8(%esp),%eax - movw %ax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -/* - * suswintr(caddr_t uaddr, short x); - * Store a short in the user's address space. Can be called during an - * interrupt. - */ -ENTRY(suswintr) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-2,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusubail),PCB_ONFAULT(%ecx) - -#if defined(I386_CPU) -#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) - cmpl $CPUCLASS_386,_C_LABEL(cpu_class) - jne 2f -#endif /* I486_CPU || I586_CPU || I686_CPU */ - - movl %edx,%eax - shrl $PGSHIFT,%eax # calculate pte address - testb $PG_RW,_C_LABEL(PTmap)(,%eax,4) - jnz 1f - - /* Simulate a trap. */ - jmp _C_LABEL(fusubail) - -1: /* XXX also need to check the following byte for validity! */ -#endif - -2: movl 8(%esp),%eax - movw %ax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -/* - * subyte(caddr_t uaddr, char x); - * Store a byte in the user's address space. - */ -ENTRY(subyte) - movl 4(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-1,%edx - ja _C_LABEL(fusuaddrfault) - movl _C_LABEL(curpcb),%ecx - movl $_C_LABEL(fusufault),PCB_ONFAULT(%ecx) - -#if defined(I386_CPU) -#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) - cmpl $CPUCLASS_386,_C_LABEL(cpu_class) - jne 2f -#endif /* I486_CPU || I586_CPU || I686_CPU */ - - movl %edx,%eax - shrl $PGSHIFT,%eax # calculate pte address - testb $PG_RW,_C_LABEL(PTmap)(,%eax,4) - jnz 1f - - /* Simulate a trap. */ - pushl %edx - pushl %edx - call _C_LABEL(trapwrite) # trapwrite(addr) - addl $4,%esp # clear parameter from the stack - popl %edx - movl _C_LABEL(curpcb),%ecx - testl %eax,%eax - jnz _C_LABEL(fusufault) - -1: -#endif - -2: movb 8(%esp),%al - movb %al,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - /*****************************************************************************/ /* @@ -2125,7 +1915,7 @@ syscall1: cmpl $SYS_syscall,%esi jne 5f pushl %edi - CALL _C_LABEL(fuword) + CALL _ASM_LABEL(fuword) movl %eax,%esi # indirect syscall no for SYS_syscall leal 4(%edi),%edi # shift parameters jmp 6f @@ -2133,20 +1923,20 @@ syscall1: cmpl $SYS___syscall,%esi jne 6f pushl %edi - CALL _C_LABEL(fuword) + CALL _ASM_LABEL(fuword) movl %eax,%esi # indirect syscall no for SYS___syscall leal 8(%edi),%edi # shift parameters (quad alignment) 6: leal 8(%edi),%ecx pushl %ecx - call _C_LABEL(fuword) + call _ASM_LABEL(fuword) movl %eax,(%esp) # 3rd syscall arg leal 4(%edi),%ecx pushl %ecx - call _C_LABEL(fuword) + call _ASM_LABEL(fuword) movl %eax,(%esp) # 2nd syscall arg pushl %edi - call _C_LABEL(fuword) + call _ASM_LABEL(fuword) movl %eax,(%esp) # 1st syscall arg pushl %esi # syscall no pushl _C_LABEL(cpl) # current spl diff --git a/sys/arch/i386/i386/math_emulate.c b/sys/arch/i386/i386/math_emulate.c index d51efca8c81..a60b7958015 100644 --- a/sys/arch/i386/i386/math_emulate.c +++ b/sys/arch/i386/i386/math_emulate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: math_emulate.c,v 1.5 2002/03/14 03:15:53 millert Exp $ */ +/* $OpenBSD: math_emulate.c,v 1.6 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: math_emulate.c,v 1.17 1996/05/03 19:42:17 christos Exp $ */ /* @@ -94,7 +94,9 @@ math_emulate(info) I387.fip = oldeip = info->tf_eip; info->tf_eip += 2; - code = htons(fusword((u_short *) oldeip)) & 0x7ff; + if (copyin((u_short *)oldeip, &code, sizeof(u_short)) != 0) + math_abort(info,SIGSEGV); + code = htons(code) & 0x7ff; *((u_short *) &I387.fcs) = (u_short) info->tf_cs; *((u_short *) &I387.fcs + 1) = code; @@ -346,20 +348,23 @@ math_emulate(info) return(0); case 0x24: address = ea(info,code); - copyin((u_long *) address, (u_long *) &I387, 28); + if (copyin((u_long *) address, (u_long *) &I387, 28) != 0) + math_abort(info,SIGSEGV); return(0); case 0x25: address = ea(info,code); - *(u_short *) &I387.cwd = - fusword((u_short *) address); + if (copyin((u_short *)address, &I387.cwd, sizeof(u_short)) != 0) + math_abort(info,SIGSEGV); return(0); case 0x26: address = ea(info,code); - copyout((u_long *) &I387, (u_long *) address, 28); + if (copyout((u_long *) &I387, (u_long *) address, 28) != 0) + math_abort(info,SIGSEGV); return(0); case 0x27: address = ea(info,code); - susword((u_short *) address, I387.cwd); + if (copyout(&I387.cwd, address, sizeof(int16_t)) != 0) + math_abort(info,SIGSEGV); return(0); case 0x62: put_long_int(PST(0),info,code); @@ -386,16 +391,19 @@ math_emulate(info) return(0); case 0xa4: address = ea(info,code); - copyin((u_long *) address, (u_long *) &I387, 108); + if (copyin((u_long *) address, (u_long *) &I387, 108) != 0) + math_abort(info,SIGSEGV); return(0); case 0xa6: address = ea(info,code); - copyout((u_long *) &I387, (u_long *) address, 108); + if (copyout((u_long *) &I387, (u_long *) address, 108) != 0) + math_abort(info,SIGSEGV); fninit(); return(0); case 0xa7: address = ea(info,code); - susword((u_short *) address, I387.swd); + if (copyout(&I387.swd, address, sizeof(int16_t)) != 0) + math_abort(info,SIGSEGV); return(0); case 0xe2: put_short_int(PST(0),info,code); @@ -536,11 +544,10 @@ static int __regoffset[] = { static char * sib(struct trapframe * info, int mod) { - u_char ss,index,base; - long offset = 0; + u_char ss, index, base; + long increment = 0, offset = 0; - base = fubyte((char *) info->tf_eip); - info->tf_eip++; + copyin(info->tf_eip++, &base, sizeof(u_char)) ss = base >> 6; index = (base >> 3) & 7; base &= 7; @@ -552,10 +559,11 @@ static char * sib(struct trapframe * info, int mod) if (mod || base != 5) offset += REG(base); if (mod == 1) { - offset += (signed char) fubyte((char *) info->tf_eip); - info->tf_eip++; + copyin(info->tf_eip++, &increment, sizeof(u_char)); + offset += increment; } else if (mod == 2 || base == 5) { - offset += (signed) fuword((u_long *) info->tf_eip); + copyin(info->tf_eip, &increment, sizeof(u_long)); + offset += increment; info->tf_eip += 4; } I387.foo = offset; @@ -567,6 +575,7 @@ char * ea(struct trapframe * info, u_short code) { u_char mod,rm; long * tmp; + signed char tmp; int offset = 0; mod = (code >> 6) & 3; @@ -574,7 +583,7 @@ char * ea(struct trapframe * info, u_short code) if (rm == 4 && mod != 3) return sib(info,mod); if (rm == 5 && !mod) { - offset = fuword((u_long *) info->tf_eip); + copyin(info->tf_eip, &offset, sizeof(u_long)); info->tf_eip += 4; I387.foo = offset; I387.fos = 0x17; @@ -584,11 +593,11 @@ char * ea(struct trapframe * info, u_short code) switch (mod) { case 0: offset = 0; break; case 1: - offset = (signed char) fubyte((char *) info->tf_eip); - info->tf_eip++; + copyin(info->tf_eip++, &tmp, sizeof(char)); + offset = (signed char)tmp; break; case 2: - offset = (signed) fuword((u_long *) info->tf_eip); + copyin(info->tf_eip, &offset, sizeof(u_long)); info->tf_eip += 4; break; #ifdef notyet @@ -619,7 +628,7 @@ void get_short_real(temp_real * tmp, short_real sr; addr = ea(info,code); - sr = fuword((u_long *) addr); + copyin(addr, &sr, sizeof(u_long)); short_to_temp(&sr,tmp); } @@ -630,8 +639,8 @@ void get_long_real(temp_real * tmp, long_real lr; addr = ea(info,code); - lr.a = fuword((u_long *) addr); - lr.b = fuword((u_long *) addr + 1); + copyin(addr, &lr.a, sizeof(u_long)); + copyin(addr + sizeof(u_long), &lr.b, sizeof(u_long)); long_to_temp(&lr,tmp); } @@ -641,9 +650,9 @@ void get_temp_real(temp_real * tmp, char * addr; addr = ea(info,code); - tmp->a = fuword((u_long *) addr); - tmp->b = fuword((u_long *) addr + 1); - tmp->exponent = fusword((u_short *) addr + 4); + copyin(addr, &tmp->a, sizeof(u_long)); + copyin(addr + sizeof(u_long), &tmp->b, sizeof(u_long)); + copyin(addr + sizeof(u_long) * 2, &tmp->exponent, sizeof(u_short)); } void get_short_int(temp_real * tmp, @@ -651,9 +660,11 @@ void get_short_int(temp_real * tmp, { char * addr; temp_int ti; + signed short tmp; addr = ea(info,code); - ti.a = (signed short) fusword((u_short *) addr); + copyin(addr, &tmp, sizeof(signed short)); + ti.a = (signed short)tmp; ti.b = 0; if ((ti.sign = (ti.a < 0)) != 0) ti.a = - ti.a; @@ -667,7 +678,7 @@ void get_long_int(temp_real * tmp, temp_int ti; addr = ea(info,code); - ti.a = fuword((u_long *) addr); + copyin(addr, &ti.a, sizeof(u_long)); ti.b = 0; if ((ti.sign = (ti.a < 0)) != 0) ti.a = - ti.a; @@ -681,8 +692,8 @@ void get_longlong_int(temp_real * tmp, temp_int ti; addr = ea(info,code); - ti.a = fuword((u_long *) addr); - ti.b = fuword((u_long *) addr + 1); + copyin(addr, &ti.a, sizeof(u_long)); + copyin(addr + sizeof(u_long), &ti.b, sizeof(u_long)); if ((ti.sign = (ti.b < 0)) != 0) __asm__("notl %0 ; notl %1\n\t" "addl $1,%0 ; adcl $0,%1" @@ -713,10 +724,11 @@ void get_BCD(temp_real * tmp, struct trapframe * info, u_short code) addr = ea(info,code); addr += 9; - i.sign = 0x80 & fubyte(addr--); + copyin(addr--, &i.sign, sizeof(u_char)); + i.sign &= 0x80; i.a = i.b = 0; for (k = 0; k < 9; k++) { - c = fubyte(addr--); + copyin(addr--, &c, sizeof(u_char)); MUL10(i.a, i.b); ADD64((c>>4), i.a, i.b); MUL10(i.a, i.b); @@ -733,7 +745,7 @@ void put_short_real(const temp_real * tmp, addr = ea(info,code); temp_to_short(tmp,&sr); - suword((u_long *) addr,sr); + copyout(&sr, addr, sizeof(int32_t)); } void put_long_real(const temp_real * tmp, @@ -744,8 +756,8 @@ void put_long_real(const temp_real * tmp, addr = ea(info,code); temp_to_long(tmp,&lr); - suword((u_long *) addr, lr.a); - suword((u_long *) addr + 1, lr.b); + copyout(&lr.a, (u_long *)addr, sizeof(int32_t)); + copyout(&lr.b, (u_long *)addr + 1, sizeof(int32_t)); } void put_temp_real(const temp_real * tmp, @@ -754,9 +766,9 @@ void put_temp_real(const temp_real * tmp, char * addr; addr = ea(info,code); - suword((u_long *) addr, tmp->a); - suword((u_long *) addr + 1, tmp->b); - susword((u_short *) addr + 4, tmp->exponent); + copyout(&tmp->a, (u_long *)addr, sizeof(int32_t)); + copyout(&tmp->b, (u_long *)addr + 1, sizeof(int32_t)); + copyout(&tmp->exponent, (u_short *)addr + 4, sizeof(int16_t)); } void put_short_int(const temp_real * tmp, @@ -769,7 +781,7 @@ void put_short_int(const temp_real * tmp, real_to_int(tmp,&ti); if (ti.sign) ti.a = -ti.a; - susword((u_short *) addr,ti.a); + copyout(&ti.a, addr, sizeof(int16_t)); } void put_long_int(const temp_real * tmp, @@ -782,7 +794,7 @@ void put_long_int(const temp_real * tmp, real_to_int(tmp,&ti); if (ti.sign) ti.a = -ti.a; - suword((u_long *) addr, ti.a); + copyout(&ti.a, addr, sizeof(int32_t)); } void put_longlong_int(const temp_real * tmp, @@ -798,8 +810,8 @@ void put_longlong_int(const temp_real * tmp, "addl $1,%0 ; adcl $0,%1" :"=r" (ti.a),"=r" (ti.b) :"0" (ti.a),"1" (ti.b)); - suword((u_long *) addr, ti.a); - suword((u_long *) addr + 1, ti.b); + copyout(&ti.a, (u_long *)addr, sizeof(int32_t)); + copyout(&ti.b, (u_long *)addr + 1, sizeof(int32_t)); } #define DIV10(low,high,rem) \ @@ -817,15 +829,16 @@ void put_BCD(const temp_real * tmp,struct trapframe * info, u_short code) addr = ea(info,code); real_to_int(tmp,&i); if (i.sign) - subyte(addr+9,0x80); + c = 0x80; else - subyte(addr+9,0x00); + c = 0; + copyout(&c, addr + 9, sizeof(char)); for (k = 0; k < 9; k++) { DIV10(i.a,i.b,rem); c = rem; DIV10(i.a,i.b,rem); c += rem<<4; - subyte(addr++,c); + copyout(&c, addr++, sizeof(char)); } } diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 5d755150af4..ffd96d49161 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.51 2002/12/12 07:41:45 ish Exp $ */ +/* $OpenBSD: trap.c,v 1.52 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -181,8 +181,7 @@ trap(frame) int type = frame.tf_trapno; u_quad_t sticks; struct pcb *pcb = NULL; - extern char fusubail[], - resume_iret[], resume_pop_ds[], resume_pop_es[]; + extern char resume_iret[], resume_pop_ds[], resume_pop_es[]; struct trapframe *vframe; int resume; vm_prot_t vftype, ftype; @@ -406,12 +405,6 @@ trap(frame) if (p == 0 || p->p_addr == 0) goto we_re_toast; pcb = &p->p_addr->u_pcb; - /* - * fusubail is used by [fs]uswintr() to prevent page faulting - * from inside the profiling interrupt. - */ - if (pcb->pcb_onfault == fusubail) - goto copyfault; #if 0 /* XXX - check only applies to 386's and 486's with WP off */ if (frame.tf_err & PGEX_P) @@ -640,7 +633,7 @@ syscall(frame) /* * Code is first argument, followed by actual args. */ - code = fuword(params); + copyin(params, &code, sizeof(int)); params += sizeof(int); break; case SYS___syscall: @@ -658,7 +651,7 @@ syscall(frame) #endif ) break; - code = fuword(params + _QUAD_LOWWORD * sizeof(int)); + copyin(params + _QUAD_LOWWORD * sizeof(int), &code, sizeof(int)); params += sizeof(quad_t); break; default: diff --git a/sys/arch/i386/i386/vm86.c b/sys/arch/i386/i386/vm86.c index 4bf4911debe..9b93fc802e4 100644 --- a/sys/arch/i386/i386/vm86.c +++ b/sys/arch/i386/i386/vm86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm86.c,v 1.14 2002/03/14 01:26:33 millert Exp $ */ +/* $OpenBSD: vm86.c,v 1.15 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: vm86.c,v 1.15 1996/05/03 19:42:33 christos Exp $ */ /*- @@ -150,7 +150,7 @@ is_bitset(nr, bitmap) bytes--it examines ints! */ bitmap += nr / NBBY; nr = nr % NBBY; - byte = fubyte(bitmap); + copyin(bitmap, &byte, sizeof(u_char)); __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0" :"=r" (nr) @@ -180,7 +180,7 @@ fast_intxx(p, intrno) /* * Note: u_vm86p points to user-space, we only compute offsets - * and don't deref it. is_revectored() above does fubyte() to + * and don't deref it. is_revectored() above does copyin() to * get stuff from it */ u_vm86p = (struct vm86_struct *)p->p_addr->u_pcb.vm86_userp; diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 4e6f61855b2..05256eaf371 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.43 2002/09/24 00:06:23 nordin Exp $ */ +/* $OpenBSD: cpu.h,v 1.44 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -175,8 +175,6 @@ void i386_proc0_tss_ldt_init(void); struct region_descriptor; void lgdt(struct region_descriptor *); void fillw(short, void *, size_t); -short fusword(u_short *); -int susword(u_short *t, u_short); struct pcb; void savectx(struct pcb *); diff --git a/sys/arch/m68k/fpe/fpu_calcea.c b/sys/arch/m68k/fpe/fpu_calcea.c index c3b2044e779..ff00edf4bc1 100644 --- a/sys/arch/m68k/fpe/fpu_calcea.c +++ b/sys/arch/m68k/fpe/fpu_calcea.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_calcea.c,v 1.8 2002/03/14 03:15:54 millert Exp $ */ +/* $OpenBSD: fpu_calcea.c,v 1.9 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: fpu_calcea.c,v 1.7 1996/10/16 06:27:05 scottr Exp $ */ /* @@ -196,8 +196,8 @@ decode_ea6(frame, insn, ea, modreg) int bd_size, od_size; int sig; - extword = fusword((void *) (frame->f_pc + insn->is_advance)); - if (extword < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &extword, + sizeof(int)) != 0) { return SIGSEGV; } insn->is_advance += 2; @@ -546,8 +546,8 @@ fetch_immed(frame, insn, dst) ext_bytes = insn->is_datasize; if (0 < ext_bytes) { - data = fusword((void *) (frame->f_pc + insn->is_advance)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &data, + sizeof(int)) != 0) { return SIGSEGV; } if (ext_bytes == 1) { @@ -567,8 +567,8 @@ fetch_immed(frame, insn, dst) dst[0] = data; } if (2 < ext_bytes) { - data = fusword((void *) (frame->f_pc + insn->is_advance)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &data, + sizeof(int)) != 0) { return SIGSEGV; } insn->is_advance += 2; @@ -576,26 +576,26 @@ fetch_immed(frame, insn, dst) dst[0] |= data; } if (4 < ext_bytes) { - data = fusword((void *) (frame->f_pc + insn->is_advance)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &data, + sizeof(int)) != 0) { return SIGSEGV; } dst[1] = data << 16; - data = fusword((void *) (frame->f_pc + insn->is_advance + 2)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance + 2), &data, + sizeof(int)) != 0) { return SIGSEGV; } insn->is_advance += 4; dst[1] |= data; } if (8 < ext_bytes) { - data = fusword((void *) (frame->f_pc + insn->is_advance)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &data, + sizeof(int)) != 0) { return SIGSEGV; } dst[2] = data << 16; - data = fusword((void *) (frame->f_pc + insn->is_advance + 2)); - if (data < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance + 2), &data, + sizeof(int)) != 0) { return SIGSEGV; } insn->is_advance += 4; @@ -617,8 +617,8 @@ fetch_disp(frame, insn, size, res) int disp, word; if (size == 1) { - word = fusword((void *) (frame->f_pc + insn->is_advance)); - if (word < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &word, + sizeof(int)) != 0) { return SIGSEGV; } disp = word & 0xffff; @@ -628,13 +628,13 @@ fetch_disp(frame, insn, size, res) } insn->is_advance += 2; } else if (size == 2) { - word = fusword((void *) (frame->f_pc + insn->is_advance)); - if (word < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &word, + sizeof(int)) != 0) { return SIGSEGV; } disp = word << 16; - word = fusword((void *) (frame->f_pc + insn->is_advance + 2)); - if (word < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance + 2), &word, + sizeof(int)) != 0) { return SIGSEGV; } disp |= (word & 0xffff); @@ -689,13 +689,11 @@ calc_ea(ea, ptr, eaddr) printf(" calc_ea: addr fetched from %p\n", ptr); } /* memory indirect modes */ - word = fusword(ptr); - if (word < 0) { + if (copyin(ptr, &word, sizeof(int)) != 0) { return SIGSEGV; } word <<= 16; - data = fusword(ptr + 2); - if (data < 0) { + if (copyin(ptr + 2, &data, sizeof(int)) != 0) { return SIGSEGV; } word |= data; diff --git a/sys/arch/m68k/fpe/fpu_emulate.c b/sys/arch/m68k/fpe/fpu_emulate.c index 23a03df3f2e..a3c5ffb12dc 100644 --- a/sys/arch/m68k/fpe/fpu_emulate.c +++ b/sys/arch/m68k/fpe/fpu_emulate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_emulate.c,v 1.11 2002/04/29 22:23:49 miod Exp $ */ +/* $OpenBSD: fpu_emulate.c,v 1.12 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: fpu_emulate.c,v 1.14 1996/12/18 05:44:31 scottr Exp $ */ /* @@ -139,8 +139,7 @@ fpu_emulate(frame, fpf) frame->f_pc = frame->f_fmt4.f_fslw; } - word = fusword((void *) (frame->f_pc)); - if (word < 0) { + if (copyin((void *)frame->f_pc, &word, sizeof(int)) != 0) { #ifdef DEBUG printf(" fpu_emulate: fault reading opcode\n"); #endif @@ -170,8 +169,7 @@ fpu_emulate(frame, fpf) insn.is_opcode = word; optype = (word & 0x01C0); - word = fusword((void *) (frame->f_pc + 2)); - if (word < 0) { + if (copyin((void *)(frame->f_pc + 2), &word, sizeof(int)) != 0) { #ifdef DEBUG printf(" fpu_emulate: fault reading word1\n"); #endif @@ -1079,8 +1077,8 @@ fpu_emul_type1(fe, insn) u_int16_t count = frame->f_regs[insn->is_opcode & 7]; if (count-- != 0) { - displ = fusword((void *) (frame->f_pc + insn->is_advance)); - if (displ < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), + &displ, sizeof(int)) != 0) { #ifdef DEBUG printf(" fpu_emul_type1: fault reading displacement\n"); #endif @@ -1169,8 +1167,8 @@ fpu_emul_brcc(fe, insn) displ = insn->is_word1; if (insn->is_opcode & 0x40) { - word2 = fusword((void *) (frame->f_pc + insn->is_advance)); - if (word2 < 0) { + if (copyin((void *)(frame->f_pc + insn->is_advance), &word2, + sizeof(int)) != 0) { #ifdef DEBUG printf(" fpu_emul_brcc: fault reading word2\n"); #endif diff --git a/sys/arch/m68k/include/cpu.h b/sys/arch/m68k/include/cpu.h index b7bd34cb3d5..e14c58d30fa 100644 --- a/sys/arch/m68k/include/cpu.h +++ b/sys/arch/m68k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.8 2002/03/14 01:26:34 millert Exp $ */ +/* $OpenBSD: cpu.h,v 1.9 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: cpu.h,v 1.3 1997/02/02 06:56:57 thorpej Exp $ */ /* @@ -201,10 +201,6 @@ extern u_int mappedcopysize; u_long getdfc(void); u_long getsfc(void); -/* copy.s */ -int fusword(caddr_t); -int susword(caddr_t, u_short); - /* m68k_machdep.c */ struct proc; struct frame; diff --git a/sys/arch/m68k/m68k/copy.s b/sys/arch/m68k/m68k/copy.s index 83fb7d9e744..a1a70aba52c 100644 --- a/sys/arch/m68k/m68k/copy.s +++ b/sys/arch/m68k/m68k/copy.s @@ -1,4 +1,4 @@ -/* $OpenBSD: copy.s,v 1.13 2002/01/21 20:35:49 miod Exp $ */ +/* $OpenBSD: copy.s,v 1.14 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: copy.s,v 1.30 1998/03/04 06:39:14 thorpej Exp $ */ /*- @@ -42,7 +42,7 @@ /* * This file contains the functions for user-space access: - * copyin/copyout, fuword/suword, etc. + * copyin/copyout, etc. */ #include <sys/errno.h> @@ -350,142 +350,3 @@ Lkcfault: addl #16,sp | pop args and return address moveq #EFAULT,d0 | indicate a fault bra Lkcdone - -/* - * fuword(caddr_t uaddr); - * Fetch an int from the user's address space. - */ -ENTRY(fuword) - CHECK_SFC - movl sp@(4),a0 | address to read - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lferr,a1@(PCB_ONFAULT) - movsl a0@,d0 | do read from user space - bra Lfdone - -/* - * fusword(caddr_t uaddr); - * Fetch a short from the user's address space. - */ -ENTRY(fusword) - CHECK_SFC - movl sp@(4),a0 | address to read - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lferr,a1@(PCB_ONFAULT) - moveq #0,d0 - movsw a0@,d0 | do read from user space - bra Lfdone - -/* - * fuswintr(caddr_t uaddr); - * Fetch a short from the user's address space. - * Can be called during an interrupt. - */ -ENTRY(fuswintr) - CHECK_SFC - movl sp@(4),a0 | address to read - movl _C_LABEL(curpcb),a1 | set fault handler - movl #_fubail,a1@(PCB_ONFAULT) - moveq #0,d0 - movsw a0@,d0 | do read from user space - bra Lfdone - -/* - * fubyte(caddr_t uaddr); - * Fetch a byte from the user's address space. - */ -ENTRY(fubyte) - CHECK_SFC - movl sp@(4),a0 | address to read - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lferr,a1@(PCB_ONFAULT) - moveq #0,d0 - movsb a0@,d0 | do read from user space - bra Lfdone - -/* - * Error routine for fuswintr. The fault handler in trap.c - * checks for pcb_onfault set to this fault handler and - * "bails out" before calling the VM fault handler. - * (We can not call VM code from interrupt level.) - * Same code as Lferr but must have a different address. - */ -ENTRY(fubail) - nop -Lferr: - moveq #-1,d0 | error indicator -Lfdone: - clrl a1@(PCB_ONFAULT) | clear fault handler - rts - -/* - * suword(caddr_t uaddr, int x); - * Store an int in the user's address space. - */ -ENTRY(suword) - CHECK_DFC - movl sp@(4),a0 | address to write - movl sp@(8),d0 | value to put there - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lserr,a1@(PCB_ONFAULT) - movsl d0,a0@ | do write to user space - moveq #0,d0 | indicate no fault - bra Lsdone - -/* - * susword(caddr_t uaddr, short x); - * Store a short in the user's address space. - */ -ENTRY(susword) - CHECK_DFC - movl sp@(4),a0 | address to write - movw sp@(10),d0 | value to put there - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lserr,a1@(PCB_ONFAULT) - movsw d0,a0@ | do write to user space - moveq #0,d0 | indicate no fault - bra Lsdone - -/* - * suswintr(caddr_t uaddr, short x); - * Store a short in the user's address space. - * Can be called during an interrupt. - */ -ENTRY(suswintr) - CHECK_DFC - movl sp@(4),a0 | address to write - movw sp@(10),d0 | value to put there - movl _C_LABEL(curpcb),a1 | set fault handler - movl #_subail,a1@(PCB_ONFAULT) - movsw d0,a0@ | do write to user space - moveq #0,d0 | indicate no fault - bra Lsdone - -/* - * subyte(caddr_t uaddr, char x); - * Store a byte in the user's address space. - */ -ENTRY(subyte) - CHECK_DFC - movl sp@(4),a0 | address to write - movb sp@(11),d0 | value to put there - movl _C_LABEL(curpcb),a1 | set fault handler - movl #Lserr,a1@(PCB_ONFAULT) - movsb d0,a0@ | do write to user space - moveq #0,d0 | indicate no fault - bra Lsdone - -/* - * Error routine for suswintr. The fault handler in trap.c - * checks for pcb_onfault set to this fault handler and - * "bails out" before calling the VM fault handler. - * (We can not call VM code from interrupt level.) - * Same code as Lserr but must have a different address. - */ -ENTRY(subail) - nop -Lserr: - moveq #-1,d0 | error indicator -Lsdone: - clrl a1@(PCB_ONFAULT) | clear fault handler - rts diff --git a/sys/arch/m68k/m68k/mappedcopy.c b/sys/arch/m68k/m68k/mappedcopy.c index 6ff97081ae7..b10e347d167 100644 --- a/sys/arch/m68k/m68k/mappedcopy.c +++ b/sys/arch/m68k/m68k/mappedcopy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mappedcopy.c,v 1.9 2001/12/08 02:24:06 art Exp $ */ +/* $OpenBSD: mappedcopy.c,v 1.10 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: mappedcopy.c,v 1.1 1997/02/02 06:54:10 thorpej Exp $ */ /* @@ -82,7 +82,7 @@ mappedcopyin(fromp, top, count) register vaddr_t kva; register paddr_t upa; register size_t len; - int off, alignable; + int off, alignable, tmp; pmap_t upmap; extern caddr_t CADDR1; @@ -99,10 +99,10 @@ mappedcopyin(fromp, top, count) upmap = vm_map_pmap(&curproc->p_vmspace->vm_map); while (count > 0) { /* - * First access of a page, use fubyte to make sure + * First access of a page, use copyin to make sure * page is faulted in and read access allowed. */ - if (fubyte(fromp) == -1) + if (copyin(fromp, &tmp, sizeof(u_char)) != 0) return (EFAULT); /* * Map in the page and bcopy data in from it @@ -152,10 +152,10 @@ mappedcopyout(fromp, top, count) upmap = vm_map_pmap(&curproc->p_vmspace->vm_map); while (count > 0) { /* - * First access of a page, use subyte to make sure + * First access of a page, use copyout to make sure * page is faulted in and write access allowed. */ - if (subyte(top, *((char *)fromp)) == -1) + if (copyout(fromp, top, sizeof(char)) != 0) return (EFAULT); /* * Map in the page and bcopy data out to it diff --git a/sys/arch/m68k/m68k/regdump.c b/sys/arch/m68k/m68k/regdump.c index a27da661de2..ebb4187e9c1 100644 --- a/sys/arch/m68k/m68k/regdump.c +++ b/sys/arch/m68k/m68k/regdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regdump.c,v 1.3 2002/03/14 01:26:35 millert Exp $ */ +/* $OpenBSD: regdump.c,v 1.4 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: regdump.c,v 1.1 1997/04/09 19:21:47 thorpej Exp $ */ /* @@ -104,11 +104,11 @@ regdump(tf, sbytes) void dumpmem(ptr, sz, ustack) - register int *ptr; + int *ptr; int sz, ustack; { - register int i, val; - register int limit; + int i, val; + int limit; /* Stay in the same page */ limit = ((int)ptr) | (NBPG-3); @@ -119,7 +119,7 @@ dumpmem(ptr, sz, ustack) else printf(" "); if (ustack == 1) { - if ((val = fuword(ptr++)) == -1) + if (copyin(ptr++, &val, sizeof(int)) != 0) break; } else { if (((int) ptr) >= limit) diff --git a/sys/arch/m68k/m68k/sig_machdep.c b/sys/arch/m68k/m68k/sig_machdep.c index 9570ba4a9b1..2165e017f34 100644 --- a/sys/arch/m68k/m68k/sig_machdep.c +++ b/sys/arch/m68k/m68k/sig_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sig_machdep.c,v 1.10 2002/07/20 19:24:56 art Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.11 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: sig_machdep.c,v 1.3 1997/04/30 23:28:03 gwr Exp $ */ /* @@ -139,11 +139,11 @@ sendsig(catcher, sig, mask, code, type, val) int type; union sigval val; { - register struct proc *p = curproc; - register struct sigframe *fp, *kfp; - register struct frame *frame; - register struct sigacts *psp = p->p_sigacts; - register short ft; + struct proc *p = curproc; + struct sigframe *fp, *kfp; + struct frame *frame; + struct sigacts *psp = p->p_sigacts; + short ft; int oonstack, fsize; frame = (struct frame *)p->p_md.md_regs; @@ -352,17 +352,13 @@ sys_sigreturn(p, v, retval) * See if there is anything to do before we go to the * expense of copying in close to 1/2K of data */ - flags = fuword((caddr_t)rf); + if (copyin((caddr_t)rf, &flags, sizeof(int)) != 0) + return (EINVAL); #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sigreturn(%d): sc_ap %x flags %x\n", p->p_pid, rf, flags); #endif - /* - * fuword failed (bogus sc_ap value). - */ - if (flags == -1) - return (EINVAL); if (flags == 0 || copyin((caddr_t)rf, (caddr_t)&tstate, sizeof tstate)) return (EJUSTRETURN); #ifdef DEBUG diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index d6551bc7d0e..915b61fb4bd 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.39 2002/10/12 01:09:43 krw Exp $ */ +/* $OpenBSD: trap.c,v 1.40 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -239,7 +239,6 @@ trap(type, code, v, frame) u_int v; struct frame frame; { - extern char fubail[], subail[]; struct proc *p; int i, s; u_int ucode; @@ -546,15 +545,6 @@ copyfault: goto out; case T_MMUFLT: /* Kernel mode page fault */ - /* - * If we were doing profiling ticks or other user mode - * stuff from interrupt code, Just Say No. - */ - if (p->p_addr->u_pcb.pcb_onfault == fubail || - p->p_addr->u_pcb.pcb_onfault == subail) - goto copyfault; - /* fall into... */ - case T_MMUFLT|T_USER: /* page fault */ { vaddr_t va; @@ -783,7 +773,8 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb1s)) *(long *)f->f_wb1a = wb1d; else - err = suword((caddr_t)f->f_wb1a, wb1d); + err = copyout(&wb1d, (caddr_t)f->f_wb1a, + sizeof(int)); break; case SSW4_SZB: off = 24 - off; @@ -791,8 +782,12 @@ writeback(fp, docachepush) wb1d >>= off; if (KDFAULT(f->f_wb1s)) *(char *)f->f_wb1a = wb1d; - else - err = subyte((caddr_t)f->f_wb1a, wb1d); + else { + char tmp = wb1d; + + err = copyout(&tmp, (caddr_t)f->f_wb1a, + sizeof(char)); + } break; case SSW4_SZW: off = (off + 16) % 32; @@ -800,8 +795,12 @@ writeback(fp, docachepush) wb1d = (wb1d >> (32 - off)) | (wb1d << off); if (KDFAULT(f->f_wb1s)) *(short *)f->f_wb1a = wb1d; - else - err = susword((caddr_t)f->f_wb1a, wb1d); + else { + short tmp = wb1d; + + err = copyout(&tmp, (caddr_t)f->f_wb1a, + sizeof(short)); + } break; } if (err) { @@ -833,19 +832,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb2s)) *(long *)f->f_wb2a = f->f_wb2d; else - err = suword((caddr_t)f->f_wb2a, f->f_wb2d); + err = copyout(&f->f_wb2d, (caddr_t)f->f_wb2a, + sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb2s)) *(char *)f->f_wb2a = f->f_wb2d; - else - err = subyte((caddr_t)f->f_wb2a, f->f_wb2d); + else { + char tmp = f->f_wb2d; + + err = copyout(&tmp, (caddr_t)f->f_wb2a, + sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb2s)) *(short *)f->f_wb2a = f->f_wb2d; - else - err = susword((caddr_t)f->f_wb2a, f->f_wb2d); + else { + short tmp = f->f_wb2d; + + err = copyout(&tmp, (caddr_t)f->f_wb2a, + sizeof(short)); + } break; } if (err) { @@ -873,19 +881,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb3s)) *(long *)f->f_wb3a = f->f_wb3d; else - err = suword((caddr_t)f->f_wb3a, f->f_wb3d); + err = copyout(&f->f_wb3d, (caddr_t)f->f_wb3a, + sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb3s)) *(char *)f->f_wb3a = f->f_wb3d; - else - err = subyte((caddr_t)f->f_wb3a, f->f_wb3d); + else { + char tmp = f->f_wb3d; + + err = copyout(&tmp, (caddr_t)f->f_wb3a, + sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb3s)) *(short *)f->f_wb3a = f->f_wb3d; - else - err = susword((caddr_t)f->f_wb3a, f->f_wb3d); + else { + short tmp = f->f_wb3d; + + err = copyout(&tmp, (caddr_t)f->f_wb3a, + sizeof(short)); + } break; #ifdef DEBUG case SSW4_SZLN: @@ -947,6 +964,7 @@ dumpwb(num, s, a, d) { struct proc *p = curproc; paddr_t pa; + int tmp; printf(" writeback #%d: VA %x, data %x, SZ=%s, TT=%s, TM=%s\n", num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], @@ -954,8 +972,12 @@ dumpwb(num, s, a, d) printf(" PA "); if (pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a, &pa) == FALSE) printf("<invalid address>"); - else - printf("%lx, current value %lx", pa, fuword((caddr_t)a)); + else { + if (copyin((caddr_t)a, &tmp, sizeof(int)) == 0) + printf("%lx, current value %lx", pa, tmp); + else + printf("%lx, current value inaccessible", pa); + } printf("\n"); } #endif @@ -997,7 +1019,9 @@ syscall(code, frame) * code assumes the kernel pops the syscall argument the * glue pushed on the stack. Sigh... */ - code = fuword((caddr_t)frame.f_regs[SP]); + if (copyin((caddr_t)frame.f_regs[SP], &code, + sizeof(register_t)) != 0) + code = -1; /* * XXX @@ -1025,7 +1049,8 @@ syscall(code, frame) /* * Code is first argument, followed by actual args. */ - code = fuword(params); + if (copyin(params, &code, sizeof(register_t)) != 0) + code = -1; params += sizeof(int); /* * XXX sigreturn requires special stack manipulation @@ -1042,7 +1067,9 @@ syscall(code, frame) */ if (callp != sysent) break; - code = fuword(params + _QUAD_LOWWORD * sizeof(int)); + if (copyin(params + _QUAD_LOWWORD * sizeof(int), &code, + sizeof(register_t)) != 0) + code = -1; params += sizeof(quad_t); break; default: diff --git a/sys/arch/mvme68k/mvme68k/hpux_machdep.c b/sys/arch/mvme68k/mvme68k/hpux_machdep.c index 571cdfa014b..f25545d8af7 100644 --- a/sys/arch/mvme68k/mvme68k/hpux_machdep.c +++ b/sys/arch/mvme68k/mvme68k/hpux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_machdep.c,v 1.8 2002/07/20 19:24:56 art Exp $ */ +/* $OpenBSD: hpux_machdep.c,v 1.9 2003/01/09 22:27:09 miod Exp $ */ /* $NetBSD: hpux_machdep.c,v 1.9 1997/03/16 10:00:45 thorpej Exp $ */ /* @@ -651,17 +651,13 @@ hpux_sys_sigreturn(p, v, retval) * See if there is anything to do before we go to the * expense of copying in close to 1/2K of data */ - flags = fuword((caddr_t)rf); + if (copyin((caddr_t)rf, &flags, sizeof(int)) != 0) + return (EINVAL); #ifdef DEBUG if (hpuxsigdebug & SDB_FOLLOW) printf("sigreturn(%d): sc_ap %x flags %x\n", p->p_pid, rf, flags); #endif - /* - * fuword failed (bogus _hsc_ap value). - */ - if (flags == -1) - return (EINVAL); if (flags == 0 || copyin((caddr_t)rf, (caddr_t)&tstate, sizeof tstate)) return (EJUSTRETURN); #ifdef DEBUG diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index 3525bdae77c..ea4d2889da2 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.47 2002/12/09 00:45:37 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.48 2003/01/09 22:27:09 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -264,7 +264,6 @@ trap(type, code, v, frame) register u_int v; struct frame frame; { - extern char fubail[], subail[]; register struct proc *p; register int i; u_int ucode; @@ -536,15 +535,6 @@ copyfault: goto out; case T_MMUFLT: /* kernel mode page fault */ - /* - * If we were doing profiling ticks or other user mode - * stuff from interrupt code, Just Say No. - */ - if (p && (p->p_addr->u_pcb.pcb_onfault == fubail || - p->p_addr->u_pcb.pcb_onfault == subail)) - goto copyfault; - /* FALLTHROUGH */ - case T_MMUFLT|T_USER: /* page fault */ { vm_offset_t va; @@ -786,7 +776,8 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb1s)) *(long *)f->f_wb1a = wb1d; else - err = suword((caddr_t)f->f_wb1a, wb1d); + err = copyout(&wb1d, + (caddr_t)f->f_wb1a, sizeof(int)); break; case SSW4_SZB: off = 24 - off; @@ -794,8 +785,12 @@ writeback(fp, docachepush) wb1d >>= off; if (KDFAULT(f->f_wb1s)) *(char *)f->f_wb1a = wb1d; - else - err = subyte((caddr_t)f->f_wb1a, wb1d); + else { + char tmp = wb1d; + + err = copyout(&tmp, + (caddr_t)f->f_wb1a, sizeof(char)); + } break; case SSW4_SZW: off = (off + 16) % 32; @@ -803,8 +798,12 @@ writeback(fp, docachepush) wb1d = (wb1d >> (32 - off)) | (wb1d << off); if (KDFAULT(f->f_wb1s)) *(short *)f->f_wb1a = wb1d; - else - err = susword((caddr_t)f->f_wb1a, wb1d); + else { + short tmp = wb1d; + + err = copyout(&tmp, + (caddr_t)f->f_wb1a, sizeof(long)); + } break; } if (err) { @@ -836,19 +835,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb2s)) *(long *)f->f_wb2a = f->f_wb2d; else - err = suword((caddr_t)f->f_wb2a, f->f_wb2d); + err = copyout(&f->f_wb2d, + (caddr_t)f->f_wb2a, sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb2s)) *(char *)f->f_wb2a = f->f_wb2d; - else - err = subyte((caddr_t)f->f_wb2a, f->f_wb2d); + else { + char tmp = f->f_wb2d; + + err = copyout(&tmp, + (caddr_t)f->f_wb2a, sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb2s)) *(short *)f->f_wb2a = f->f_wb2d; - else - err = susword((caddr_t)f->f_wb2a, f->f_wb2d); + else { + short tmp = f->f_wb2d; + + err = copyout(&tmp, + (caddr_t)f->f_wb2a, sizeof(short)); + } break; } if (err) { @@ -876,19 +884,28 @@ writeback(fp, docachepush) if (KDFAULT(f->f_wb3s)) *(long *)f->f_wb3a = f->f_wb3d; else - err = suword((caddr_t)f->f_wb3a, f->f_wb3d); + err = copyout(&f->f_wb3d, + (caddr_t)f->f_wb3a, sizeof(int)); break; case SSW4_SZB: if (KDFAULT(f->f_wb3s)) *(char *)f->f_wb3a = f->f_wb3d; - else - err = subyte((caddr_t)f->f_wb3a, f->f_wb3d); + else { + char tmp = f->f_wb3d; + + err = copyout(&tmp, + (caddr_t)f->f_wb3a, sizeof(char)); + } break; case SSW4_SZW: if (KDFAULT(f->f_wb3s)) *(short *)f->f_wb3a = f->f_wb3d; - else - err = susword((caddr_t)f->f_wb3a, f->f_wb3d); + else { + short tmp = f->f_wb3d; + + err = copyout(&tmp, + (caddr_t)f->f_wb3a, sizeof(short)); + } break; #ifdef DEBUG case SSW4_SZLN: @@ -950,6 +967,7 @@ dumpwb(num, s, a, d) { register struct proc *p = curproc; vm_offset_t pa; + int tmp; printf(" writeback #%d: VA %x, data %x, SZ=%s, TT=%s, TM=%s\n", num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], @@ -957,8 +975,12 @@ dumpwb(num, s, a, d) printf(" PA "); if (pmap_extract(p->p_vmspace->vm_map.pmap, (vm_offset_t)a, &pa) == FALSE) printf("<invalid address>"); - else - printf("%x, current value %x", pa, fuword((caddr_t)a)); + else { + if (copyin((caddr_t)a, &tmp, sizeof(int)) == 0) + printf("%lx, current value %lx", pa, tmp); + else + printf("%lx, current value inaccessible", pa); + } printf("\n"); } #endif @@ -1003,7 +1025,9 @@ syscall(code, frame) * code assumes the kernel pops the syscall argument the * glue pushed on the stack. Sigh... */ - code = fuword((caddr_t)frame.f_regs[SP]); + if (copyin((caddr_t)frame.f_regs[SP], &code, + sizeof(register_t)) != 0) + code = -1; /* * XXX @@ -1031,7 +1055,8 @@ syscall(code, frame) /* * Code is first argument, followed by actual args. */ - code = fuword(params); + if (copyin(params, &code, sizeof(register_t)) != 0) + code = -1; params += sizeof(int); /* * XXX sigreturn requires special stack manipulation @@ -1048,7 +1073,9 @@ syscall(code, frame) */ if (callp != sysent) break; - code = fuword(params + _QUAD_LOWWORD * sizeof(int)); + if (copyin(params + _QUAD_LOWWORD * sizeof(int), &code, + sizeof(register_t)) != 0) + code = -1; params += sizeof(quad_t); break; default: diff --git a/sys/arch/mvme88k/mvme88k/locore_asm_routines.S b/sys/arch/mvme88k/mvme88k/locore_asm_routines.S index 73b31afa46b..7838389e6cb 100644 --- a/sys/arch/mvme88k/mvme88k/locore_asm_routines.S +++ b/sys/arch/mvme88k/mvme88k/locore_asm_routines.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore_asm_routines.S,v 1.20 2002/01/21 20:35:51 miod Exp $ */ +/* $OpenBSD: locore_asm_routines.S,v 1.21 2003/01/09 22:27:09 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -182,181 +182,6 @@ GLOBAL(FAULT_ERROR) jmp r1 /* - * Fetch from user space - * r2 == address in user space - */ - -ENTRY(fuword) -ENTRY(fuiword) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - ld.usr r5, r0, r2 - NOP - NOP - NOP -#else - ld.usr r5, r0, r2 -#endif - or r2, r0, r5 - br fusu_ret -fusu_fault: - subu r2, r0, 1 -fusu_ret: - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - st r0, r6, PCB_ONFAULT /* pcb_onfault = 0 */ - - jmp r1 - -ENTRY(fusword) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - ld.h.usr r5, r0, r2 - NOP - NOP - NOP -#else - ld.h.usr r5, r0, r2 -#endif - or r2, r0, r5 - br fusu_ret - -ENTRY(fubyte) -ENTRY(fuibyte) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - ld.b.usr r5, r0, r2 - NOP - NOP - NOP -#else - ld.b.usr r5, r0, r2 -#endif - or r2, r0, r5 - br fusu_ret - -ENTRY(fuswintr) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(_fubail) - or r5, r5, lo16(_fubail) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fubail */ -#ifdef ERRATA__XXX_USR - NOP - ld.h.usr r5, r2, r0 - NOP - NOP - NOP -#else - ld.h.usr r5, r2, r0 -#endif - or r2, r0, r5 - br fusu_ret - -ENTRY(fubail) - subu r2, r0, 1 - br fusu_ret - -/* - * store to user space. - * r2 == address in user space - * r3 == byte/short/word - */ - -ENTRY(suword) -ENTRY(suiword) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - st.usr r3, r2, r0 - NOP - NOP - NOP -#else - st.usr r3, r2, r0 -#endif - or r2, r0, r0 /* return success */ - br fusu_ret - -ENTRY(susword) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - st.h.usr r3, r2, r0 - NOP - NOP - NOP -#else - st.h.usr r3, r2, r0 -#endif - or r2, r0, r0 /* return success */ - br fusu_ret - -ENTRY(subyte) -ENTRY(suibyte) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(fusu_fault) - or r5, r5, lo16(fusu_fault) - st r5, r6, PCB_ONFAULT /* pcb_onfault = fusu_fault */ -#ifdef ERRATA__XXX_USR - NOP - st.b.usr r3, r2, r0 - NOP - NOP - NOP -#else - st.b.usr r3, r2, r0 -#endif - or r2, r0, r0 /* return success */ - br fusu_ret - -ENTRY(suswintr) - or.u r5, r0, hi16(_curpcb) - ld r6, r5, lo16(_curpcb) - or.u r5, r0, hi16(_subail) - or r5, r5, lo16(_subail) - st r5, r6, PCB_ONFAULT /* pcb_onfault = subail */ -#ifdef ERRATA__XXX_USR - NOP - st.h.usr r3, r2, r0 - NOP - NOP - NOP -#else - st.h.usr r3, r2, r0 -#endif - or r2, r0, r0 /* return success */ - br fusu_ret - -ENTRY(subail) - subu r2, r0, 1 - br fusu_ret - -/* * Copy specified amount of data from user space into the kernel * copyin(from, to, len) * r2 == from (user source address) diff --git a/sys/arch/mvme88k/mvme88k/trap.c b/sys/arch/mvme88k/mvme88k/trap.c index 5a20d6eab0b..350a6d2ff6d 100644 --- a/sys/arch/mvme88k/mvme88k/trap.c +++ b/sys/arch/mvme88k/mvme88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.37 2003/01/03 23:17:43 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.38 2003/01/09 22:27:10 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -337,19 +337,6 @@ m88100_trap(unsigned type, struct m88100_saved_state *frame) if (frame->dmt0 & DMT_DAS) map = kernel_map; - /* - * We don't want to call vm_fault() if it is fuwintr() or - * suwintr(). These routines are for copying from interrupt - * context and vm_fault() can potentially sleep. You may - * wonder if it isn't bad karma for an interrupt handler to - * touch the current process. Indeed it is, but clock interrupt - * does it while doing profiling. It is OK in that context. - */ - - if (p->p_addr->u_pcb.pcb_onfault == (int)fubail || - p->p_addr->u_pcb.pcb_onfault == (int)subail) - goto outtahere; - /* data fault on the user address */ if (type == T_DATAFLT && (frame->dmt0 & DMT_DAS) == 0) { type = T_DATAFLT + T_USER; @@ -452,7 +439,6 @@ m88100_trap(unsigned type, struct m88100_saved_state *frame) if (!p->p_addr->u_pcb.pcb_onfault) panictrap(frame->vector, frame); -outtahere: frame->snip = ((unsigned)p->p_addr->u_pcb.pcb_onfault ) | FIP_V; frame->sfip = ((unsigned)p->p_addr->u_pcb.pcb_onfault + 4) | FIP_V; frame->sxip = 0; @@ -591,7 +577,7 @@ outtahere: va = pc; /* read break instruction */ - instr = fuiword((caddr_t)pc); + copyin((caddr_t)pc, &instr, sizeof(unsigned)); #if 0 printf("trap: %s (%d) breakpoint %x at %x: (adr %x ins %x)\n", p->p_comm, p->p_pid, instr, pc, @@ -867,19 +853,6 @@ m88110_trap(unsigned type, struct m88100_saved_state *frame) } } - /* - * We don't want to call vm_fault() if it is fuwintr() or - * suwintr(). These routines are for copying from interrupt - * context and vm_fault() can potentially sleep. You may - * wonder if it isn't bad karma for an interrupt handler to - * touch the current process. Indeed it is, but clock interrupt - * does it while doing profiling. It is OK in that context. - */ - - if (p->p_addr->u_pcb.pcb_onfault == (int)fubail || - p->p_addr->u_pcb.pcb_onfault == (int)subail) - goto m88110_outtahere; - /* data fault on the user address */ if (type == T_DATAFLT && (frame->dsr & CMMU_DSR_SU) == 0) { type = T_DATAFLT + T_USER; @@ -941,7 +914,6 @@ m88110_trap(unsigned type, struct m88100_saved_state *frame) if (!p->p_addr->u_pcb.pcb_onfault) panictrap(frame->vector, frame); -m88110_outtahere: frame->exip = ((unsigned)p->p_addr->u_pcb.pcb_onfault); return; case T_INSTFLT+T_USER: @@ -1095,7 +1067,7 @@ m88110_user_fault: va = pc; /* read break instruction */ - instr = fuiword((caddr_t)pc); + copyin((caddr_t)pc, &instr, sizeof(unsigned)); #if 1 printf("trap: %s (%d) breakpoint %x at %x: (adr %x ins %x)\n", p->p_comm, p->p_pid, instr, pc, diff --git a/sys/arch/powerpc/conf/files.powerpc b/sys/arch/powerpc/conf/files.powerpc index d1c0af0f1c4..2a7da45a390 100644 --- a/sys/arch/powerpc/conf/files.powerpc +++ b/sys/arch/powerpc/conf/files.powerpc @@ -1,4 +1,4 @@ -# $OpenBSD: files.powerpc,v 1.36 2002/06/08 16:02:14 miod Exp $ +# $OpenBSD: files.powerpc,v 1.37 2003/01/09 22:27:10 miod Exp $ # file arch/powerpc/powerpc/setjmp.S ddb @@ -6,14 +6,9 @@ file arch/powerpc/powerpc/Locore.c file arch/powerpc/powerpc/bcopy.c file arch/powerpc/powerpc/copystr.c file arch/powerpc/powerpc/fpu.c -file arch/powerpc/powerpc/fubyte.c -file arch/powerpc/powerpc/fuswintr.c file arch/powerpc/powerpc/in_cksum.c file arch/powerpc/powerpc/pmap.c file arch/powerpc/powerpc/process_machdep.c -file arch/powerpc/powerpc/subyte.c -file arch/powerpc/powerpc/suword.c -file arch/powerpc/powerpc/suswintr.c file arch/powerpc/powerpc/sys_machdep.c file arch/powerpc/powerpc/trap.c file arch/powerpc/powerpc/vm_machdep.c diff --git a/sys/arch/powerpc/powerpc/fubyte.c b/sys/arch/powerpc/powerpc/fubyte.c deleted file mode 100644 index c60475ae36f..00000000000 --- a/sys/arch/powerpc/powerpc/fubyte.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: fubyte.c,v 1.5 2002/09/15 09:01:59 deraadt Exp $ */ -/* $NetBSD: fubyte.c,v 1.1 1996/09/30 16:34:45 ws Exp $ */ - -/*- - * Copyright (C) 1993 Wolfgang Solfrank. - * Copyright (C) 1993 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/systm.h> - -/* - * Emulate fubyte. - */ -int -fubyte(addr) - void *addr; -{ - unsigned char c; - - if (copyin(addr,&c,sizeof(c))) - return -1; - return c; -} diff --git a/sys/arch/powerpc/powerpc/fuswintr.c b/sys/arch/powerpc/powerpc/fuswintr.c deleted file mode 100644 index 6fc884792b4..00000000000 --- a/sys/arch/powerpc/powerpc/fuswintr.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: fuswintr.c,v 1.3 2001/06/24 23:29:34 drahn Exp $ */ -/* $NetBSD: fuswintr.c,v 1.1 1996/09/30 16:34:45 ws Exp $ */ - -/*- - * Copyright (C) 1994 Wolfgang Solfrank. - * Copyright (C) 1994 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/systm.h> - -/* - * Emulate fuswintr - * - * Simply return fault for all cases - */ -int -fuswintr(addr) - char *addr; -{ - return -1; -} diff --git a/sys/arch/powerpc/powerpc/subyte.c b/sys/arch/powerpc/powerpc/subyte.c deleted file mode 100644 index 43b0cef8373..00000000000 --- a/sys/arch/powerpc/powerpc/subyte.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: subyte.c,v 1.4 2001/07/09 01:14:01 mickey Exp $ */ -/* $NetBSD: subyte.c,v 1.1 1996/09/30 16:34:54 ws Exp $ */ - -/*- - * Copyright (C) 1993 Wolfgang Solfrank. - * Copyright (C) 1993 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/systm.h> - -/* - * Emulate subyte. - */ -int -subyte(addr,c) - void *addr; - unsigned char c; -{ - if (copyout(&c,addr,sizeof(c))) - return -1; - return 0; -} diff --git a/sys/arch/powerpc/powerpc/suswintr.c b/sys/arch/powerpc/powerpc/suswintr.c deleted file mode 100644 index bf1e2be08a7..00000000000 --- a/sys/arch/powerpc/powerpc/suswintr.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: suswintr.c,v 1.3 2001/07/09 01:21:30 mickey Exp $ */ -/* $NetBSD: suswintr.c,v 1.1 1996/09/30 16:34:54 ws Exp $ */ - -/*- - * Copyright (C) 1994 Wolfgang Solfrank. - * Copyright (C) 1994 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/systm.h> - -/* - * Emulate suswintr - * - * Simply return fault for all cases - */ -int -suswintr(addr,s) - caddr_t addr; - u_int s; -{ - return -1; -} diff --git a/sys/arch/powerpc/powerpc/suword.c b/sys/arch/powerpc/powerpc/suword.c deleted file mode 100644 index c3e6262ee32..00000000000 --- a/sys/arch/powerpc/powerpc/suword.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: suword.c,v 1.4 2001/07/09 01:14:59 mickey Exp $ */ -/* $NetBSD: suword.c,v 1.1 1996/09/30 16:34:55 ws Exp $ */ - -/*- - * Copyright (C) 1993 Wolfgang Solfrank. - * Copyright (C) 1993 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/systm.h> - -/* - * Emulate suword - */ -int -suword(addr,l) - void *addr; - long l; -{ - if (copyout(&l,addr,sizeof(l))) - return -1; - return 0; -} diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index 82b55c609d3..8c7a2f40825 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.55 2002/08/20 12:57:54 art Exp $ */ +/* $OpenBSD: locore.s,v 1.56 2003/01/09 22:27:10 miod Exp $ */ /* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */ /* @@ -4833,148 +4833,6 @@ ENTRY(proc_trampoline) b return_from_syscall add %l1, 4, %l2 ! npc = pc+4 -/* - * {fu,su}{,i}{byte,word} - */ -ALTENTRY(fuiword) -ENTRY(fuword) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE... - bgeu Lfsbadaddr - EMPTY - btst 3, %o0 ! or has low bits set... - bnz Lfsbadaddr ! go return -1 - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - ld [%o0], %o0 ! fetch the word - retl ! phew, made it, return the word - st %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - -Lfserr: - st %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault -Lfsbadaddr: - retl ! and return error indicator - mov -1, %o0 - - /* - * This is just like Lfserr, but it's a global label that allows - * mem_access_fault() to check to see that we don't want to try to - * page in the fault. It's used by fuswintr() etc. - */ - .globl _C_LABEL(Lfsbail) -_C_LABEL(Lfsbail): - st %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault - retl ! and return error indicator - mov -1, %o0 - - /* - * Like fusword but callable from interrupt context. - * Fails if data isn't resident. - */ -ENTRY(fuswintr) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = _Lfsbail; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set _C_LABEL(Lfsbail), %o3 - st %o3, [%o2 + PCB_ONFAULT] - lduh [%o0], %o0 ! fetch the halfword - retl ! made it - st %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - -ENTRY(fusword) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - lduh [%o0], %o0 ! fetch the halfword - retl ! made it - st %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - -ALTENTRY(fuibyte) -ENTRY(fubyte) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - ldub [%o0], %o0 ! fetch the byte - retl ! made it - st %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - -ALTENTRY(suiword) -ENTRY(suword) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE ... - bgeu Lfsbadaddr - EMPTY - btst 3, %o0 ! or has low bits set ... - bnz Lfsbadaddr ! go return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - st %o1, [%o0] ! store the word - st %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - retl ! and return 0 - clr %o0 - -ENTRY(suswintr) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! go return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = _Lfsbail; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set _C_LABEL(Lfsbail), %o3 - st %o3, [%o2 + PCB_ONFAULT] - sth %o1, [%o0] ! store the halfword - st %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - retl ! and return 0 - clr %o0 - -ENTRY(susword) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! go return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - sth %o1, [%o0] ! store the halfword - st %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - retl ! and return 0 - clr %o0 - -ALTENTRY(suibyte) -ENTRY(subyte) - set KERNBASE, %o2 - cmp %o0, %o2 ! if addr >= KERNBASE - bgeu Lfsbadaddr ! go return error - EMPTY - sethi %hi(_C_LABEL(cpcb)), %o2 ! cpcb->pcb_onfault = Lfserr; - ld [%o2 + %lo(_C_LABEL(cpcb))], %o2 - set Lfserr, %o3 - st %o3, [%o2 + PCB_ONFAULT] - stb %o1, [%o0] ! store the byte - st %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - retl ! and return 0 - clr %o0 - /* probeget and probeset are meant to be used during autoconfiguration */ /* @@ -5004,6 +4862,22 @@ ENTRY(probeget) 0: retl ! made it, clear onfault and return st %g0, [%o2 + PCB_ONFAULT] +Lfserr: + st %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault + retl ! and return error indicator + mov -1, %o0 + + /* + * This is just like Lfserr, but it's a global label that allows + * mem_access_fault() to check to see that we don't want to try to + * page in the fault. It's used by xldcontrolb(). + */ + .globl _C_LABEL(Lfsbail) +Lfsbail: + st %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault + retl ! and return error indicator + mov -1, %o0 + /* * probeset(addr, size, val) caddr_t addr; int size, val; * diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index b143af5f4af..de8a1c11976 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.90 2002/12/17 23:11:32 millert Exp $ */ +/* $OpenBSD: machdep.c,v 1.91 2003/01/09 22:27:10 miod Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -578,7 +578,8 @@ sendsig(catcher, sig, mask, code, type, val) write_user_windows(); /* XXX do not copyout siginfo if not needed */ if (rwindow_save(p) || copyout((caddr_t)&sf, (caddr_t)fp, sizeof sf) || - suword(&((struct rwindow *)newsp)->rw_in[6], oldsp)) { + copyout(&oldsp, &((struct rwindow *)newsp)->rw_in[6], + sizeof(register_t)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. diff --git a/sys/arch/sparc/sparc/svr4_machdep.c b/sys/arch/sparc/sparc/svr4_machdep.c index cd448800d36..097b360ced5 100644 --- a/sys/arch/sparc/sparc/svr4_machdep.c +++ b/sys/arch/sparc/sparc/svr4_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_machdep.c,v 1.11 2002/07/20 19:24:57 art Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.12 2003/01/09 22:27:10 miod Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1997/07/29 10:04:45 fair Exp $ */ /* @@ -496,7 +496,8 @@ svr4_sendsig(catcher, sig, mask, code, type, val) write_user_windows(); if (rwindow_save(p) || copyout(&frame, fp, sizeof(frame)) != 0 || - suword(&((struct rwindow *)newsp)->rw_in[6], oldsp)) { + copyout(&oldsp, &((struct rwindow *)newsp)->rw_in[6], + sizeof(register_t)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. diff --git a/sys/arch/sparc64/sparc64/db_interface.c b/sys/arch/sparc64/sparc64/db_interface.c index b32eea46048..7609736d661 100644 --- a/sys/arch/sparc64/sparc64/db_interface.c +++ b/sys/arch/sparc64/sparc64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.12 2002/07/24 00:48:25 art Exp $ */ +/* $OpenBSD: db_interface.c,v 1.13 2003/01/09 22:27:10 miod Exp $ */ /* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */ /* @@ -378,7 +378,7 @@ db_read_bytes(addr, size, data) if (src >= (char *)VM_MIN_KERNEL_ADDRESS) *data++ = probeget((paddr_t)(u_long)src++, ASI_P, 1); else - *data++ = fubyte(src++); + copyin(src++, data++, sizeof(u_char)); } } @@ -405,7 +405,7 @@ db_write_bytes(addr, size, data) /* Read Only mapping -- need to do a bypass access */ stba((u_long)dst - ktext + ktextp, ASI_PHYS_CACHED, *data); else - subyte(dst, *data); + copyout(data, dst, sizeof(char)); dst++, data++; } diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 1b93f3b9607..be62b3af491 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.25 2002/09/10 18:29:44 art Exp $ */ +/* $OpenBSD: locore.s,v 1.26 2003/01/09 22:27:10 miod Exp $ */ /* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */ /* @@ -7749,146 +7749,6 @@ ENTRY(proc_trampoline) ba,a,pt %icc, return_from_trap nop -/* - * {fu,su}{,i}{byte,word} - */ -ALTENTRY(fuiword) -ENTRY(fuword) - btst 3, %o0 ! has low bits set... - bnz Lfsbadaddr ! go return -1 - EMPTY - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - set Lfserr, %o3 - LDPTR [%o2 + %lo(CPCB)], %o2 - membar #LoadStore - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - LDPTRA [%o0] ASI_AIUS, %o0 ! fetch the word - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - retl ! phew, made it, return the word - membar #StoreStore|#StoreLoad - -Lfserr: - STPTR %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault - membar #StoreStore|#StoreLoad -Lfsbadaddr: -#ifndef _LP64 - mov -1, %o1 -#endif - retl ! and return error indicator - mov -1, %o0 - - /* - * This is just like Lfserr, but it's a global label that allows - * mem_access_fault() to check to see that we don't want to try to - * page in the fault. It's used by fuswintr() etc. - */ - .globl _C_LABEL(Lfsbail) -_C_LABEL(Lfsbail): - STPTR %g0, [%o2 + PCB_ONFAULT]! error in r/w, clear pcb_onfault - membar #StoreStore|#StoreLoad - retl ! and return error indicator - mov -1, %o0 - - /* - * Like fusword but callable from interrupt context. - * Fails if data isn't resident. - */ -ENTRY(fuswintr) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = _Lfsbail; - LDPTR [%o2 + %lo(CPCB)], %o2 - set _C_LABEL(Lfsbail), %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - lduha [%o0] ASI_AIUS, %o0 ! fetch the halfword - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - retl ! made it - membar #StoreStore|#StoreLoad - -ENTRY(fusword) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - LDPTR [%o2 + %lo(CPCB)], %o2 - set Lfserr, %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - lduha [%o0] ASI_AIUS, %o0 ! fetch the halfword - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - retl ! made it - membar #StoreStore|#StoreLoad - -ALTENTRY(fuibyte) -ENTRY(fubyte) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - LDPTR [%o2 + %lo(CPCB)], %o2 - set Lfserr, %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - lduba [%o0] ASI_AIUS, %o0 ! fetch the byte - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! but first clear onfault - retl ! made it - membar #StoreStore|#StoreLoad - -ALTENTRY(suiword) -ENTRY(suword) - btst 3, %o0 ! or has low bits set ... - bnz Lfsbadaddr ! go return error - EMPTY - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - LDPTR [%o2 + %lo(CPCB)], %o2 - set Lfserr, %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - STPTRA %o1, [%o0] ASI_AIUS ! store the word - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - membar #StoreStore|#StoreLoad - retl ! and return 0 - clr %o0 - -ENTRY(suswintr) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = _Lfsbail; - LDPTR [%o2 + %lo(CPCB)], %o2 - set _C_LABEL(Lfsbail), %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - stha %o1, [%o0] ASI_AIUS ! store the halfword - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - membar #StoreStore|#StoreLoad - retl ! and return 0 - clr %o0 - -ENTRY(susword) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - LDPTR [%o2 + %lo(CPCB)], %o2 - set Lfserr, %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - stha %o1, [%o0] ASI_AIUS ! store the halfword - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - membar #StoreStore|#StoreLoad - retl ! and return 0 - clr %o0 - -ALTENTRY(suibyte) -ENTRY(subyte) - sethi %hi(CPCB), %o2 ! cpcb->pcb_onfault = Lfserr; - LDPTR [%o2 + %lo(CPCB)], %o2 - set Lfserr, %o3 - STPTR %o3, [%o2 + PCB_ONFAULT] - membar #Sync - stba %o1, [%o0] ASI_AIUS ! store the byte - membar #Sync - STPTR %g0, [%o2 + PCB_ONFAULT]! made it, clear onfault - membar #StoreStore|#StoreLoad - retl ! and return 0 - clr %o0 - /* probeget and probeset are meant to be used during autoconfiguration */ /* * The following probably need to be changed, but to what I don't know. diff --git a/sys/arch/sparc64/sparc64/mem.c b/sys/arch/sparc64/sparc64/mem.c index bf25de2132d..5c3884e5087 100644 --- a/sys/arch/sparc64/sparc64/mem.c +++ b/sys/arch/sparc64/sparc64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.6 2001/12/04 23:22:42 art Exp $ */ +/* $OpenBSD: mem.c,v 1.7 2003/01/09 22:27:11 miod Exp $ */ /* $NetBSD: mem.c,v 1.18 2001/04/24 04:31:12 thorpej Exp $ */ /* @@ -180,14 +180,23 @@ mmrw(dev, uio, flags) case UIO_USERSPACE: if (uio->uio_rw == UIO_READ) - while (cnt--) - if(subyte(d++, lduba(v++, ASI_PHYS_CACHED))) { - error = EFAULT; - goto unlock; - } + while (cnt--) { + char tmp; + + tmp = lduba(v++, ASI_PHYS_CACHED); + error = copyout(&tmp, d++, sizeof(tmp)); + if (error != 0) + break; + } else - while (cnt--) - stba(v++, ASI_PHYS_CACHED, fubyte(d++)); + while (cnt--) { + char tmp; + + error = copyin(d++, &tmp, sizeof(tmp)); + if (error != 0) + break; + stba(v++, ASI_PHYS_CACHED, tmp); + } if (error) goto unlock; break; diff --git a/sys/arch/sparc64/sparc64/openprom.c b/sys/arch/sparc64/sparc64/openprom.c index de589afdf98..0d3c4dc0a9e 100644 --- a/sys/arch/sparc64/sparc64/openprom.c +++ b/sys/arch/sparc64/sparc64/openprom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openprom.c,v 1.8 2002/07/31 18:39:22 jason Exp $ */ +/* $OpenBSD: openprom.c,v 1.9 2003/01/09 22:27:11 miod Exp $ */ /* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */ /* @@ -218,8 +218,10 @@ openpromioctl(dev, cmd, data, flags, p) error = OF_nextprop(node, name, nextprop); splx(s); if (error == 0) { + char nul = 0; + op->op_buflen = 0; - error = subyte(op->op_buf, 0); + error = copyin(&nul, op->op_buf, sizeof(char)); break; } if (error == -1) { diff --git a/sys/arch/vax/vax/subr.s b/sys/arch/vax/vax/subr.s index 38a705fb3bd..6ffa5a25556 100644 --- a/sys/arch/vax/vax/subr.s +++ b/sys/arch/vax/vax/subr.s @@ -1,4 +1,4 @@ -/* $OpenBSD: subr.s,v 1.17 2002/06/11 09:36:24 hugh Exp $ */ +/* $OpenBSD: subr.s,v 1.18 2003/01/09 22:27:11 miod Exp $ */ /* $NetBSD: subr.s,v 1.32 1999/03/25 00:41:48 mrg Exp $ */ /* @@ -493,48 +493,6 @@ ENTRY(copystr,0) 4: clrl *pcbtrap ret -ENTRY(subyte,0) - movl 4(ap),r0 - blss 3f # illegal space - movab 1f,*pcbtrap - movb 8(ap),(r0) - clrl r1 -1: clrl *pcbtrap - movl r1,r0 - ret - -ENTRY(suword,0) - movl 4(ap),r0 - blss 3f # illegal space - movab 1f,*pcbtrap - movl 8(ap),(r0) - clrl r1 -1: clrl *pcbtrap - movl r1,r0 - ret - -ENTRY(suswintr,0) - movl 4(ap),r0 - blss 3f # illegal space - movab 1f,*pcbtrap - movw 8(ap),(r0) - clrl r1 -1: clrl *pcbtrap - movl r1,r0 - ret - -3: mnegl $1,r0 - ret - -ENTRY(fuswintr,0) - movl 4(ap),r0 - blss 3b # illegal space - movab 1f,*pcbtrap - movzwl (r0),r1 -1: clrl *pcbtrap - movl r1,r0 - ret - # # data department # diff --git a/sys/arch/vax/vsa/smg.c b/sys/arch/vax/vsa/smg.c index 9d0019311c1..0cf41acb60d 100644 --- a/sys/arch/vax/vsa/smg.c +++ b/sys/arch/vax/vsa/smg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smg.c,v 1.7 2002/03/14 01:26:49 millert Exp $ */ +/* $OpenBSD: smg.c,v 1.8 2003/01/09 22:27:11 miod Exp $ */ /* $NetBSD: smg.c,v 1.21 2000/03/23 06:46:44 thorpej Exp $ */ /* * Copyright (c) 1998 Ludd, University of Lule}, Sweden. @@ -433,14 +433,14 @@ setcursor(struct wsdisplay_cursor *v) } if (v->which & WSDISPLAY_CURSOR_DOCMAP) { /* First background */ - red = fuswintr(v->cmap.red); - green = fuswintr(v->cmap.green); - blue = fuswintr(v->cmap.blue); + copyin(v->cmap.red, &red, sizeof(u_short)); + copyin(v->cmap.green, &green, sizeof(u_short)); + copyin(v->cmap.blue, &blue, sizeof(u_short)); bgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >= (((1<<8)-1)*50)) ? ~0 : 0; - red = fuswintr(v->cmap.red+2); - green = fuswintr(v->cmap.green+2); - blue = fuswintr(v->cmap.blue+2); + copyin(v->cmap.red + 2, &red, sizeof(u_short)); + copyin(v->cmap.green + 2, &green, sizeof(u_short)); + copyin(v->cmap.blue + 2, &blue, sizeof(u_short)); fgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >= (((1<<8)-1)*50)) ? ~0 : 0; } |