diff mbox series

[09/13] linux-user/sparc: Flush register windows before clone/fork/vfork

Message ID 20190519201953.20161-10-richard.henderson@linaro.org
State New
Headers show
Series linux-user: path, clone, sparc, shmat fixes | expand

Commit Message

Richard Henderson May 19, 2019, 8:19 p.m. UTC
As seen as the very first instruction of sys_clone in the kernel.

Ideally this would be done in or before cpu_copy, and not with a
separate explicit test vs the syscall number, but this is a more
minimal solution.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/sparc/cpu_loop.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

-- 
2.17.1
diff mbox series

Patch

diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
index 9e357229c0..0816da6fa1 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -169,6 +169,18 @@  void cpu_loop (CPUSPARCState *env)
         case 0x110:
         case 0x16d:
 #endif
+            /*
+             * Before copying/adjusting registers for parent/child,
+             * flush the register windows to the stack.
+             */
+            switch (env->gregs[1]) {
+            case TARGET_NR_fork:
+            case TARGET_NR_vfork:
+            case TARGET_NR_clone:
+                flush_windows(env);
+                break;
+            }
+
             ret = do_syscall (env, env->gregs[1],
                               env->regwptr[0], env->regwptr[1],
                               env->regwptr[2], env->regwptr[3],