diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-01-09 14:50:27 +0000 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-01-10 17:55:42 +0000 |
commit | 0a36956261c67d61def90e1aefeb6c46568ff167 (patch) | |
tree | 5f6d72f83185698d45e1f4b3eba1537f1c370167 /src/arch/x86/linux/linux.hh | |
parent | 13daa2e0620e71a1c11f94d1f8a864f73a52b94d (diff) | |
download | gem5-0a36956261c67d61def90e1aefeb6c46568ff167.tar.xz |
sim-se: Refactor clone to avoid most ifdefs
Some parts of clone are architecture dependent. In some cases, we are
able to use architecture-specific helper functions or register
aliases. However, there is still some architecture-specific that is
protected by ifdefs in the common clone implementation.
Move these architecture-specific bits to the architecture-specific OS
class instead to avoid these ifdefs and make the code a bit more
readable.
Change-Id: Ia0903d738d0ba890863bddfa77e3b717db7f45de
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/15435
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Brandon Potter <Brandon.Potter@amd.com>
Diffstat (limited to 'src/arch/x86/linux/linux.hh')
-rw-r--r-- | src/arch/x86/linux/linux.hh | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh index ef0715fd6..91498043c 100644 --- a/src/arch/x86/linux/linux.hh +++ b/src/arch/x86/linux/linux.hh @@ -40,9 +40,31 @@ #ifndef __ARCH_X86_LINUX_LINUX_HH__ #define __ARCH_X86_LINUX_LINUX_HH__ +#include "arch/x86/utility.hh" #include "kern/linux/linux.hh" -class X86Linux64 : public Linux +class X86Linux : public Linux +{ + public: + static void + archClone(uint64_t flags, + Process *pp, Process *cp, + ThreadContext *ptc, ThreadContext *ctc, + uint64_t stack, uint64_t tls) + { + X86ISA::copyRegs(ptc, ctc); + + if (flags & TGT_CLONE_SETTLS) { + ctc->setMiscRegNoEffect(X86ISA::MISCREG_FS_BASE, tls); + ctc->setMiscRegNoEffect(X86ISA::MISCREG_FS_EFF_BASE, tls); + } + + if (stack) + ctc->setIntReg(X86ISA::StackPointerReg, stack); + } +}; + +class X86Linux64 : public X86Linux { public: @@ -185,7 +207,7 @@ class X86Linux64 : public Linux }; -class X86Linux32 : public Linux +class X86Linux32 : public X86Linux { public: |