From d809b7922020ea56737f0e02a02729f71bf684a2 Mon Sep 17 00:00:00 2001 From: Benno Rice Date: Mon, 29 Apr 2002 09:28:56 +0000 Subject: [PATCH] - Add back calls to setfault that were removed when these functions were moved. --- sys/powerpc/aim/copyinout.c | 88 +++++++++++++++++++++++++++------ sys/powerpc/powerpc/copyinout.c | 88 +++++++++++++++++++++++++++------ 2 files changed, 148 insertions(+), 28 deletions(-) diff --git a/sys/powerpc/aim/copyinout.c b/sys/powerpc/aim/copyinout.c index c1ec6d3033be..a7d416ce5fbb 100644 --- a/sys/powerpc/aim/copyinout.c +++ b/sys/powerpc/aim/copyinout.c @@ -83,6 +83,7 @@ copyout(const void *kaddr, void *udaddr, size_t len) { struct thread *td; pmap_t pm; + faultbuf env; const char *kp; char *up, *p; size_t l; @@ -90,6 +91,14 @@ copyout(const void *kaddr, void *udaddr, size_t len) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + printf("copyout: called with %p, %p, %d (td=%p)\n", kaddr, udaddr, len, + td); + + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -109,6 +118,7 @@ copyout(const void *kaddr, void *udaddr, size_t len) len -= l; } + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -117,6 +127,7 @@ copyin(const void *udaddr, void *kaddr, size_t len) { struct thread *td; pmap_t pm; + faultbuf env; const char *up; char *kp, *p; size_t l; @@ -124,6 +135,14 @@ copyin(const void *udaddr, void *kaddr, size_t len) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + printf("copyin: called with %p, %p, %d (td=%p)\n", udaddr, kaddr, len, + td); + + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -143,6 +162,7 @@ copyin(const void *udaddr, void *kaddr, size_t len) len -= l; } + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -151,6 +171,7 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) { struct thread *td; pmap_t pm; + faultbuf env; const char *up; char *kp; size_t l; @@ -159,6 +180,11 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -181,24 +207,32 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) *done = l; } + td->td_pcb->pcb_onfault = NULL; return (rv); } int subyte(void *addr, int byte) { - struct thread *td; - pmap_t pm; - char *p; + struct thread *td; + pmap_t pm; + faultbuf env; + char *p; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); *p = (char)byte; + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -212,49 +246,75 @@ suibyte(void *addr, int byte) int suword(void *addr, long word) { - struct thread *td; - pmap_t pm; - long *p; + struct thread *td; + pmap_t pm; + faultbuf env; + long *p; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); *p = word; + td->td_pcb->pcb_onfault = NULL; return (0); } int fubyte(const void *addr) { - struct thread *td; - pmap_t pm; - char *p; + struct thread *td; + pmap_t pm; + faultbuf env; + char *p; + int val; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); - return ((int)*p); + val = (int)*p; + + td->td_pcb->pcb_onfault = NULL; + return (val); } long fuword(const void *addr) { - struct thread *td; - pmap_t pm; - long *p; + struct thread *td; + pmap_t pm; + faultbuf env; + long *p, val; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); - return (*p); + val = *p; + + td->td_pcb->pcb_onfault = NULL; + return (val); } diff --git a/sys/powerpc/powerpc/copyinout.c b/sys/powerpc/powerpc/copyinout.c index c1ec6d3033be..a7d416ce5fbb 100644 --- a/sys/powerpc/powerpc/copyinout.c +++ b/sys/powerpc/powerpc/copyinout.c @@ -83,6 +83,7 @@ copyout(const void *kaddr, void *udaddr, size_t len) { struct thread *td; pmap_t pm; + faultbuf env; const char *kp; char *up, *p; size_t l; @@ -90,6 +91,14 @@ copyout(const void *kaddr, void *udaddr, size_t len) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + printf("copyout: called with %p, %p, %d (td=%p)\n", kaddr, udaddr, len, + td); + + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -109,6 +118,7 @@ copyout(const void *kaddr, void *udaddr, size_t len) len -= l; } + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -117,6 +127,7 @@ copyin(const void *udaddr, void *kaddr, size_t len) { struct thread *td; pmap_t pm; + faultbuf env; const char *up; char *kp, *p; size_t l; @@ -124,6 +135,14 @@ copyin(const void *udaddr, void *kaddr, size_t len) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + printf("copyin: called with %p, %p, %d (td=%p)\n", udaddr, kaddr, len, + td); + + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -143,6 +162,7 @@ copyin(const void *udaddr, void *kaddr, size_t len) len -= l; } + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -151,6 +171,7 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) { struct thread *td; pmap_t pm; + faultbuf env; const char *up; char *kp; size_t l; @@ -159,6 +180,11 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + kp = kaddr; up = udaddr; @@ -181,24 +207,32 @@ copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) *done = l; } + td->td_pcb->pcb_onfault = NULL; return (rv); } int subyte(void *addr, int byte) { - struct thread *td; - pmap_t pm; - char *p; + struct thread *td; + pmap_t pm; + faultbuf env; + char *p; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); *p = (char)byte; + td->td_pcb->pcb_onfault = NULL; return (0); } @@ -212,49 +246,75 @@ suibyte(void *addr, int byte) int suword(void *addr, long word) { - struct thread *td; - pmap_t pm; - long *p; + struct thread *td; + pmap_t pm; + faultbuf env; + long *p; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); *p = word; + td->td_pcb->pcb_onfault = NULL; return (0); } int fubyte(const void *addr) { - struct thread *td; - pmap_t pm; - char *p; + struct thread *td; + pmap_t pm; + faultbuf env; + char *p; + int val; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); - return ((int)*p); + val = (int)*p; + + td->td_pcb->pcb_onfault = NULL; + return (val); } long fuword(const void *addr) { - struct thread *td; - pmap_t pm; - long *p; + struct thread *td; + pmap_t pm; + faultbuf env; + long *p, val; td = PCPU_GET(curthread); pm = &td->td_proc->p_vmspace->vm_pmap; p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK)); + if (setfault(env)) { + td->td_pcb->pcb_onfault = NULL; + return (EFAULT); + } + set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]); - return (*p); + val = *p; + + td->td_pcb->pcb_onfault = NULL; + return (val); }