Go to the documentation of this file.
32 #include <sys/syscall.h>
39 #include <unordered_map>
41 #include "arch/utility.hh"
44 #include "config/the_isa.hh"
62 warn(
"Cannot invoke %s on host operating system.", syscall_name);
68 fatal(
"syscall %s (#%d) unimplemented.", desc->
name(), desc->
num());
75 warn(
"ignoring syscall %s(...)", desc->
name());
82 static std::unordered_map<SyscallDesc *, bool> bool_map;
84 bool &warned = bool_map[desc];
86 warn(
"ignoring syscall %s(...)\n"
87 " (further warnings will be suppressed)", desc->
name());
116 *
p->exitGroup =
true;
118 if (
p->childClearTID)
121 bool last_thread =
true;
122 Process *parent =
nullptr, *tg_lead =
nullptr;
125 if (!(walk = sys->
threads[
i]->getProcessPtr()))
134 if (walk->
pid() ==
p->tgid())
147 if (walk->
tgid() ==
p->tgid()) {
160 if (*(
p->exitGroup)) {
176 if (*
p->sigchld && (
p->ppid() != 0) && (walk->
pid() ==
p->ppid()))
192 for (
int i = 0;
i <
p->fds->getSize();
i++) {
194 p->fds->closeFDEntry(
i);
204 int activeContexts = 0;
206 activeContexts +=
system->threads.numRunning();
208 if (activeContexts == 0) {
254 std::shared_ptr<MemState> mem_state =
p->memState;
255 Addr brk_point = mem_state->getBrkPoint();
259 if (new_brk == 0 || (new_brk == brk_point))
262 mem_state->updateBrkRegion(brk_point, new_brk);
265 mem_state->getBrkPoint());
267 return mem_state->getBrkPoint();
276 return process->pid();
283 return p->fds->closeFDEntry(tgt_fd);
288 int tgt_fd, uint64_t offs,
int whence)
292 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
295 int sim_fd = ffdp->getSimFD();
297 off_t result = lseek(sim_fd, offs, whence);
299 return (result == (off_t)-1) ? -errno : result;
305 int tgt_fd, uint64_t offset_high, uint32_t offset_low,
306 Addr result_ptr,
int whence)
310 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
313 int sim_fd = ffdp->getSimFD();
315 uint64_t
offset = (offset_high << 32) | offset_low;
317 uint64_t result = lseek(sim_fd,
offset, whence);
320 if (result == (off_t)-1)
323 BufferArg result_buf(result_ptr,
sizeof(result));
324 memcpy(result_buf.
bufferPtr(), &result,
sizeof(result));
345 p->memState->unmapRegion(start,
length);
355 Addr buf_ptr,
int name_len)
365 Addr buf_ptr,
unsigned long size)
372 string cwd =
p->tgtCwd;
374 if (cwd.length() >= size) {
378 strncpy((
char *)buf.
bufferPtr(), cwd.c_str(), size);
379 result = cwd.length();
381 if (getcwd((
char *)buf.
bufferPtr(), size)) {
382 result = strlen((
char *)buf.
bufferPtr());
390 return (result == -1) ? -errno : result;
395 Addr pathname,
Addr buf_ptr,
size_t bufsiz)
404 path =
p->checkPathRedirect(path);
409 if (path !=
"/proc/self/exe") {
410 result = readlink(path.c_str(), (
char *)buf.
bufferPtr(), bufsiz);
424 char real_path[PATH_MAX];
425 char *check_real_path = realpath(
p->progName(), real_path);
426 if (!check_real_path) {
427 fatal(
"readlink('/proc/self/exe') unable to resolve path to "
428 "executable: %s",
p->progName());
430 strncpy((
char*)buf.
bufferPtr(), real_path, bufsiz);
431 size_t real_path_len = strlen(real_path);
432 if (real_path_len > bufsiz) {
437 result = real_path_len;
441 warn_once(
"readlink() called on '/proc/self/exe' may yield unexpected "
442 "results in various settings.\n Returning '%s'\n",
448 return (result == -1) ? -errno : result;
460 path =
p->checkPathRedirect(path);
462 int result = unlink(path.c_str());
463 return (result == -1) ? -errno : result;
475 if (!virt_mem.tryReadString(path, pathname))
477 if (!virt_mem.tryReadString(new_path, new_pathname))
480 path =
p->absolutePath(path,
true);
481 new_path =
p->absolutePath(new_path,
true);
483 int result = link(path.c_str(), new_path.c_str());
484 return (result == -1) ? -errno : result;
496 if (!virt_mem.tryReadString(path, pathname))
498 if (!virt_mem.tryReadString(new_path, new_pathname))
501 path =
p->absolutePath(path,
true);
502 new_path =
p->absolutePath(new_path,
true);
504 int result = symlink(path.c_str(), new_path.c_str());
505 return (result == -1) ? -errno : result;
516 path =
p->checkPathRedirect(path);
518 auto result = mkdir(path.c_str(),
mode);
519 return (result == -1) ? -errno : result;
536 old_name =
p->checkPathRedirect(old_name);
537 new_name =
p->checkPathRedirect(new_name);
539 int64_t result = rename(old_name.c_str(), new_name.c_str());
540 return (result == -1) ? -errno : result;
553 path =
p->checkPathRedirect(path);
555 int result = truncate(path.c_str(),
length);
556 return (result == -1) ? -errno : result;
564 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
567 int sim_fd = ffdp->getSimFD();
569 int result = ftruncate(sim_fd,
length);
570 return (result == -1) ? -errno : result;
587 int result = truncate(path.c_str(),
length);
589 int result = truncate64(path.c_str(),
length);
591 return (result == -1) ? -errno : result;
596 int tgt_fd, int64_t
length)
600 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
603 int sim_fd = ffdp->getSimFD();
606 int result = ftruncate(sim_fd,
length);
608 int result = ftruncate64(sim_fd,
length);
610 return (result == -1) ? -errno : result;
619 mode_t oldMask = umask(0);
626 Addr pathname, uint32_t owner, uint32_t group)
635 uid_t hostOwner = owner;
636 gid_t hostGroup = group;
639 path =
p->checkPathRedirect(path);
641 int result = chown(path.c_str(), hostOwner, hostGroup);
642 return (result == -1) ? -errno : result;
647 int tgt_fd, uint32_t owner, uint32_t group)
651 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
654 int sim_fd = ffdp->getSimFD();
657 uid_t hostOwner = owner;
658 gid_t hostGroup = group;
660 int result = fchown(sim_fd, hostOwner, hostGroup);
661 return (result == -1) ? -errno : result;
675 auto old_hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[tgt_fd]);
678 int sim_fd = old_hbfdp->getSimFD();
680 int result = dup(sim_fd);
684 auto new_hbfdp = std::dynamic_pointer_cast<HBFDEntry>(old_hbfdp->clone());
685 new_hbfdp->setSimFD(result);
686 new_hbfdp->setCOE(
false);
687 return p->fds->allocFD(new_hbfdp);
694 auto old_hbp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[old_tgt_fd]);
697 int old_sim_fd = old_hbp->getSimFD();
704 int res_fd = dup2(old_sim_fd, open(
"/dev/null", O_RDONLY));
708 auto new_hbp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[new_tgt_fd]);
710 p->fds->closeFDEntry(new_tgt_fd);
711 new_hbp = std::dynamic_pointer_cast<HBFDEntry>(old_hbp->clone());
712 new_hbp->setSimFD(res_fd);
713 new_hbp->setCOE(
false);
715 return p->fds->allocFD(new_hbp);
724 auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[tgt_fd]);
727 int sim_fd = hbfdp->getSimFD();
729 int coe = hbfdp->getCOE();
733 return coe & FD_CLOEXEC;
736 int arg = varargs.
get<
int>();
737 arg ? hbfdp->setCOE(
true) : hbfdp->setCOE(
false);
749 int arg = varargs.
get<
int>();
750 int rv = fcntl(sim_fd, cmd, arg);
751 return (rv == -1) ? -errno : rv;
755 warn(
"fcntl: unsupported command %d\n", cmd);
765 auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[tgt_fd]);
768 int sim_fd = hbfdp->getSimFD();
772 warn(
"fcntl64(%d, F_GETLK64) not supported, error returned\n", tgt_fd);
777 warn(
"fcntl64(%d, F_SETLK(W)64) not supported, error returned\n",
784 warn(
"fcntl64(%d, %d) passed through to host\n", tgt_fd, cmd);
785 return fcntl(sim_fd, cmd);
806 int sim_fds[2], tgt_fds[2];
808 int pipe_retval = pipe(sim_fds);
809 if (pipe_retval == -1)
812 auto rend = PipeFDEntry::EndType::read;
813 auto rpfd = std::make_shared<PipeFDEntry>(sim_fds[0], O_WRONLY, rend);
814 tgt_fds[0] =
p->fds->allocFD(rpfd);
815 int sim_fd_rpfd = rpfd->getSimFD();
817 auto wend = PipeFDEntry::EndType::write;
818 auto wpfd = std::make_shared<PipeFDEntry>(sim_fds[1], O_RDONLY, wend);
819 tgt_fds[1] =
p->fds->allocFD(wpfd);
820 int sim_fd_wpfd = wpfd->getSimFD();
826 rpfd->setPipeReadSource(tgt_fds[1]);
840 BufferArg tgt_handle(tgt_addr,
sizeof(
int[2]));
841 int *buf_ptr = (
int*)tgt_handle.
bufferPtr();
842 buf_ptr[0] = tgt_fds[0];
843 buf_ptr[1] = tgt_fds[1];
849 if ((flags != O_CLOEXEC) && (flags != O_NONBLOCK) &&
850 (flags != (O_CLOEXEC | O_NONBLOCK))) {
858 if (flags & O_NONBLOCK) {
865 if (fcntl(sim_fd_rpfd, F_SETFL, O_NONBLOCK)) {
868 if (fcntl(sim_fd_wpfd, F_SETFL, O_NONBLOCK)) {
877 if (flags & O_CLOEXEC) {
890 return process->
pgid();
902 process->
pgid(process->pid());
910 for (
auto *tc: sysh->
threads) {
915 if (walk_ph && walk_ph->
pid() == process->pid())
916 matched_ph = walk_ph;
921 matched_ph->
pgid((pgid == 0) ? matched_ph->
pid() : pgid);
931 return process->
tgid();
938 return process->
pid();
945 return process->
ppid();
952 return process->
uid();
959 return process->
euid();
966 return process->
gid();
973 return process->
egid();
980 #if defined(__linux__)
983 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*
p->fds)[tgt_fd]);
986 int sim_fd = ffdp->getSimFD();
1008 path =
p->checkPathRedirect(path);
1010 int result = access(path.c_str(),
mode);
1011 return (result == -1) ? -errno : result;
1016 Addr pathname, mode_t
mode, dev_t dev)
1023 path =
p->checkPathRedirect(path);
1025 auto result = mknod(path.c_str(),
mode, dev);
1026 return (result == -1) ? -errno : result;
1037 std::string tgt_cwd;
1042 tgt_cwd = realpath((
p->tgtCwd +
"/" + path).c_str(), buf);
1044 std::string host_cwd =
p->checkPathRedirect(tgt_cwd);
1046 int result = chdir(host_cwd.c_str());
1051 p->hostCwd = host_cwd;
1052 p->tgtCwd = tgt_cwd;
1064 path =
p->checkPathRedirect(path);
1066 auto result = rmdir(path.c_str());
1067 return (result == -1) ? -errno : result;
1070 #if defined(SYS_getdents) || defined(SYS_getdents64)
1071 template<
typename DE,
int SYS_NUM>
1074 int tgt_fd,
Addr buf_ptr,
unsigned count)
1078 auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*
p->fds)[tgt_fd]);
1081 int sim_fd = hbfdp->getSimFD();
1084 auto status = syscall(SYS_NUM, sim_fd, buf_arg.bufferPtr(),
count);
1089 unsigned traversed = 0;
1090 while (traversed <
status) {
1091 DE *buffer = (DE*)((
Addr)buf_arg.bufferPtr() + traversed);
1093 auto host_reclen = buffer->d_reclen;
1101 buffer->d_ino =
htog(buffer->d_ino,
bo);
1102 buffer->d_off =
htog(buffer->d_off,
bo);
1103 buffer->d_reclen =
htog(buffer->d_reclen,
bo);
1105 traversed += host_reclen;
1113 #if defined(SYS_getdents)
1116 int tgt_fd,
Addr buf_ptr,
unsigned count)
1118 typedef struct linux_dirent {
1119 unsigned long d_ino;
1120 unsigned long d_off;
1121 unsigned short d_reclen;
1125 return getdentsImpl<LinDent, SYS_getdents>(desc, tc,
1126 tgt_fd, buf_ptr,
count);
1130 #if defined(SYS_getdents64)
1133 int tgt_fd,
Addr buf_ptr,
unsigned count)
1135 typedef struct linux_dirent64 {
1138 unsigned short d_reclen;
1142 return getdentsImpl<LinDent64, SYS_getdents64>(desc, tc,
1143 tgt_fd, buf_ptr,
count);
1152 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1155 int sim_fd = sfdp->getSimFD();
1157 int retval = shutdown(sim_fd, how);
1159 return (retval == -1) ? -errno : retval;
1164 int tgt_fd,
Addr buf_ptr,
int addrlen)
1171 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1174 int sim_fd = sfdp->getSimFD();
1176 int status = ::bind(sim_fd,
1188 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1191 int sim_fd = sfdp->getSimFD();
1193 int status = listen(sim_fd, backlog);
1200 int tgt_fd,
Addr buf_ptr,
int addrlen)
1207 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1210 int sim_fd = sfdp->getSimFD();
1212 int status = connect(sim_fd,
1213 (
struct sockaddr *)
addr.bufferPtr(),
1214 (socklen_t)addrlen);
1221 int tgt_fd,
Addr bufrPtr,
size_t bufrLen,
int flags,
1226 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1229 int sim_fd = sfdp->getSimFD();
1235 socklen_t addrLen = 0;
1236 if (addrlenPtr != 0) {
1238 BufferArg addrlenBuf(addrlenPtr,
sizeof(socklen_t));
1240 addrLen = *((socklen_t *)addrlenBuf.
bufferPtr());
1243 struct sockaddr
sa, *sap = NULL;
1247 memcpy(&
sa, (
struct sockaddr *)addrBuf.
bufferPtr(),
1248 sizeof(
struct sockaddr));
1252 ssize_t recvd_size = recvfrom(sim_fd,
1254 bufrLen, flags, sap, (socklen_t *)&addrLen);
1256 if (recvd_size == -1)
1271 BufferArg addrlenBuf(addrlenPtr,
sizeof(socklen_t));
1272 *(socklen_t *)addrlenBuf.
bufferPtr() = addrLen;
1281 int tgt_fd,
Addr bufrPtr,
size_t bufrLen,
int flags,
1282 Addr addrPtr, socklen_t addrLen)
1286 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1289 int sim_fd = sfdp->getSimFD();
1295 struct sockaddr
sa, *sap =
nullptr;
1296 memset(&
sa, 0,
sizeof(sockaddr));
1300 memcpy(&
sa, (sockaddr*)addrBuf.
bufferPtr(), addrLen);
1304 ssize_t sent_size = sendto(sim_fd,
1306 bufrLen, flags, sap, (socklen_t)addrLen);
1308 return (sent_size == -1) ? -errno : sent_size;
1313 int tgt_fd,
Addr msgPtr,
int flags)
1317 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1320 int sim_fd = sfdp->getSimFD();
1345 BufferArg msgBuf(msgPtr,
sizeof(
struct msghdr));
1347 struct msghdr *msgHdr = (
struct msghdr *)msgBuf.
bufferPtr();
1354 Addr msg_name_phold = 0;
1355 Addr msg_iov_phold = 0;
1356 Addr iovec_base_phold[msgHdr->msg_iovlen];
1357 Addr msg_control_phold = 0;
1363 if (msgHdr->msg_name) {
1364 msg_name_phold = (
Addr)msgHdr->msg_name;
1365 nameBuf =
new BufferArg(msg_name_phold, msgHdr->msg_namelen);
1367 msgHdr->msg_name = nameBuf->
bufferPtr();
1376 BufferArg *iovecBuf[msgHdr->msg_iovlen];
1377 for (
int i = 0;
i < msgHdr->msg_iovlen;
i++) {
1378 iovec_base_phold[
i] = 0;
1382 if (msgHdr->msg_iov) {
1383 msg_iov_phold = (
Addr)msgHdr->msg_iov;
1384 iovBuf =
new BufferArg(msg_iov_phold, msgHdr->msg_iovlen *
1385 sizeof(
struct iovec));
1387 for (
int i = 0;
i < msgHdr->msg_iovlen;
i++) {
1388 if (((
struct iovec *)iovBuf->
bufferPtr())[
i].iov_base) {
1389 iovec_base_phold[
i] =
1392 ((
struct iovec *)iovBuf->
bufferPtr())[
i].iov_len);
1394 ((
struct iovec *)iovBuf->
bufferPtr())[
i].iov_base =
1395 iovecBuf[
i]->bufferPtr();
1398 msgHdr->msg_iov = (
struct iovec *)iovBuf->
bufferPtr();
1405 if (msgHdr->msg_control) {
1406 msg_control_phold = (
Addr)msgHdr->msg_control;
1407 controlBuf =
new BufferArg(msg_control_phold,
1408 CMSG_ALIGN(msgHdr->msg_controllen));
1410 msgHdr->msg_control = controlBuf->
bufferPtr();
1413 ssize_t recvd_size = recvmsg(sim_fd, msgHdr, flags);
1418 if (msgHdr->msg_name) {
1421 msgHdr->msg_name = (
void *)msg_name_phold;
1424 if (msgHdr->msg_iov) {
1425 for (
int i = 0;
i< msgHdr->msg_iovlen;
i++) {
1426 if (((
struct iovec *)iovBuf->
bufferPtr())[
i].iov_base) {
1429 ((
struct iovec *)iovBuf->
bufferPtr())[
i].iov_base =
1430 (
void *)iovec_base_phold[
i];
1435 msgHdr->msg_iov = (
struct iovec *)msg_iov_phold;
1438 if (msgHdr->msg_control) {
1441 msgHdr->msg_control = (
void *)msg_control_phold;
1451 int tgt_fd,
Addr msgPtr,
int flags)
1455 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1458 int sim_fd = sfdp->getSimFD();
1463 BufferArg msgBuf(msgPtr,
sizeof(
struct msghdr));
1465 struct msghdr msgHdr = *((
struct msghdr *)msgBuf.
bufferPtr());
1471 struct iovec *iovPtr = msgHdr.msg_iov;
1472 BufferArg iovBuf((
Addr)iovPtr,
sizeof(
struct iovec) * msgHdr.msg_iovlen);
1474 struct iovec *iov = (
struct iovec *)iovBuf.
bufferPtr();
1475 msgHdr.msg_iov = iov;
1490 for (
int iovIndex = 0 ; iovIndex < msgHdr.msg_iovlen; iovIndex++) {
1491 Addr basePtr = (
Addr) iov[iovIndex].iov_base;
1492 bufferArray[iovIndex] =
new BufferArg(basePtr, iov[iovIndex].iov_len);
1494 iov[iovIndex].iov_base = bufferArray[iovIndex]->
bufferPtr();
1497 ssize_t sent_size = sendmsg(sim_fd, &msgHdr, flags);
1498 int local_errno = errno;
1503 for (
int iovIndex = 0 ; iovIndex < msgHdr.msg_iovlen; iovIndex++) {
1513 return (sent_size < 0) ? -local_errno : sent_size;
1518 int tgt_fd,
int level,
int optname,
Addr valPtr,
Addr lenPtr)
1524 struct linger linger_val;
1525 struct timeval timeval_val;
1530 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1533 int sim_fd = sfdp->getSimFD();
1535 socklen_t
len =
sizeof(
val);
1556 int tgt_fd,
Addr addrPtr,
Addr lenPtr)
1560 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1563 int sim_fd = sfdp->getSimFD();
1569 BufferArg lenBuf(lenPtr,
sizeof(socklen_t));
1593 int tgt_fd,
Addr sockAddrPtr,
Addr addrlenPtr)
1597 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1600 int sim_fd = sfdp->getSimFD();
1602 BufferArg bufAddrlen(addrlenPtr,
sizeof(
unsigned));
1606 int retval = getpeername(sim_fd,
1615 return (retval == -1) ? -errno : retval;
1620 int tgt_fd,
int level,
int optname,
Addr valPtr, socklen_t
len)
1627 auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*
p->fds)[tgt_fd]);
1630 int sim_fd = sfdp->getSimFD();
std::list< BasicSignal > signalList
#define fatal(...)
This implements a cprintf based fatal() function.
SyscallReturn connectFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr buf_ptr, int addrlen)
SyscallReturn geteuidFunc(SyscallDesc *desc, ThreadContext *tc)
Target geteuid() handler.
SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc, Addr start, size_t length)
Target munmap() handler.
SyscallReturn dupFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
FIXME: The file description is not shared among file descriptors created with dup.
SyscallReturn ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling,...
SyscallReturn getpeernameFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr)
int wakeup(Addr addr, uint64_t tgid, int count)
Wakes up at most count waiting threads on a futex.
SyscallReturn getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpagesize() handler.
Addr getPageBytes() const
Get the page bytes for the ISA.
@ Halting
Trying to exit and waiting for an event to completely exit.
ByteOrder getGuestByteOrder() const
Get the guest byte order.
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, uint32_t owner, uint32_t group)
Target chown() handler.
SyscallReturn listenFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog)
static SyscallReturn exitImpl(SyscallDesc *desc, ThreadContext *tc, bool group, int status)
SyscallReturn shutdownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how)
Target shutdown() handler.
SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode)
Target mkdir() handler.
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
Target unlink() handler.
FutexMap class holds a map of all futexes used in the system.
SyscallReturn getegidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getegid() handler.
virtual Process * getProcessPtr()=0
SyscallReturn ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t length)
Target ftruncate() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, ThreadContext *tc)
Target umask() handler.
SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr addrPtr, Addr lenPtr)
static void exitFutexWake(ThreadContext *tc, Addr addr, uint64_t tgid)
SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr new_pathname)
Target symlink() handler.
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
virtual void halt()=0
Set the status to Halted.
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
static std::vector< System * > systemList
SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpid() handler.
SyscallReturn renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath)
Target rename() handler.
SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk)
Target brk() handler: set brk address.
void warnUnsupportedOS(std::string syscall_name)
SyscallReturn fchownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group)
Target fchown() handler.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
SyscallReturn setpgidFunc(SyscallDesc *desc, ThreadContext *tc, int pid, int pgid)
Target setpgid() handler.
SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, Addr result_ptr, int whence)
Target _llseek() handler.
SyscallReturn getsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, Addr valPtr, Addr lenPtr)
std::string checkPathRedirect(const std::string &filename)
Redirect file path if it matches any keys initialized by system object.
SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr buf_ptr, size_t bufsiz)
Target readlink() handler.
@ Halted
Permanently shut down.
#define DPRINTF_SYSCALL(FLAGEXT, FMT,...)
This macro is intended to help with readability.
T htog(T value, ByteOrder guest_byte_order)
SyscallReturn fallocateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int mode, off_t offset, off_t len)
SyscallReturn truncateFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, off_t length)
Target truncate() handler.
SyscallReturn getppidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getppid() handler.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode, dev_t dev)
Target mknod() handler.
SyscallReturn recvfromFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, Addr addrPtr, Addr addrlenPtr)
SyscallReturn pipeFunc(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr)
Target pipe() handler.
virtual ContextID contextId() const =0
SyscallReturn ftruncate64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int64_t length)
Target ftruncate64() handler.
SyscallReturn recvmsgFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr msgPtr, int flags)
SyscallReturn exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit_group() handler: terminate simulation. (exit all threads)
virtual Status status() const =0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
This class represents the return value from an emulated system call, including any errno setting.
const std::string & name()
SyscallReturn sendmsgFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr msgPtr, int flags)
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr)
Target set_tid_address() handler.
SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, Addr valPtr, socklen_t len)
SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
bool copyIn(PortProxy &memproxy)
copy data into simulator space (read from target memory)
void * bufferPtr()
Return a pointer to the internal simulator-space buffer.
virtual PortProxy & getVirtProxy()=0
SyscallReturn fcntlFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd, GuestABI::VarArgs< int > varargs)
Target fcntl() handler.
SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc, Addr buf_ptr, unsigned long size)
Target getcwd() handler.
SyscallReturn linkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr new_pathname)
Target link() handler.
SyscallReturn gettidFunc(SyscallDesc *desc, ThreadContext *tc)
Target gettid() handler.
SyscallReturn ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc)
Like above, but only prints a warning once per syscall desc it's used with.
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc)
SyscallReturn unimplementedFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we haven't thought about.
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
Target close() handler.
Overload hash function for BasicBlockRange type.
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
Target chdir() handler.
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc, Addr buf_ptr, int name_len)
Target gethostname() handler.
SyscallReturn bindFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr buf_ptr, int addrlen)
SyscallReturn fcntl64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd)
Target fcntl64() handler.
SyscallReturn getpgrpFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpgrpFunc() handler.
BufferArg represents an untyped buffer in target user space that is passed by reference to an (emulat...
SyscallReturn sendtoFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, Addr addrPtr, socklen_t addrLen)
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getgid() handler.
SyscallReturn pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc)
Pseudo Funcs - These functions use a different return convension, returning a second value in a regis...
SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc, Addr pathname, int64_t length)
Target truncate64() handler.
bool tryReadString(std::string &str, Addr addr) const
Reads the string at guest address addr into the std::string str.
SyscallReturn pipe2Func(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr, int flags)
Target pipe() handler.
SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode)
Target access() handler.
uint64_t childClearTID
Calls a futex wakeup at the address specified by this pointer when this process exits.
This class provides the wrapper interface for the system call implementations which are defined in th...
SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< uint32_t > cpu, VPtr< uint32_t > node, VPtr< uint32_t > tcache)
virtual System * getSystemPtr()=0
bool copyOut(PortProxy &memproxy)
copy data out of simulator space (write to target memory)
SyscallReturn dup2Func(SyscallDesc *desc, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd)
Target dup2() handler.
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17