Module Name: src Committed By: rin Date: Sun Sep 11 09:08:04 UTC 2022
Modified Files: src/sys/arch/powerpc/ibm4xx: trap.c Log Message: copy{in,out}(): Tiny optimizations for __asm codes. No regressions for full ATF run. - Use {l,st}swx instead of loop for remaining bytes. - Drop needless "mtpid %[x]; isync;". To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/arch/powerpc/ibm4xx/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/ibm4xx/trap.c diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.93 src/sys/arch/powerpc/ibm4xx/trap.c:1.94 --- src/sys/arch/powerpc/ibm4xx/trap.c:1.93 Sun Sep 11 09:03:25 2022 +++ src/sys/arch/powerpc/ibm4xx/trap.c Sun Sep 11 09:08:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.93 2022/09/11 09:03:25 rin Exp $ */ +/* $NetBSD: trap.c,v 1.94 2022/09/11 09:08:04 rin Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -69,7 +69,7 @@ #define __UFETCHSTORE_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.93 2022/09/11 09:03:25 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.94 2022/09/11 09:08:04 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -485,23 +485,18 @@ copyin(const void *uaddr, void *kaddr, s "2:" "andi. %[count],%[len],0x3;" /* How many remaining bytes? */ "beq 10f;" - "addi %[count],%[count],0x1;" - "mtctr %[count];" - "3:" "bdz 10f;" /* while count */ + "mtxer %[count];" "mtpid %[ctx];" "isync;" - "lbz %[tmp],0(%[uaddr]);" /* Load user byte */ - "addi %[uaddr],%[uaddr],0x1;" /* next uaddr byte */ + "lswx %[tmp],0,%[uaddr];" /* Load user bytes */ "sync;" "mtpid %[pid];" "isync;" - "stb %[tmp],0(%[kaddr]);" /* Store kernel byte */ + "stswx %[tmp],0,%[kaddr];" /* Store kernel byte */ "dcbst 0,%[kaddr];" /* flush cache */ - "addi %[kaddr],%[kaddr],0x1;" "sync;" - "b 3b;" "10:" "mtpid %[pid];" /* Restore PID and MSR */ "mtmsr %[msr];" @@ -510,7 +505,7 @@ copyin(const void *uaddr, void *kaddr, s : [msr] "=&r" (msr), [pid] "=&r" (pid), [tmp] "=&r" (tmp) : [uaddr] "b" (uaddr), [ctx] "b" (ctx), [kaddr] "b" (kaddr), [len] "b" (len), [count] "b" (count) - : "cr0", "ctr"); + : "cr0", "ctr", "xer"); curpcb->pcb_onfault = NULL; return 0; @@ -582,8 +577,7 @@ copyout(const void *kaddr, void *uaddr, "beq- 2f;" /* No words. Go do bytes */ "mtctr %[count];" - "1:" "mtpid %[pid];" - "isync;" + "1:" #ifdef PPC_IBM403 "lswi %[tmp],%[kaddr],4;" /* Load kernel word */ #else @@ -602,36 +596,32 @@ copyout(const void *kaddr, void *uaddr, "dcbst 0,%[uaddr];" /* flush cache */ "addi %[uaddr],%[uaddr],0x4;" /* next uaddr word */ "sync;" + + "mtpid %[pid];" + "isync;" "bdnz 1b;" /* repeat */ "2:" "andi. %[count],%[len],0x3;" /* How many remaining bytes? */ "beq 10f;" - "addi %[count],%[count],0x1;" - "mtctr %[count];" - "3:" "bdz 10f;" /* while count */ + "mtxer %[count];" - "mtpid %[pid];" - "isync;" - "lbz %[tmp],0(%[kaddr]);" /* Load kernel byte */ - "addi %[kaddr],%[kaddr],0x1;" /* next kaddr byte */ + "lswx %[tmp],0,%[kaddr];" /* Load kernel bytes */ "sync;" "mtpid %[ctx];" "isync;" - "stb %[tmp],0(%[uaddr]);" /* Store user byte */ + "stswx %[tmp],0,%[uaddr];" /* Store user bytes */ "dcbst 0,%[uaddr];" /* flush cache */ - "addi %[uaddr],%[uaddr],0x1;" "sync;" - "b 3b;" - "10:" "mtpid %[pid];" /* Restore PID and MSR */ - "mtmsr %[msr];" + "mtpid %[pid];" /* Restore PID and MSR */ + "10:" "mtmsr %[msr];" "isync;" : [msr] "=&r" (msr), [pid] "=&r" (pid), [tmp] "=&r" (tmp) : [uaddr] "b" (uaddr), [ctx] "b" (ctx), [kaddr] "b" (kaddr), [len] "b" (len), [count] "b" (count) - : "cr0", "ctr"); + : "cr0", "ctr", "xer"); curpcb->pcb_onfault = NULL; return 0;