From 0b68475b102a9ecc769d1a3493a34055e08c2e7e Mon Sep 17 00:00:00 2001 From: Tony Gutierrez Date: Thu, 4 Aug 2016 12:32:21 -0400 Subject: [PATCH] x86, sim: add some syscalls to X86 this patch adds an implementation for the pwrite64 syscall and enables it for x86_64, and enables fstatfs for x86_64. --- src/arch/x86/linux/process.cc | 4 ++-- src/sim/syscall_emul.hh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index 665815c30..08137b943 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -236,7 +236,7 @@ static SyscallDesc syscallDescs64[] = { /* 15 */ SyscallDesc("rt_sigreturn", unimplementedFunc), /* 16 */ SyscallDesc("ioctl", ioctlFunc), /* 17 */ SyscallDesc("pread64", unimplementedFunc), - /* 18 */ SyscallDesc("pwrite64", unimplementedFunc), + /* 18 */ SyscallDesc("pwrite64", pwrite64Func), /* 19 */ SyscallDesc("readv", unimplementedFunc), /* 20 */ SyscallDesc("writev", writevFunc), /* 21 */ SyscallDesc("access", ignoreFunc), @@ -356,7 +356,7 @@ static SyscallDesc syscallDescs64[] = { /* 135 */ SyscallDesc("personality", unimplementedFunc), /* 136 */ SyscallDesc("ustat", unimplementedFunc), /* 137 */ SyscallDesc("statfs", unimplementedFunc), - /* 138 */ SyscallDesc("fstatfs", unimplementedFunc), + /* 138 */ SyscallDesc("fstatfs", fstatfsFunc), /* 139 */ SyscallDesc("sysfs", unimplementedFunc), /* 140 */ SyscallDesc("getpriority", unimplementedFunc), /* 141 */ SyscallDesc("setpriority", unimplementedFunc), diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index e9ed130f0..906a01edb 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1389,6 +1389,28 @@ mmapImpl(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc, return start; } +template +SyscallReturn +pwrite64Func(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) +{ + int index = 0; + int tgt_fd = p->getSyscallArg(tc, index); + Addr bufPtr = p->getSyscallArg(tc, index); + int nbytes = p->getSyscallArg(tc, index); + int offset = p->getSyscallArg(tc, index); + + int sim_fd = p->getSimFD(tgt_fd); + if (sim_fd < 0) + return -EBADF; + + BufferArg bufArg(bufPtr, nbytes); + bufArg.copyIn(tc->getMemProxy()); + + int bytes_written = pwrite64(sim_fd, bufArg.bufferPtr(), nbytes, offset); + + return (bytes_written == -1) ? -errno : bytes_written; +} + /// Target mmap() handler. template SyscallReturn -- 2.30.2