summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2016-03-17 10:25:53 -0700
committerBrandon Potter <brandon.potter@amd.com>2016-03-17 10:25:53 -0700
commit7eaa5952f994c07a801fbef81f8097a5e9a5828f (patch)
tree11d40da8b09eb843e44a392b9bddbbb25fd6035d /src/sim/syscall_emul.hh
parent9d8fec0d90c2121a092c04da74e3306069ab5270 (diff)
downloadgem5-7eaa5952f994c07a801fbef81f8097a5e9a5828f.tar.xz
syscall_emul: fix bugs for mmap2 system call and x86-32 syscalls
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 34fbc6618..a859fbe43 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1223,11 +1223,11 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return result;
}
-
-/// Target mmap() handler.
+/// Real mmap handler.
template <class OS>
SyscallReturn
-mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+mmapImpl(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
+ bool is_mmap2)
{
int index = 0;
Addr start = p->getSyscallArg(tc, index);
@@ -1237,9 +1237,8 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
int tgt_fd = p->getSyscallArg(tc, index);
int offset = p->getSyscallArg(tc, index);
- DPRINTF_SYSCALL(Verbose, "mmap(0x%x, len %d, prot %d, flags %d, fd %d, "
- "offs %d)\n", start, length, prot, tgt_flags, tgt_fd,
- offset);
+ if (is_mmap2)
+ offset *= TheISA::PageBytes;
if (start & (TheISA::PageBytes - 1) ||
offset & (TheISA::PageBytes - 1) ||
@@ -1363,6 +1362,22 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
return start;
}
+/// Target mmap() handler.
+template <class OS>
+SyscallReturn
+mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+{
+ return mmapImpl<OS>(desc, num, p, tc, false);
+}
+
+/// Target mmap2() handler.
+template <class OS>
+SyscallReturn
+mmap2Func(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+{
+ return mmapImpl<OS>(desc, num, p, tc, true);
+}
+
/// Target getrlimit() handler.
template <class OS>
SyscallReturn