Skip to contentSkip to conversation

linux-user: AArch64: Fix exclusive store of the zero register

PATCH In review Janne Grunau 3 participants 3 messages Feb 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: AArch64: Fix exclusive store of the zero register

---
 linux-user/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
linux-user/main.c +4 -2
index cabc9e1..9192977 100644
@@ -953,7 +953,8 @@ static int do_strex_a64(CPUARMState *env)
             goto finish;
         }
     }
-    val = env->xregs[rt];
+    /* handle the zero register */
+    val = rt == 31 ? 0 : env->xregs[rt];
     switch (size) {
     case 0:
         segv = put_user_u8(val, addr);
@@ -972,7 +973,8 @@ static int do_strex_a64(CPUARMState *env)
         goto error;
     }
     if (is_pair) {
-        val = env->xregs[rt2];
+        /* handle the zero register */
+        val = rt2 == 31 ? 0 : env->xregs[rt2];
         if (size == 2) {
             segv = put_user_u32(val, addr + 4);
         } else {
Signature · 1 line
1.8.5.5
Reviewed-by on v1 1/1
#2 lore raw
In reply to Janne Grunau
Quoted 20 lines · [email protected] writes:
---
 linux-user/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
linux-user/main.c +2 -1
index cabc9e1..9192977 100644
@@ -953,7 +953,8 @@ static int do_strex_a64(CPUARMState *env)
             goto finish;
         }
     }
-    val = env->xregs[rt];
+    /* handle the zero register */
+    val = rt == 31 ? 0 : env->xregs[rt];
     switch (size) {
     case 0:
         segv = put_user_u8(val, addr);

linux-user/main.c static int do_strex_a64(CPUARMState *env) · line 980

Quoted 9 lines
linux-user/main.c +2 -1
@@ -972,7 +973,8 @@ static int do_strex_a64(CPUARMState *env)
         goto error;
     }
     if (is_pair) {
-        val = env->xregs[rt2];
+        /* handle the zero register */
+        val = rt2 == 31 ? 0 : env->xregs[rt2];
         if (size == 2) {
             segv = put_user_u32(val, addr + 4);
         } else {

Looks good to me. I'll have a scan through the other helpers to see if we've missed any other similar thinkos.

Signature · 1 line
Alex Bennée