53 using namespace X86ISA;
63 strcpy(
name->sysname,
"Linux");
64 strcpy(
name->nodename,
"sim.gem5.org");
65 strcpy(
name->release,
"3.0.0");
66 strcpy(
name->version,
"#1 Mon Aug 18 11:32:15 EDT 2003");
67 strcpy(
name->machine,
"x86_64");
90 uint64_t fsBase, gsBase;
101 p.
write(addr, fsBase);
109 p.
write(addr, gsBase);
117 Bitfield<0> seg_32bit;
126 uint32_t entry_number;
144 const int minTLSEntry = 6;
145 const int numTLSEntries = 3;
146 const int maxTLSEntry = minTLSEntry + numTLSEntries - 1;
151 assert((maxTLSEntry + 1) *
sizeof(uint64_t) <= x86p->
gdtSize());
156 gdt(x86p->
gdtStart() + minTLSEntry *
sizeof(uint64_t),
157 numTLSEntries *
sizeof(uint64_t));
163 panic(
"Failed to copy in GDT for %s.\n", desc->
name());
165 if (userDesc->entry_number == (uint32_t)(-1)) {
167 for (
int i = 0;
i < numTLSEntries;
i++) {
169 userDesc->entry_number =
i + minTLSEntry;
174 if (userDesc->entry_number == (uint32_t)(-1))
178 int index = userDesc->entry_number;
180 if (index < minTLSEntry || index > maxTLSEntry)
183 index -= minTLSEntry;
186 SegDescriptor segDesc = 0;
187 UserDescFlags flags = userDesc->flags;
189 segDesc.limitLow =
bits(userDesc->limit, 15, 0);
190 segDesc.baseLow =
bits(userDesc->base_addr, 23, 0);
192 if (!flags.read_exec_only)
194 if (
bits((uint8_t)flags.contents, 0))
196 if (
bits((uint8_t)flags.contents, 1))
197 segDesc.type.codeOrData = 1;
200 if (!flags.seg_not_present)
202 segDesc.limitHigh =
bits(userDesc->limit, 19, 16);
208 if (flags.limit_in_pages)
210 segDesc.baseHigh =
bits(userDesc->base_addr, 31, 24);
212 gdt[
index] = (uint64_t)segDesc;
217 panic(
"Failed to copy out GDT for %s.\n", desc->
name());
319 SyscallDesc(
"gettimeofday", gettimeofdayFunc<X86Linux64>),
320 SyscallDesc(
"getrlimit", getrlimitFunc<X86Linux64>),
321 SyscallDesc(
"getrusage", getrusageFunc<X86Linux64>),
451 SyscallDesc(
"clock_gettime", clock_gettimeFunc<X86Linux64>),
452 SyscallDesc(
"clock_getres", clock_getresFunc<X86Linux64>),
539 X86_64LinuxProcess::X86_64LinuxProcess(ProcessParams * params,
628 SyscallDesc(
"getrlimit", getrlimitFunc<X86Linux32>),
629 SyscallDesc(
"getrusage", getrusageFunc<X86Linux32>),
817 SyscallDesc(
"clock_gettime", clock_gettimeFunc<X86Linux32>),
SyscallReturn ftruncateFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target ftruncate() handler.
SyscallReturn brkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target brk() handler: set brk address.
const std::string & name()
EndBitUnion(UserDescFlags) struct UserDesc32
SyscallReturn fallocateFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
SyscallReturn dupFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
FIXME: The file description is not shared among file descriptors created with dup.
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, TheISA::IntReg flags)
SyscallReturn getcwdFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target getcwd() handler.
static SyscallReturn archPrctlFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
void write(Addr address, T data) const
Write object T to address.
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
SyscallReturn ignoreFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling, etc.) and should not affect the correct behavior of the program.
SyscallReturn setTidAddressFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target set_tid_address() handler.
SyscallReturn getppidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target getppid() handler.
Bitfield< 2, 1 > contents
SyscallReturn readlinkFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i)=0
SyscallReturn getpidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target getpid() handler.
TypedBufferArg is a class template; instances of this template represent typed buffers in target user...
ThreadContext is the external interface to all thread state for anything outside of the CPU...
SyscallReturn truncate64Func(SyscallDesc *desc, int num, Process *process, ThreadContext *tc)
Target truncate64() handler.
SyscallReturn getegidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target getegid() handler.
SyscallReturn _llseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target _llseek() handler.
SyscallReturn fcntlFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target fcntl() handler.
SyscallReturn munmapFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target munmap() handler.
SyscallReturn writeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target write() handler.
SyscallReturn unimplementedFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Handler for unimplemented syscalls that we haven't thought about.
Bitfield< 4 > limit_in_pages
SyscallReturn exitGroupFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
Target exit_group() handler: terminate simulation. (exit all threads)
SyscallReturn lseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target lseek() handler.
Bitfield< 3 > read_exec_only
SyscallReturn unlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
SyscallReturn gettidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target gettid() handler.
SyscallReturn geteuidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target geteuid() handler.
virtual SETranslatingPortProxy & getMemProxy()=0
Warn only once for unimplemented system calls.
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, TheISA::IntReg flags)
static SyscallReturn unameFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target uname() handler.
This class provides the wrapper interface for the system call implementations which are defined in th...
SyscallReturn truncateFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target truncate() handler.
SyscallReturn getgidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target getgid() handler.
SyscallReturn renameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target rename() handler.
SyscallReturn setpgidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target setpgid() handler.
This file defines objects used to emulate syscalls from the target application on the host machine...
SyscallReturn getuidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target getuid() handler.
SyscallReturn dup2Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target dup2() handler.
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, TheISA::IntReg flags)
SyscallReturn exitFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
Target exit() handler: terminate current context.
SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target ftruncate64() handler.
SyscallReturn closeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
Target close() handler.
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, TheISA::IntReg flags)
BitUnion32(UserDescFlags) Bitfield< 0 > seg_32bit
static SyscallReturn setThreadArea32Func(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
This class represents the return value from an emulated system call, including any errno setting...
Bitfield< 5 > seg_not_present
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)=0
static SyscallDesc syscallDescs64[]
SyscallReturn pipeFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
Target pipe() handler.
SyscallReturn readFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
static SyscallDesc syscallDescs32[]
I386LinuxProcess(ProcessParams *params, ObjectFile *objFile)
Constructor.