Patchwork [7/9] alpha-linux-user: Fix a3 error return with v0 error bypass.

login
register
mail settings
Submitter Richard Henderson
Date June 7, 2012, 10:24 p.m.
Message ID <1339107871-4487-8-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/163688/
State New
Headers show

Comments

Richard Henderson - June 7, 2012, 10:24 p.m.
We were failing to initialize a3 for syscalls that bypass the
negative return value error check.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 linux-user/main.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index e81abb2..605018a 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2758,13 +2758,11 @@  void cpu_loop(CPUAlphaState *env)
                     break;
                 }
                 /* Syscall writes 0 to V0 to bypass error check, similar
-                   to how this is handled internal to Linux kernel.  */
-                if (env->ir[IR_V0] == 0) {
-                    env->ir[IR_V0] = sysret;
-                } else {
-                    env->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);
-                    env->ir[IR_A3] = (sysret < 0);
-                }
+                   to how this is handled internal to Linux kernel.
+                   (Ab)use trapnr temporarily as boolean indicating error.  */
+                trapnr = (env->ir[IR_V0] != 0 && sysret < 0);
+                env->ir[IR_V0] = (trapnr ? -sysret : sysret);
+                env->ir[IR_A3] = trapnr;
                 break;
             case 0x86:
                 /* IMB */