Module Name: src
Committed By: ryo
Date: Fri Sep 14 13:47:14 UTC 2018
Modified Files:
src/sys/arch/aarch64/aarch64: copyinout.S trap.c
Log Message:
change copystr() to asm so that we don't have to add __noasan.
Also copyinout.S is the right place for copystr().
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/copyinout.S
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/copyinout.S
diff -u src/sys/arch/aarch64/aarch64/copyinout.S:1.8 src/sys/arch/aarch64/aarch64/copyinout.S:1.9
--- src/sys/arch/aarch64/aarch64/copyinout.S:1.8 Mon Sep 10 17:25:15 2018
+++ src/sys/arch/aarch64/aarch64/copyinout.S Fri Sep 14 13:47:14 2018
@@ -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 @@ copyoutstr_done:
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)
Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.9 src/sys/arch/aarch64/aarch64/trap.c:1.10
--- src/sys/arch/aarch64/aarch64/trap.c:1.9 Mon Sep 10 17:25:15 2018
+++ src/sys/arch/aarch64/aarch64/trap.c Fri Sep 14 13:47:14 2018
@@ -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 @@ ucas_ras_check(struct trapframe *tf)
#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)