Skip to contentSkip to conversation

linux-user: Fix register used for 6th and 7th syscall argument on aarch64

PATCH Superseded Guido Günther 4 participants 6 messages Jan 24, 2018 – Feb 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Fix register used for 6th and 7th syscall argument on aarch64

Unbreaks the testcase from

    http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

---
 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/host/aarch64/safe-syscall.inc.S +3 -3
index 58a2329b37..bc1f5a9792 100644
@@ -36,7 +36,7 @@ safe_syscall_base:
 	 *               and return the result in x0
 	 * and the syscall instruction needs
 	 *               x8 == syscall number
-	 *               x0 ... x7 == syscall arguments
+	 *               x0 ... x6 == syscall arguments
 	 *               and returns the result in x0
 	 * Shuffle everything around appropriately.
 	 */
@@ -47,8 +47,8 @@ safe_syscall_base:
 	mov	x2, x4
 	mov	x3, x5
 	mov	x4, x6
-	mov	x6, x7
-	ldr	x7, [sp]
+	mov	x5, x7
+	ldr	x6, [sp]
 
 	/* This next sequence of code works in conjunction with the
 	 * rewind_if_safe_syscall_function(). If a signal is taken
Signature · 1 line
2.15.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw

I spent the night studying linux-user end figured out the same correct fix. Just checking morning ML before sending the patch :)

Mine had "Suggested-by: Laurent Vivier <[email protected]>" since he said on IRC "gdb will help" and indeed single stepping before the syscall the bug was obvious.

Quoted 6 lines · Guido Günther

Unbreaks the testcase from

    http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

Quoted 29 lines
---
 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/host/aarch64/safe-syscall.inc.S +3 -3
index 58a2329b37..bc1f5a9792 100644
@@ -36,7 +36,7 @@ safe_syscall_base:
 	 *               and return the result in x0
 	 * and the syscall instruction needs
 	 *               x8 == syscall number
-	 *               x0 ... x7 == syscall arguments
+	 *               x0 ... x6 == syscall arguments
 	 *               and returns the result in x0
 	 * Shuffle everything around appropriately.
 	 */
@@ -47,8 +47,8 @@ safe_syscall_base:
 	mov	x2, x4
 	mov	x3, x5
 	mov	x4, x6
-	mov	x6, x7
-	ldr	x7, [sp]
+	mov	x5, x7
+	ldr	x6, [sp]
 
 	/* This next sequence of code works in conjunction with the
 	 * rewind_if_safe_syscall_function(). If a signal is taken
Reviewed-by on v1 1/1
#2 lore raw
In reply to Guido Günther

Le 24/01/2018 à 11:13, Guido Günther a écrit :

Quoted 25 lines

Unbreaks the testcase from

    http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

---
 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/host/aarch64/safe-syscall.inc.S +1 -1
index 58a2329b37..bc1f5a9792 100644
@@ -36,7 +36,7 @@ safe_syscall_base:
 	 *               and return the result in x0
 	 * and the syscall instruction needs
 	 *               x8 == syscall number
-	 *               x0 ... x7 == syscall arguments
+	 *               x0 ... x6 == syscall arguments
 	 *               and returns the result in x0
 	 * Shuffle everything around appropriately.
 	 */

linux-user/host/aarch64/safe-syscall.inc.S safe_syscall_base: · line 54

Quoted 10 lines
linux-user/host/aarch64/safe-syscall.inc.S +2 -2
@@ -47,8 +47,8 @@ safe_syscall_base:
 	mov	x2, x4
 	mov	x3, x5
 	mov	x4, x6
-	mov	x6, x7
-	ldr	x7, [sp]
+	mov	x5, x7
+	ldr	x6, [sp]
 
 	/* This next sequence of code works in conjunction with the
 	 * rewind_if_safe_syscall_function(). If a signal is taken

for your future patches (I hope there will be), if there are several versions, add the version number in the Subject (i.e. "[PATCH v2]") and version history below the signature mark ("---"):

...

---
v2: fix also 7th arg

     linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)

...

Thanks,
Laurent

#4 lore raw

PATCH v3 1/1 linux-user: Fix register used for 6th and 7th syscall argument on aarch64

In reply to Guido Günther

This unbreaks the testcase from

    http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

---
v3 collects *-by: replies. Anything else I can do to get this applied?

 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/host/aarch64/safe-syscall.inc.S +3 -3
index 58a2329b37..bc1f5a9792 100644
@@ -36,7 +36,7 @@ safe_syscall_base:
 	 *               and return the result in x0
 	 * and the syscall instruction needs
 	 *               x8 == syscall number
-	 *               x0 ... x7 == syscall arguments
+	 *               x0 ... x6 == syscall arguments
 	 *               and returns the result in x0
 	 * Shuffle everything around appropriately.
 	 */
@@ -47,8 +47,8 @@ safe_syscall_base:
 	mov	x2, x4
 	mov	x3, x5
 	mov	x4, x6
-	mov	x6, x7
-	ldr	x7, [sp]
+	mov	x5, x7
+	ldr	x6, [sp]
 
 	/* This next sequence of code works in conjunction with the
 	 * rewind_if_safe_syscall_function(). If a signal is taken
Signature · 1 line
2.15.1
#5 lore raw

Le 02/02/2018 à 11:02, Guido Günther a écrit :

Quoted 11 lines

This unbreaks the testcase from

    http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

Quoted 5 lines

---
v3 collects *-by: replies. Anything else I can do to get this applied?

 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to my 'linux-user-for-2.12' branch.

Thanks,
Laurent