arch-arm, sim-se: Fix incorrect SP handling in clone
authorAndreas Sandberg <andreas.sandberg@arm.com>
Wed, 9 Jan 2019 15:52:51 +0000 (15:52 +0000)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Thu, 10 Jan 2019 17:55:42 +0000 (17:55 +0000)
The clone syscall is currently broken on aarch64 since the aarch64
code uses an incorrect SP register. Fix this by storing the new stack
pointer in SP_EL0 instead of R13.

Change-Id: Ie17990b4f359608e3b53e5bf625eca53769a6653
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Cc: Giacomo Travaglini <giacomo.travaglini@arm.com>
Cc: Javier Setoain <javier.setoain@arm.com>
Cc: Brandon Potter <Brandon.Potter@amd.com>
Reviewed-on: https://gem5-review.googlesource.com/c/15436
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Brandon Potter <Brandon.Potter@amd.com>

src/arch/arm/linux/linux.hh

index 9e9ca1f809862722495ae6d1257bfa032d6d8066..e1f27a761ee1c9590f1b4cbd02211892731e4130 100644 (file)
@@ -58,9 +58,6 @@ class ArmLinux : public Linux
               uint64_t stack, uint64_t tls)
     {
         ArmISA::copyRegs(ptc, ctc);
-
-        if (stack)
-            ctc->setIntReg(TheISA::StackPointerReg, stack);
     }
 };
 
@@ -271,6 +268,18 @@ class ArmLinux32 : public ArmLinux
         int32_t tms_cutime;     //!< user time of children
         int32_t tms_cstime;     //!< system time of children
     };
+
+    static void
+    archClone(uint64_t flags,
+              Process *pp, Process *cp,
+              ThreadContext *ptc, ThreadContext *ctc,
+              uint64_t stack, uint64_t tls)
+    {
+        ArmLinux::archClone(flags, pp, cp, ptc, ctc, stack, tls);
+
+        if (stack)
+            ctc->setIntReg(ArmISA::INTREG_SP, stack);
+    }
 };
 
 class ArmLinux64 : public ArmLinux
@@ -516,6 +525,17 @@ class ArmLinux64 : public ArmLinux
         int64_t tms_cutime;     //!< user time of children
         int64_t tms_cstime;     //!< system time of children
     };
+
+    static void archClone(uint64_t flags,
+                          Process *pp, Process *cp,
+                          ThreadContext *ptc, ThreadContext *ctc,
+                          uint64_t stack, uint64_t tls)
+    {
+        ArmLinux::archClone(flags, pp, cp, ptc, ctc, stack, tls);
+
+        if (stack)
+            ctc->setIntReg(ArmISA::INTREG_SP0, stack);
+    }
 };
 
 #endif