diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e47133825..a4bab0d51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -482,7 +482,9 @@ jobs: patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch patch -p1 < $GITHUB_WORKSPACE/ci/aarch64-o-largefile.patch patch -p1 < $GITHUB_WORKSPACE/ci/tcgets2-tcsets2.patch + patch -p1 < $GITHUB_WORKSPACE/ci/tiocgsid.patch patch -p1 < $GITHUB_WORKSPACE/ci/more-sockopts.patch + patch -p1 < $GITHUB_WORKSPACE/ci/pidfd-open.patch ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs ninja -C build install if: matrix.qemu != '' && matrix.os == 'ubuntu-latest' @@ -618,7 +620,9 @@ jobs: patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch patch -p1 < $GITHUB_WORKSPACE/ci/aarch64-o-largefile.patch patch -p1 < $GITHUB_WORKSPACE/ci/tcgets2-tcsets2.patch + patch -p1 < $GITHUB_WORKSPACE/ci/tiocgsid.patch patch -p1 < $GITHUB_WORKSPACE/ci/more-sockopts.patch + patch -p1 < $GITHUB_WORKSPACE/ci/pidfd-open.patch ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs ninja -C build install if: matrix.qemu != '' && matrix.os == 'ubuntu-latest' @@ -710,7 +714,9 @@ jobs: patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch patch -p1 < $GITHUB_WORKSPACE/ci/aarch64-o-largefile.patch patch -p1 < $GITHUB_WORKSPACE/ci/tcgets2-tcsets2.patch + patch -p1 < $GITHUB_WORKSPACE/ci/tiocgsid.patch patch -p1 < $GITHUB_WORKSPACE/ci/more-sockopts.patch + patch -p1 < $GITHUB_WORKSPACE/ci/pidfd-open.patch ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs ninja -C build install if: matrix.qemu != '' && matrix.os == 'ubuntu-latest' diff --git a/ci/more-sockopts.patch b/ci/more-sockopts.patch index 54eaab5e9..5afdcb0fe 100644 --- a/ci/more-sockopts.patch +++ b/ci/more-sockopts.patch @@ -18,6 +18,19 @@ diff -ur -x roms -x build a/linux-user/generic/sockbits.h b/linux-user/generic/s +#define TARGET_SO_COOKIE 57 +#endif #endif +diff -ur -x roms -x build a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h +--- a/linux-user/mips/sockbits.h ++++ b/linux-user/mips/sockbits.h +@@ -73,6 +73,9 @@ + #define TARGET_SO_RCVBUFFORCE 33 + #define TARGET_SO_PASSSEC 34 + ++#define TARGET_SO_INCOMING_CPU 49 ++#define TARGET_SO_COOKIE 57 ++ + /** sock_type - Socket types + * + * Please notice that for binary compat reasons MIPS has to diff -ur -x roms -x build a/linux-user/syscall.c b/linux-user/syscall.c --- a/linux-user/syscall.c +++ b/linux-user/syscall.c diff --git a/ci/pidfd-open.patch b/ci/pidfd-open.patch new file mode 100644 index 000000000..6dcae96b0 --- /dev/null +++ b/ci/pidfd-open.patch @@ -0,0 +1,19 @@ +From Dan Gohman +Subject: [PATCH] Fix the flags argument of `pidfd_open`. + +This corrects the flags value of `pidfd_open` to avoid passing +target flags to the host. Currently the only flag is `PIDFD_NONBLOCK` +so we use the `fcntl_flags_tbl` to translate it. + +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -9477,7 +9477,8 @@ + #endif + #if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open) + case TARGET_NR_pidfd_open: +- return get_errno(pidfd_open(arg1, arg2)); ++ return get_errno(pidfd_open(arg1, ++ target_to_host_bitmask(arg2, fcntl_flags_tbl))); + #endif + #if defined(__NR_pidfd_send_signal) && defined(TARGET_NR_pidfd_send_signal) + case TARGET_NR_pidfd_send_signal: diff --git a/ci/tiocgsid.patch b/ci/tiocgsid.patch new file mode 100644 index 000000000..01ccdf708 --- /dev/null +++ b/ci/tiocgsid.patch @@ -0,0 +1,17 @@ +From Dan Gohman +Subject: [PATCH] Fix the definition of `TIOCGSID`. + +This corrects the value of `TIOCGSID`. + +diff -ur a/linux-user/ioctls.h b/linux-user/ioctls.h +--- a/linux-user/ioctls.h ++++ b/linux-user/ioctls.h +@@ -22,7 +28,7 @@ + IOCTL(TIOCSCTTY, 0, TYPE_INT) + IOCTL(TIOCGPGRP, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TIOCSPGRP, IOC_W, MK_PTR(TYPE_INT)) +- IOCTL(TIOCGSID, IOC_W, MK_PTR(TYPE_INT)) ++ IOCTL(TIOCGSID, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TIOCOUTQ, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TIOCSTI, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(TIOCMGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/tests/process/pidfd.rs b/tests/process/pidfd.rs index e1b1f8f4a..872ee59df 100644 --- a/tests/process/pidfd.rs +++ b/tests/process/pidfd.rs @@ -71,8 +71,9 @@ fn test_pidfd_poll() { process::WaitId::PidFd(pidfd.as_fd()), process::WaitidOptions::EXITED, ) { - Err(e) if e == io::Errno::AGAIN => (), - _ => panic!("unexpected result"), + Err(io::Errno::AGAIN) => (), + Err(e) => panic!("unexpected result: {:?}", e), + Ok(_) => panic!("unexpected success"), } // Wait for the child process to exit.