[gem5-dev] Change in gem5/gem5[master]: sim-se: adding pipe2 syscall
Brandon Potter has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/12310 ) Change subject: sim-se: adding pipe2 syscall .. sim-se: adding pipe2 syscall pipe2 builds on top of the pipe syscall implementation by adding some extra flags for the files (to avoid have to make separate calls to fcntl). Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/12310 Reviewed-by: Brandon Potter Maintainer: Brandon Potter Tested-by: kokoro --- M src/arch/x86/linux/process.cc M src/sim/syscall_emul.cc M src/sim/syscall_emul.hh 3 files changed, 63 insertions(+), 6 deletions(-) Approvals: Brandon Potter: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index 8a58ee1..9ffde7f 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -483,7 +483,7 @@ /* 218 */ SyscallDesc("set_tid_address", setTidAddressFunc), /* 219 */ SyscallDesc("restart_syscall", unimplementedFunc), /* 220 */ SyscallDesc("semtimedop", unimplementedFunc), -/* 221 */ SyscallDesc("fadvise64", unimplementedFunc), +/* 221 */ SyscallDesc("fadvise64", ignoreFunc), /* 222 */ SyscallDesc("timer_create", unimplementedFunc), /* 223 */ SyscallDesc("timer_settime", unimplementedFunc), /* 224 */ SyscallDesc("timer_gettime", unimplementedFunc), @@ -555,7 +555,7 @@ /* 290 */ SyscallDesc("eventfd2", eventfdFunc), /* 291 */ SyscallDesc("epoll_create1", unimplementedFunc), /* 292 */ SyscallDesc("dup3", unimplementedFunc), -/* 293 */ SyscallDesc("pipe2", unimplementedFunc), +/* 293 */ SyscallDesc("pipe2", pipe2Func), /* 294 */ SyscallDesc("inotify_init1", unimplementedFunc), /* 295 */ SyscallDesc("preadv", unimplementedFunc), /* 296 */ SyscallDesc("pwritev", unimplementedFunc), diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 142292d..28e3e3d 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -866,13 +866,18 @@ } SyscallReturn -pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool pseudoPipe) +pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool pseudo_pipe, + bool is_pipe2) { Addr tgt_addr = 0; +int flags = 0; auto p = tc->getProcessPtr(); -if (!pseudoPipe) { +if (!pseudo_pipe) { int index = 0; tgt_addr = p->getSyscallArg(tc, index); +if (is_pipe2) { +flags = p->getSyscallArg(tc, index); +} } int sim_fds[2], tgt_fds[2]; @@ -884,10 +889,12 @@ auto rend = PipeFDEntry::EndType::read; auto rpfd = std::make_shared(sim_fds[0], O_WRONLY, rend); tgt_fds[0] = p->fds->allocFD(rpfd); +int sim_fd_rpfd = rpfd->getSimFD(); auto wend = PipeFDEntry::EndType::write; auto wpfd = std::make_shared(sim_fds[1], O_RDONLY, wend); tgt_fds[1] = p->fds->allocFD(wpfd); +int sim_fd_wpfd = wpfd->getSimFD(); /** * Now patch the read object to record the target file descriptor chosen @@ -899,7 +906,7 @@ * Alpha Linux convention for pipe() is that fd[0] is returned as * the return value of the function, and fd[1] is returned in r20. */ -if (pseudoPipe) { +if (pseudo_pipe) { tc->setIntReg(SyscallPseudoReturnReg, tgt_fds[1]); return tgt_fds[0]; } @@ -913,6 +920,45 @@ buf_ptr[0] = tgt_fds[0]; buf_ptr[1] = tgt_fds[1]; tgt_handle.copyOut(tc->getVirtProxy()); + +// pipe2 has additional behavior if flags != 0 +if (is_pipe2 && flags) { +// pipe2 only uses O_NONBLOCK, O_CLOEXEC, and (O_NONBLOCK | O_CLOEXEC) +// if flags set to anything else, return EINVAL +if ((flags != O_CLOEXEC) && (flags != O_NONBLOCK) && +(flags != (O_CLOEXEC | O_NONBLOCK))) { +return -EINVAL; +} + +/* + If O_NONBLOCK is passed in as a flag to pipe2, set O_NONBLOCK file + status flag for two new open file descriptors. +*/ +if (flags & O_NONBLOCK) { +/* + O_NONBLOCK is set when the programmer wants to avoid a separate + call(s) to fcntl in their code, so mirror the fcntl + implementation for handling file descriptors -- rely on host to + maintain file status flags. +*/ +if (fcntl(sim_fd_rpfd, F_SETFL, O_NONBLOCK)) { +return -errno; +} +if (fcntl(sim_fd_wpfd, F_SETFL, O_NONBLOCK)) { +return -errno; +} +} + +/* + If O_CLOEXEC is passed in as a flag to pipe2, set close-on-exec + (FD_CLOEXEC) file status flag for two new open file descriptors. +*/ +if (flags & O_CLOEXEC) { +
[gem5-dev] Change in gem5/gem5[master]: sim-se: adding pipe2 syscall
Hello Matt Sinclair, Alexandru Duțu, John Alsop, I'd like you to reexamine a change. Please visit https://gem5-review.googlesource.com/c/public/gem5/+/12310 to look at the new patch set (#23). Change subject: sim-se: adding pipe2 syscall .. sim-se: adding pipe2 syscall pipe2 builds on top of the pipe syscall implementation by adding some extra flags for the files (to avoid have to make separate calls to fcntl). Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 --- M src/arch/x86/linux/process.cc M src/sim/syscall_emul.cc M src/sim/syscall_emul.hh 3 files changed, 63 insertions(+), 6 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12310 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 Gerrit-Change-Number: 12310 Gerrit-PatchSet: 23 Gerrit-Owner: Brandon Potter Gerrit-Reviewer: Alexandru Duțu Gerrit-Reviewer: John Alsop Gerrit-Reviewer: Matt Sinclair Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: sim-se: adding pipe2 syscall
Alexandru Duțu has uploaded a new patch set (#19) to the change originally created by Brandon Potter. ( https://gem5-review.googlesource.com/c/public/gem5/+/12310 ) Change subject: sim-se: adding pipe2 syscall .. sim-se: adding pipe2 syscall pipe2 builds on top of the pipe syscall implementation by adding some extra flags for the files (to avoid have to make separate calls to fcntl). Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 --- M src/arch/x86/linux/process.cc M src/sim/syscall_emul.cc M src/sim/syscall_emul.hh 3 files changed, 63 insertions(+), 6 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12310 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 Gerrit-Change-Number: 12310 Gerrit-PatchSet: 19 Gerrit-Owner: Brandon Potter Gerrit-Reviewer: Alexandru Duțu Gerrit-Reviewer: John Alsop Gerrit-Reviewer: Matt Sinclair Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: sim-se: adding pipe2 syscall
Brandon Potter has uploaded a new patch set (#12). ( https://gem5-review.googlesource.com/c/public/gem5/+/12310 ) Change subject: sim-se: adding pipe2 syscall .. sim-se: adding pipe2 syscall pipe2 builds on top of the pipe syscall implementation by adding some extra flags for the files (to avoid have to make separate calls to fcntl). Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 --- M src/arch/x86/linux/process.cc M src/sim/syscall_emul.cc M src/sim/syscall_emul.hh 3 files changed, 63 insertions(+), 6 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12310 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 Gerrit-Change-Number: 12310 Gerrit-PatchSet: 12 Gerrit-Owner: Brandon Potter Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: sim-se: adding pipe2 syscall
Brandon Potter has uploaded a new patch set (#3). ( https://gem5-review.googlesource.com/c/public/gem5/+/12310 ) Change subject: sim-se: adding pipe2 syscall .. sim-se: adding pipe2 syscall pipe2 builds on top of the pipe syscall implementation by adding some extra flags for the files (to avoid have to make separate calls to fcntl). Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 --- M src/arch/x86/linux/process.cc M src/sim/syscall_emul.cc M src/sim/syscall_emul.hh 3 files changed, 62 insertions(+), 5 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12310 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I88cf6f1387b9d14e60b33a32db412da9ed93a3e6 Gerrit-Change-Number: 12310 Gerrit-PatchSet: 3 Gerrit-Owner: Brandon Potter Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev