Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64/aarch64 change copystr() to asm so that we ...



details:   https://anonhg.NetBSD.org/src/rev/960a439aa0ed
branches:  trunk
changeset: 433433:960a439aa0ed
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Sep 14 13:47:14 2018 +0000

description:
change copystr() to asm so that we don't have to add __noasan.
Also copyinout.S is the right place for copystr().

diffstat:

 sys/arch/aarch64/aarch64/copyinout.S |  32 ++++++++++++++++++++++++++++++--
 sys/arch/aarch64/aarch64/trap.c      |  30 ++----------------------------
 2 files changed, 32 insertions(+), 30 deletions(-)

diffs (104 lines):

diff -r 8e7ce6c22f0e -r 960a439aa0ed sys/arch/aarch64/aarch64/copyinout.S
--- a/sys/arch/aarch64/aarch64/copyinout.S      Fri Sep 14 13:19:15 2018 +0000
+++ b/sys/arch/aarch64/aarch64/copyinout.S      Fri Sep 14 13:47:14 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: copyinout.S,v 1.8 2018/09/10 17:25:15 ryo Exp $ */
+/* $NetBSD: copyinout.S,v 1.9 2018/09/14 13:47:14 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include <aarch64/asm.h>
 #include "assym.h"
 
-RCSID("$NetBSD: copyinout.S,v 1.8 2018/09/10 17:25:15 ryo Exp $");
+RCSID("$NetBSD: copyinout.S,v 1.9 2018/09/14 13:47:14 ryo Exp $");
 
        .macro enter_cpu_onfault
        stp     fp, lr, [sp, #-16]!     /* save fp, lr */
@@ -314,6 +314,34 @@
 END(copyoutstr)
 
 
+/* LINTSTUB: int copystr(const void *s, void *d, size_t len, size_t *done); */
+
+ENTRY(copystr)
+       enter_cpu_onfault
+
+       mov     x8, #0                  /* error = 0 */
+
+       mov     x4, xzr                 /* i = 0 */
+       cbz     x2, copystr_done        /* if (len == 0) goto done */
+copystr_loop:
+       ldrb    w5, [x0], #1            /* ch = src[i] */
+       strb    w5, [x1], #1            /* dst[i] = ch */
+       add     x4, x4, #1              /* i++ */
+       cbz     x5, copystr_done        /* if (ch == '\0') goto done */
+
+       cmp     x4, x2                  /* if (i < len) goto loop */
+       bcc     copystr_loop
+       mov     x8, #ENAMETOOLONG       /* error = ENAMETOOLONG */
+
+copystr_done:
+       cbz     x3, 1f                  /* if (done != NULL) *done = i */
+       str     x4, [x3]
+1:
+       exit_cpu_onfault
+       ret
+END(copystr)
+
+
 /* LINTSTUB: int kcopy(const void *src, void *dst, size_t len); */
 
 ENTRY(kcopy)
diff -r 8e7ce6c22f0e -r 960a439aa0ed sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Fri Sep 14 13:19:15 2018 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Fri Sep 14 13:47:14 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.9 2018/09/10 17:25:15 ryo Exp $ */
+/* $NetBSD: trap.c,v 1.10 2018/09/14 13:47:14 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.9 2018/09/10 17:25:15 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.10 2018/09/14 13:47:14 ryo Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -420,32 +420,6 @@
 #endif
 }
 
-int
-copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done)
-{
-       struct faultbuf fb;
-       size_t i;
-       int error;
-       const char *src = kfaddr;
-       char *dst = kdaddr;
-
-       if ((error = cpu_set_onfault(&fb)) == 0) {
-               for (i = 0; i < len; i++) {
-                       if ((*dst++ = *src++) == '\0') {
-                               i++;
-                               error = 0;
-                               goto done;
-                       }
-               }
-               error = ENAMETOOLONG;
- done:
-               if (done != NULL)
-                       *done = i;
-               cpu_unset_onfault();
-       }
-       return error;
-}
-
 #ifdef TRAP_SIGDEBUG
 static void
 frame_dump(const struct trapframe *tf)



Home | Main Index | Thread Index | Old Index