Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/arch/powerpc/booke Pull up following revision(s) (req...
details: https://anonhg.NetBSD.org/src/rev/2a158a2b5352
branches: netbsd-9
changeset: 745709:2a158a2b5352
user: martin <martin%NetBSD.org@localhost>
date: Mon Mar 09 10:11:40 2020 +0000
description:
Pull up following revision(s) (requested by rin in ticket #771):
sys/arch/powerpc/booke/copyout.c: revision 1.6
sys/arch/powerpc/booke/copyout.c: revision 1.7
sys/arch/powerpc/booke/copyout.c: revision 1.8
copyoutstr(9): sync style with copyinstr(9).
- use variable name "done" instead of "lenp"
- return return value from setfault() on fault, instead of hardcoded EFAULT
No functional changes intended.
copyoutstr(9): return ENAMETOOLONG correctly when source string is
not NUL-terminated.
Comment out full function of optimized version of copyoutstr(9),
which has never been enabled so far.
Only for clarity. No binary changes.
diffstat:
sys/arch/powerpc/booke/copyout.c | 60 +++++++++++++++++++++++++++++++--------
1 files changed, 47 insertions(+), 13 deletions(-)
diffs (98 lines):
diff -r a85ad742f607 -r 2a158a2b5352 sys/arch/powerpc/booke/copyout.c
--- a/sys/arch/powerpc/booke/copyout.c Mon Mar 09 09:55:52 2020 +0000
+++ b/sys/arch/powerpc/booke/copyout.c Mon Mar 09 10:11:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $ */
+/* $NetBSD: copyout.c,v 1.5.4.1 2020/03/09 10:11:40 martin Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.5.4.1 2020/03/09 10:11:40 martin Exp $");
#define __UFETCHSTORE_PRIVATE
@@ -400,6 +400,50 @@
return 0;
}
+#if 1
+int
+copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *done)
+{
+ struct pcb * const pcb = lwp_getpcb(curlwp);
+ struct faultbuf env;
+ int rv;
+
+ if (__predict_false(len == 0)) {
+ if (done)
+ *done = 0;
+ return 0;
+ }
+
+ rv = setfault(&env);
+ if (rv != 0) {
+ pcb->pcb_onfault = NULL;
+ if (done)
+ *done = 0;
+ return rv;
+ }
+
+ const register_t ds_msr = mfmsr() | PSL_DS;
+ const uint8_t *ksaddr8 = ksaddr;
+ size_t copylen = 0;
+
+ uint8_t *udaddr8 = (void *)udaddr;
+
+ while (copylen++ < len) {
+ const uint8_t data = *ksaddr8++;
+ copyout_uint8(udaddr8++, data, ds_msr);
+ if (data == 0)
+ goto out;
+ }
+ rv = ENAMETOOLONG;
+
+out:
+ pcb->pcb_onfault = NULL;
+ if (done)
+ *done = copylen;
+ return rv;
+}
+#else
+/* XXX This version of copyoutstr(9) has never beeen enabled so far. */
int
copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
{
@@ -423,16 +467,6 @@
const uint8_t *ksaddr8 = ksaddr;
size_t copylen = 0;
-#if 1
- uint8_t *udaddr8 = (void *)udaddr;
-
- while (copylen++ < len) {
- const uint8_t data = *ksaddr8++;
- copyout_uint8(udaddr8++, data, ds_msr);
- if (data == 0)
- break;
- }
-#else
uint32_t *udaddr32 = (void *)((uintptr_t)udaddr & ~3);
size_t boff = (uintptr_t)udaddr & 3;
@@ -523,10 +557,10 @@
copyout_le32_with_mask(udaddr32, data, mask, ds_msr);
copylen += wlen;
}
-#endif
pcb->pcb_onfault = NULL;
if (lenp)
*lenp = copylen;
return 0;
}
+#endif
Home |
Main Index |
Thread Index |
Old Index