git: 6281147a963b - main - dtrace/arm64: Fix user memory access routines

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 15 Jun 2023 16:39:42 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=6281147a963b02bb5d7b4db15ee295d6d65d0fff

commit 6281147a963b02bb5d7b4db15ee295d6d65d0fff
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-06-15 16:39:21 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-06-15 16:39:21 +0000

    dtrace/arm64: Fix user memory access routines
    
    Use unprivileged loads to access user memory.  Without this, the
    accesses trap and various dtrace actions such as ustack() fail.
    
    Reviewed by:    andrew
    MFC after:      1 week
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D40540
---
 sys/cddl/dev/dtrace/aarch64/dtrace_asm.S | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S b/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S
index 710232a0d428..913429865421 100644
--- a/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S
+++ b/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S
@@ -72,7 +72,7 @@ uint8_t
 dtrace_fuword8_nocheck(void *addr)
 */
 ENTRY(dtrace_fuword8_nocheck)
-	ldrb	w0, [x0]
+	ldtrb	w0, [x0]
 	RET
 END(dtrace_fuword8_nocheck)
 
@@ -81,7 +81,7 @@ uint16_t
 dtrace_fuword16_nocheck(void *addr)
 */
 ENTRY(dtrace_fuword16_nocheck)
-	ldrh	w0, [x0]
+	ldtrh	w0, [x0]
 	RET
 END(dtrace_fuword16_nocheck)
 
@@ -90,7 +90,7 @@ uint32_t
 dtrace_fuword32_nocheck(void *addr)
 */
 ENTRY(dtrace_fuword32_nocheck)
-	ldr	w0, [x0]
+	ldtr	w0, [x0]
 	RET
 END(dtrace_fuword32_nocheck)
 
@@ -99,7 +99,7 @@ uint64_t
 dtrace_fuword64_nocheck(void *addr)
 */
 ENTRY(dtrace_fuword64_nocheck)
-	ldr	x0, [x0]
+	ldtr	x0, [x0]
 	RET
 END(dtrace_fuword64_nocheck)
 
@@ -110,7 +110,8 @@ dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size)
 ENTRY(dtrace_copy)
 	cbz	x2, 2f		/* If len == 0 then skip loop */
 1:
-	ldrb	w4, [x0], #1	/* Load from uaddr */
+	ldtrb	w4, [x0]	/* Load from uaddr */
+	add	x0, x0, #1
 	strb	w4, [x1], #1	/* Store in kaddr */
 	sub	x2, x2, #1	/* len-- */
 	cbnz	x2, 1b
@@ -126,8 +127,9 @@ XXX: Check for flags?
 */
 ENTRY(dtrace_copystr)
 	cbz     x2, 2f          /* If len == 0 then skip loop */
- 
-1:	ldrb    w4, [x0], #1    /* Load from uaddr */
+1:
+	ldtrb	w4, [x0]	/* Load from uaddr */
+	add	x0, x0, #1
 	strb    w4, [x1], #1    /* Store in kaddr */
 	cbz     w4, 2f          /* If == 0 then break */
 	sub     x2, x2, #1      /* len-- */