Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145410071
D54947.id170737.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D54947.id170737.diff
View Options
diff --git a/sys/arm64/arm64/copyinout.S b/sys/arm64/arm64/copyinout.S
--- a/sys/arm64/arm64/copyinout.S
+++ b/sys/arm64/arm64/copyinout.S
@@ -65,9 +65,9 @@
/*
* Copies from a kernel to user address
*
- * int copyout(const void *kaddr, void *udaddr, size_t len)
+ * int copyout_std(const void *kaddr, void *udaddr, size_t len)
*/
-ENTRY(copyout)
+ENTRY(copyout_std)
cbz x2, 1f
check_user_access 1, 2, copyio_fault_nopcb
@@ -76,14 +76,46 @@
1: mov x0, xzr /* return 0 */
ret
-END(copyout)
+END(copyout_std)
+
+/*
+ * Copies from a kernel to user address
+ *
+ * int copyout_mops(const void *kaddr, void *udaddr, size_t len)
+ */
+ENTRY(copyout_mops)
+ cbz x2, 1f
+ check_user_access 1, 2, copyio_fault_nopcb
+
+ b copycommon_mops
+
+1: mov x0, xzr /* return 0 */
+ ret
+
+END(copyout_mops)
+
+/*
+ * Copies from a user to kernel address
+ *
+ * int copyin_std(const void *uaddr, void *kdaddr, size_t len)
+ */
+ENTRY(copyin_std)
+ cbz x2, 1f
+ check_user_access 0, 2, copyio_fault_nopcb
+
+ b copycommon
+
+1: mov x0, xzr /* return 0 */
+ ret
+
+END(copyin_std)
/*
* Copies from a user to kernel address
*
- * int copyin(const void *uaddr, void *kdaddr, size_t len)
+ * int copyin_mops(const void *uaddr, void *kdaddr, size_t len)
*/
-ENTRY(copyin)
+ENTRY(copyin_mops)
cbz x2, 1f
check_user_access 0, 2, copyio_fault_nopcb
@@ -92,7 +124,7 @@
1: mov x0, xzr /* return 0 */
ret
-END(copyin)
+END(copyin_mops)
/*
* Copies a string from a user to kernel address
@@ -236,4 +268,35 @@
ret
.size copycommon, . - copycommon
+
+/*
+ * Local helper (MOPS version)
+ *
+ * x0 - src pointer
+ * x1 - dst pointer
+ * x2 - size
+ * lr - the return address, so jump here instead of calling
+ */
+ .text
+ .align 4
+ .local copycommon_mops
+ .type copycommon_mops,@function
+
+copycommon_mops:
+ adr x6, copyio_fault /* Get the handler address */
+ SET_FAULT_HANDLER(x6, x7) /* Set the handler */
+ ENTER_USER_ACCESS(w6, x7)
+
+ .inst 0x19000441 /* cpyfp [x1]!, [x0]!, x2! */
+ .inst 0x19400441 /* cpyfm [x1]!, [x0]!, x2! */
+ .inst 0x19800441 /* cpyfe [x1]!, [x0]!, x2! */
+
+ EXIT_USER_ACCESS_CHECK(w6, x7)
+ SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
+
+ mov x0, xzr /* return 0 */
+ ret
+ .size copycommon_mops, . - copycommon_mops
+
+
GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/sys/arm64/arm64/copyinout_ifunc.c b/sys/arm64/arm64/copyinout_ifunc.c
new file mode 100644
--- /dev/null
+++ b/sys/arm64/arm64/copyinout_ifunc.c
@@ -0,0 +1,48 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 ARM Ltd
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+
+#include <machine/cpu.h>
+#include <machine/ifunc.h>
+
+int copyout_std(const void *kaddr, void *udaddr, size_t len);
+int copyout_mops(const void *kaddr, void *udaddr, size_t len);
+int copyin_std(const void *uaddr, void *kdaddr, size_t len);
+int copyin_mops(const void *uaddr, void *kdaddr, size_t len);
+
+DEFINE_IFUNC(, int, copyout, (const void *, void *, size_t))
+{
+ return ((mops_supported) != 0 ? copyout_mops : copyout_std);
+}
+
+DEFINE_IFUNC(, int, copyin, (const void *, void *, size_t))
+{
+ return ((mops_supported) != 0 ? copyin_mops : copyin_std);
+}
diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64
--- a/sys/conf/files.arm64
+++ b/sys/conf/files.arm64
@@ -36,6 +36,7 @@
arm64/arm64/busdma_machdep.c standard
arm64/arm64/clock.c standard
arm64/arm64/copyinout.S standard
+arm64/arm64/copyinout_ifunc.c standard
arm64/arm64/cpu_errata.c standard
arm64/arm64/cpu_feat.c standard
arm64/arm64/cpufunc_asm.S standard
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 20, 11:53 AM (1 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28898822
Default Alt Text
D54947.id170737.diff (4 KB)
Attached To
Mode
D54947: arm64: Add MOPS implementations of copyin/copyout
Attached
Detach File
Event Timeline
Log In to Comment