arm: Implement some missing syscalls (SE mode)

Adding a few syscalls that were previously considered unimplemented.
This commit is contained in:
Giacomo Gabrielli 2015-05-26 03:21:35 -04:00
parent 0cc350d2c5
commit cc2346e8ca
3 changed files with 53 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2011-2012 ARM Limited * Copyright (c) 2010, 2011-2012, 2015 ARM Limited
* All rights reserved * All rights reserved
* *
* The license below extends only to copyright in the software and shall * The license below extends only to copyright in the software and shall
@ -108,6 +108,11 @@ class ArmLinux32 : public Linux
int32_t tv_usec; //!< microseconds int32_t tv_usec; //!< microseconds
}; };
struct timespec {
int32_t tv_sec; //!< seconds
int32_t tv_nsec; //!< nanoseconds
};
// For writev/readv // For writev/readv
struct tgt_iovec { struct tgt_iovec {
uint32_t iov_base; // void * uint32_t iov_base; // void *
@ -297,6 +302,11 @@ class ArmLinux64 : public Linux
int64_t tv_usec; //!< microseconds int64_t tv_usec; //!< microseconds
}; };
struct timespec {
int64_t tv_sec; //!< seconds
int64_t tv_nsec; //!< nanoseconds
};
// For writev/readv // For writev/readv
struct tgt_iovec { struct tgt_iovec {
uint64_t iov_base; // void * uint64_t iov_base; // void *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010-2013 ARM Limited * Copyright (c) 2010-2013, 2015 ARM Limited
* All rights reserved * All rights reserved
* *
* The license below extends only to copyright in the software and shall * The license below extends only to copyright in the software and shall
@ -382,7 +382,7 @@ static SyscallDesc syscallDescs32[] = {
/* 260 */ SyscallDesc("timer_getoverrun", unimplementedFunc), /* 260 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
/* 261 */ SyscallDesc("timer_delete", unimplementedFunc), /* 261 */ SyscallDesc("timer_delete", unimplementedFunc),
/* 262 */ SyscallDesc("clock_settime", unimplementedFunc), /* 262 */ SyscallDesc("clock_settime", unimplementedFunc),
/* 263 */ SyscallDesc("clock_gettime", unimplementedFunc), /* 263 */ SyscallDesc("clock_gettime", clock_gettimeFunc<ArmLinux32>),
/* 264 */ SyscallDesc("clock_getres", unimplementedFunc), /* 264 */ SyscallDesc("clock_getres", unimplementedFunc),
/* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc), /* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
/* 266 */ SyscallDesc("statfs64", unimplementedFunc), /* 266 */ SyscallDesc("statfs64", unimplementedFunc),
@ -526,7 +526,7 @@ static SyscallDesc syscallDescs64[] = {
/* 35 */ SyscallDesc("unlinkat", unlinkatFunc<ArmLinux64>), /* 35 */ SyscallDesc("unlinkat", unlinkatFunc<ArmLinux64>),
/* 36 */ SyscallDesc("symlinkat", unimplementedFunc), /* 36 */ SyscallDesc("symlinkat", unimplementedFunc),
/* 37 */ SyscallDesc("linkat", unimplementedFunc), /* 37 */ SyscallDesc("linkat", unimplementedFunc),
/* 38 */ SyscallDesc("renameat", unimplementedFunc), /* 38 */ SyscallDesc("renameat", renameatFunc<ArmLinux64>),
/* 39 */ SyscallDesc("umount2", unimplementedFunc), /* 39 */ SyscallDesc("umount2", unimplementedFunc),
/* 40 */ SyscallDesc("mount", unimplementedFunc), /* 40 */ SyscallDesc("mount", unimplementedFunc),
/* 41 */ SyscallDesc("pivot_root", unimplementedFunc), /* 41 */ SyscallDesc("pivot_root", unimplementedFunc),
@ -601,7 +601,7 @@ static SyscallDesc syscallDescs64[] = {
/* 110 */ SyscallDesc("timer_settime", unimplementedFunc), /* 110 */ SyscallDesc("timer_settime", unimplementedFunc),
/* 111 */ SyscallDesc("timer_delete", unimplementedFunc), /* 111 */ SyscallDesc("timer_delete", unimplementedFunc),
/* 112 */ SyscallDesc("clock_settime", unimplementedFunc), /* 112 */ SyscallDesc("clock_settime", unimplementedFunc),
/* 113 */ SyscallDesc("clock_gettime", unimplementedFunc), /* 113 */ SyscallDesc("clock_gettime", clock_gettimeFunc<ArmLinux64>),
/* 114 */ SyscallDesc("clock_getres", unimplementedFunc), /* 114 */ SyscallDesc("clock_getres", unimplementedFunc),
/* 115 */ SyscallDesc("clock_nanosleep", unimplementedFunc), /* 115 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
/* 116 */ SyscallDesc("syslog", unimplementedFunc), /* 116 */ SyscallDesc("syslog", unimplementedFunc),
@ -1521,7 +1521,7 @@ static SyscallDesc syscallDescs64[] = {
/* 1030 */ SyscallDesc("mkdir", mkdirFunc), /* 1030 */ SyscallDesc("mkdir", mkdirFunc),
/* 1031 */ SyscallDesc("rmdir", unimplementedFunc), /* 1031 */ SyscallDesc("rmdir", unimplementedFunc),
/* 1032 */ SyscallDesc("lchown", unimplementedFunc), /* 1032 */ SyscallDesc("lchown", unimplementedFunc),
/* 1033 */ SyscallDesc("access", unimplementedFunc), /* 1033 */ SyscallDesc("access", accessFunc),
/* 1034 */ SyscallDesc("rename", renameFunc), /* 1034 */ SyscallDesc("rename", renameFunc),
/* 1035 */ SyscallDesc("readlink", readlinkFunc), /* 1035 */ SyscallDesc("readlink", readlinkFunc),
/* 1036 */ SyscallDesc("symlink", unimplementedFunc), /* 1036 */ SyscallDesc("symlink", unimplementedFunc),

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012-2013 ARM Limited * Copyright (c) 2012-2013, 2015 ARM Limited
* Copyright (c) 2015 Advanced Micro Devices, Inc. * Copyright (c) 2015 Advanced Micro Devices, Inc.
* All rights reserved * All rights reserved
* *
@ -715,6 +715,42 @@ readlinkatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return readlinkFunc(desc, callnum, process, tc, 1); return readlinkFunc(desc, callnum, process, tc, 1);
} }
/// Target renameat() handler.
template <class OS>
SyscallReturn
renameatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
int index = 0;
int olddirfd = process->getSyscallArg(tc, index);
if (olddirfd != OS::TGT_AT_FDCWD)
warn("renameat: first argument not AT_FDCWD; unlikely to work");
std::string old_name;
if (!tc->getMemProxy().tryReadString(old_name,
process->getSyscallArg(tc, index)))
return -EFAULT;
int newdirfd = process->getSyscallArg(tc, index);
if (newdirfd != OS::TGT_AT_FDCWD)
warn("renameat: third argument not AT_FDCWD; unlikely to work");
std::string new_name;
if (!tc->getMemProxy().tryReadString(new_name,
process->getSyscallArg(tc, index)))
return -EFAULT;
// Adjust path for current working directory
old_name = process->fullPath(old_name);
new_name = process->fullPath(new_name);
int result = rename(old_name.c_str(), new_name.c_str());
return (result == -1) ? -errno : result;
}
/// Target sysinfo() handler. /// Target sysinfo() handler.
template <class OS> template <class OS>
SyscallReturn SyscallReturn