summaryrefslogtreecommitdiff
path: root/src/arch/x86/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/linux')
-rw-r--r--src/arch/x86/linux/linux.hh20
-rw-r--r--src/arch/x86/linux/syscalls.cc42
2 files changed, 51 insertions, 11 deletions
diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index bde7925a9..8a78d5320 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -87,16 +87,16 @@ class X86Linux64 : public Linux
static OpenFlagTransTable openFlagTable[];
- static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
- static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
- static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
- static const int TGT_O_NONBLOCK = 0x00004000; //!< O_NONBLOCK
- static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
- static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT
- static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC
- static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL
- static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY
- static const int TGT_O_SYNC = 0x00002000; //!< O_SYNC
+ static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
+ static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
+ static const int TGT_O_RDWR = 00000002; //!< O_RDWR
+ static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
+ static const int TGT_O_APPEND = 00002000; //!< O_APPEND
+ static const int TGT_O_CREAT = 00000100; //!< O_CREAT
+ static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
+ static const int TGT_O_EXCL = 00000200; //!< O_EXCL
+ static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
+ static const int TGT_O_SYNC = 00010000; //!< O_SYNC
// static const int TGT_O_DRD = 0x00010000; //!< O_DRD
// static const int TGT_O_DIRECTIO = 0x00020000; //!< O_DIRECTIO
// static const int TGT_O_CACHE = 0x00002000; //!< O_CACHE
diff --git a/src/arch/x86/linux/syscalls.cc b/src/arch/x86/linux/syscalls.cc
index efbe33dfa..1146af708 100644
--- a/src/arch/x86/linux/syscalls.cc
+++ b/src/arch/x86/linux/syscalls.cc
@@ -57,6 +57,7 @@
#include "arch/x86/linux/process.hh"
#include "arch/x86/linux/linux.hh"
+#include "arch/x86/miscregs.hh"
#include "kern/linux/linux.hh"
#include "sim/syscall_emul.hh"
@@ -80,6 +81,45 @@ unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return 0;
}
+static SyscallReturn
+archPrctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+ ThreadContext *tc)
+{
+ enum ArchPrctlCodes
+ {
+ SetFS = 0x1002,
+ GetFS = 0x1003,
+ SetGS = 0x1001,
+ GetGS = 0x1004
+ };
+
+ //First argument is the code, second is the address
+ int code = tc->getSyscallArg(0);
+ uint64_t addr = tc->getSyscallArg(1);
+ uint64_t fsBase, gsBase;
+ TranslatingPort *p = tc->getMemPort();
+ switch(code)
+ {
+ //Each of these valid options should actually check addr.
+ case SetFS:
+ tc->setMiscRegNoEffect(MISCREG_FS_BASE, addr);
+ return 0;
+ case GetFS:
+ fsBase = tc->readMiscRegNoEffect(MISCREG_FS_BASE);
+ p->write(addr, fsBase);
+ return 0;
+ case SetGS:
+ tc->setMiscRegNoEffect(MISCREG_GS_BASE, addr);
+ return 0;
+ case GetGS:
+ gsBase = tc->readMiscRegNoEffect(MISCREG_GS_BASE);
+ p->write(addr, gsBase);
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
SyscallDesc X86LinuxProcess::syscallDescs[] = {
/* 0 */ SyscallDesc("read", readFunc),
/* 1 */ SyscallDesc("write", writeFunc),
@@ -239,7 +279,7 @@ SyscallDesc X86LinuxProcess::syscallDescs[] = {
/* 155 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 156 */ SyscallDesc("_sysctl", unimplementedFunc),
/* 157 */ SyscallDesc("prctl", unimplementedFunc),
- /* 158 */ SyscallDesc("arch_prctl", unimplementedFunc),
+ /* 158 */ SyscallDesc("arch_prctl", archPrctlFunc),
/* 159 */ SyscallDesc("adjtimex", unimplementedFunc),
/* 160 */ SyscallDesc("setrlimit", unimplementedFunc),
/* 161 */ SyscallDesc("chroot", unimplementedFunc),