syscall_emul.hh (12416:3c2a005993a0) syscall_emul.hh (12426:bd598b155482)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 1227 unchanged lines hidden (view full) ---

1236 return 0;
1237}
1238
1239template <class OS>
1240SyscallReturn
1241cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
1242{
1243 int index = 0;
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 1227 unchanged lines hidden (view full) ---

1236 return 0;
1237}
1238
1239template <class OS>
1240SyscallReturn
1241cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
1242{
1243 int index = 0;
1244
1244 TheISA::IntReg flags = p->getSyscallArg(tc, index);
1245 TheISA::IntReg newStack = p->getSyscallArg(tc, index);
1246 Addr ptidPtr = p->getSyscallArg(tc, index);
1245 TheISA::IntReg flags = p->getSyscallArg(tc, index);
1246 TheISA::IntReg newStack = p->getSyscallArg(tc, index);
1247 Addr ptidPtr = p->getSyscallArg(tc, index);
1248
1249#if THE_ISA == RISCV_ISA
1250 /**
1251 * Linux kernel 4.15 sets CLONE_BACKWARDS flag for RISC-V.
1252 * The flag defines the list of clone() arguments in the following
1253 * order: flags -> newStack -> ptidPtr -> tlsPtr -> ctidPtr
1254 */
1255 Addr tlsPtr M5_VAR_USED = p->getSyscallArg(tc, index);
1247 Addr ctidPtr = p->getSyscallArg(tc, index);
1256 Addr ctidPtr = p->getSyscallArg(tc, index);
1257#else
1258 Addr ctidPtr = p->getSyscallArg(tc, index);
1248 Addr tlsPtr M5_VAR_USED = p->getSyscallArg(tc, index);
1259 Addr tlsPtr M5_VAR_USED = p->getSyscallArg(tc, index);
1260#endif
1249
1250 if (((flags & OS::TGT_CLONE_SIGHAND)&& !(flags & OS::TGT_CLONE_VM)) ||
1251 ((flags & OS::TGT_CLONE_THREAD) && !(flags & OS::TGT_CLONE_SIGHAND)) ||
1252 ((flags & OS::TGT_CLONE_FS) && (flags & OS::TGT_CLONE_NEWNS)) ||
1253 ((flags & OS::TGT_CLONE_NEWIPC) && (flags & OS::TGT_CLONE_SYSVSEM)) ||
1254 ((flags & OS::TGT_CLONE_NEWPID) && (flags & OS::TGT_CLONE_THREAD)) ||
1255 ((flags & OS::TGT_CLONE_VM) && !(newStack)))
1256 return -EINVAL;

--- 78 unchanged lines hidden (view full) ---

1335 ctc->setIntReg(TheISA::NumIntArchRegs + 3, TheISA::NWindows - 2);
1336 ctc->setIntReg(TheISA::NumIntArchRegs + 5, TheISA::NWindows);
1337 ctc->setMiscReg(TheISA::MISCREG_CWP, 0);
1338 ctc->setIntReg(TheISA::NumIntArchRegs + 7, 0);
1339 ctc->setMiscRegNoEffect(TheISA::MISCREG_TL, 0);
1340 ctc->setMiscReg(TheISA::MISCREG_ASI, TheISA::ASI_PRIMARY);
1341 for (int y = 8; y < 32; y++)
1342 ctc->setIntReg(y, tc->readIntReg(y));
1261
1262 if (((flags & OS::TGT_CLONE_SIGHAND)&& !(flags & OS::TGT_CLONE_VM)) ||
1263 ((flags & OS::TGT_CLONE_THREAD) && !(flags & OS::TGT_CLONE_SIGHAND)) ||
1264 ((flags & OS::TGT_CLONE_FS) && (flags & OS::TGT_CLONE_NEWNS)) ||
1265 ((flags & OS::TGT_CLONE_NEWIPC) && (flags & OS::TGT_CLONE_SYSVSEM)) ||
1266 ((flags & OS::TGT_CLONE_NEWPID) && (flags & OS::TGT_CLONE_THREAD)) ||
1267 ((flags & OS::TGT_CLONE_VM) && !(newStack)))
1268 return -EINVAL;

--- 78 unchanged lines hidden (view full) ---

1347 ctc->setIntReg(TheISA::NumIntArchRegs + 3, TheISA::NWindows - 2);
1348 ctc->setIntReg(TheISA::NumIntArchRegs + 5, TheISA::NWindows);
1349 ctc->setMiscReg(TheISA::MISCREG_CWP, 0);
1350 ctc->setIntReg(TheISA::NumIntArchRegs + 7, 0);
1351 ctc->setMiscRegNoEffect(TheISA::MISCREG_TL, 0);
1352 ctc->setMiscReg(TheISA::MISCREG_ASI, TheISA::ASI_PRIMARY);
1353 for (int y = 8; y < 32; y++)
1354 ctc->setIntReg(y, tc->readIntReg(y));
1343#elif THE_ISA == ARM_ISA or THE_ISA == X86_ISA
1355#elif THE_ISA == ARM_ISA or THE_ISA == X86_ISA or THE_ISA == RISCV_ISA
1344 TheISA::copyRegs(tc, ctc);
1345#endif
1346
1347#if THE_ISA == X86_ISA
1348 if (flags & OS::TGT_CLONE_SETTLS) {
1349 ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_BASE, tlsPtr);
1350 ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_EFF_BASE, tlsPtr);
1351 }

--- 711 unchanged lines hidden ---
1356 TheISA::copyRegs(tc, ctc);
1357#endif
1358
1359#if THE_ISA == X86_ISA
1360 if (flags & OS::TGT_CLONE_SETTLS) {
1361 ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_BASE, tlsPtr);
1362 ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_EFF_BASE, tlsPtr);
1363 }

--- 711 unchanged lines hidden ---