/* 117 */ { "ipc" },
/* 118 */ { "fsync" },
/* 119 */ { "sigreturn" },
- /* 120 */ { "clone", cloneFunc<ArmLinux32> },
+ /* 120 */ { "clone", cloneBackwardsFunc<ArmLinux32> },
/* 121 */ { "setdomainname" },
/* 122 */ { "uname", unameFunc32 },
/* 123 */ { "unused#123" },
/* 217 */ { "add_key" },
/* 218 */ { "request_key" },
/* 219 */ { "keyctl" },
- /* 220 */ { "clone", cloneFunc<ArmLinux64> },
+ /* 220 */ { "clone", cloneBackwardsFunc<ArmLinux64> },
/* 221 */ { "execve", execveFunc<ArmLinux64> },
/* 222 */ { "mmap2", mmapFunc<ArmLinux64> },
/* 223 */ { "fadvise64_64" },
{217, { "add_key" }},
{218, { "request_key" }},
{219, { "keyctl" }},
- {220, { "clone", cloneFunc<RiscvLinux64> }},
+ {220, { "clone", cloneBackwardsFunc<RiscvLinux64> }},
{221, { "execve", execveFunc<RiscvLinux64> }},
{222, { "mmap", mmapFunc<RiscvLinux64> }},
{223, { "fadvise64" }},
{217, { "add_key" }},
{218, { "request_key" }},
{219, { "keyctl" }},
- {220, { "clone", cloneFunc<RiscvLinux32> }},
+ {220, { "clone", cloneBackwardsFunc<RiscvLinux32> }},
{221, { "execve", execveFunc<RiscvLinux32> }},
{222, { "mmap", mmapFunc<RiscvLinux32> }},
{223, { "fadvise64" }},
template <class OS>
SyscallReturn
-cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
+cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
+ RegVal flags, RegVal newStack, Addr ptidPtr,
+ Addr ctidPtr, Addr tlsPtr)
{
- int index = 0;
-
auto p = tc->getProcessPtr();
- RegVal flags = p->getSyscallArg(tc, index);
- RegVal newStack = p->getSyscallArg(tc, index);
- Addr ptidPtr = p->getSyscallArg(tc, index);
-
-#if THE_ISA == RISCV_ISA or THE_ISA == ARM_ISA
- /**
- * Linux sets CLONE_BACKWARDS flag for RISC-V and Arm.
- * The flag defines the list of clone() arguments in the following
- * order: flags -> newStack -> ptidPtr -> tlsPtr -> ctidPtr
- */
- Addr tlsPtr = p->getSyscallArg(tc, index);
- Addr ctidPtr = p->getSyscallArg(tc, index);
-#else
- Addr ctidPtr = p->getSyscallArg(tc, index);
- Addr tlsPtr = p->getSyscallArg(tc, index);
-#endif
if (((flags & OS::TGT_CLONE_SIGHAND)&& !(flags & OS::TGT_CLONE_VM)) ||
((flags & OS::TGT_CLONE_THREAD) && !(flags & OS::TGT_CLONE_SIGHAND)) ||
return cp->pid();
}
+template <class OS>
+SyscallReturn
+cloneBackwardsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
+ RegVal flags, RegVal newStack, Addr ptidPtr,
+ Addr tlsPtr, Addr ctidPtr)
+{
+ return cloneFunc<OS>(desc, callnum, tc, flags, newStack, ptidPtr,
+ ctidPtr, tlsPtr);
+}
+
/// Target fstatfs() handler.
template <class OS>
SyscallReturn