Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On Fri, Jul 19, 2019 at 09:13:16PM +1000, Michael Ellerman wrote: > Christian Brauner writes: > > On Fri, Jul 19, 2019 at 08:18:02PM +1000, Michael Ellerman wrote: > >> Christian Brauner writes: > >> > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > >> >> I think Vasily already has a clone3 patch for s390x with 435. > >> > > >> > A quick follow-up on this. Helge and Michael have asked whether there > >> > are any tests for clone3. Yes, there will be and I try to have them > >> > ready by the end of the this or next week for review. In the meantime I > >> > hope the following minimalistic test program that just verifies very > >> > very basic functionality (It's not pretty.) will help you test: > >> > >> Hi Christian, > >> > >> Thanks for the test. > >> > >> This actually oopses on powerpc, it hits the BUG_ON in CHECK_FULL_REGS > >> in process.c around line 1633: > >> > >>} else { > >>/* user thread */ > >>struct pt_regs *regs = current_pt_regs(); > >>CHECK_FULL_REGS(regs); > >>*childregs = *regs; > >>if (usp) > >> > >> > >> So I'll have to dig into how we fix that before we wire up clone3. > >> > >> Turns out testing is good! :) > > > > Indeed. I have a test-suite for clone3 in mind and I hope to have it > > ready by the end of next week. It's just always the finding the time > > part that is annoying. :) > > I know the feeling! > > > Thanks for digging into this, Michael! > > No worries, happy to help where I can. > > In the intervening five minutes I remembered how we handle this, we just > need a little wrapper to save the non-volatile regs: > > _GLOBAL(ppc_clone3) > bl save_nvgprs > bl sys_clone3 > b .Lsyscall_exit Sounds good. > > > A while back I meant to make it generate those automatically based on a > flag in the syscall.tbl but of course haven't got around to it :) > > So with the above it seems all good: > > $ ./clone3 ; echo $? > Parent process received child's pid 4204 as return value > Parent process received child's pidfd 3 > Parent process received child's pid 4204 as return argument > Child process with pid 4204 > 0 > > I'll send a patch to wire it up on Monday. Excellent! Thank you! Christian
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
Christian Brauner writes: > On Fri, Jul 19, 2019 at 08:18:02PM +1000, Michael Ellerman wrote: >> Christian Brauner writes: >> > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: >> >> I think Vasily already has a clone3 patch for s390x with 435. >> > >> > A quick follow-up on this. Helge and Michael have asked whether there >> > are any tests for clone3. Yes, there will be and I try to have them >> > ready by the end of the this or next week for review. In the meantime I >> > hope the following minimalistic test program that just verifies very >> > very basic functionality (It's not pretty.) will help you test: >> >> Hi Christian, >> >> Thanks for the test. >> >> This actually oopses on powerpc, it hits the BUG_ON in CHECK_FULL_REGS >> in process.c around line 1633: >> >> } else { >> /* user thread */ >> struct pt_regs *regs = current_pt_regs(); >> CHECK_FULL_REGS(regs); >> *childregs = *regs; >> if (usp) >> >> >> So I'll have to dig into how we fix that before we wire up clone3. >> >> Turns out testing is good! :) > > Indeed. I have a test-suite for clone3 in mind and I hope to have it > ready by the end of next week. It's just always the finding the time > part that is annoying. :) I know the feeling! > Thanks for digging into this, Michael! No worries, happy to help where I can. In the intervening five minutes I remembered how we handle this, we just need a little wrapper to save the non-volatile regs: _GLOBAL(ppc_clone3) bl save_nvgprs bl sys_clone3 b .Lsyscall_exit A while back I meant to make it generate those automatically based on a flag in the syscall.tbl but of course haven't got around to it :) So with the above it seems all good: $ ./clone3 ; echo $? Parent process received child's pid 4204 as return value Parent process received child's pidfd 3 Parent process received child's pid 4204 as return argument Child process with pid 4204 0 I'll send a patch to wire it up on Monday. cheers
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On Fri, Jul 19, 2019 at 08:18:02PM +1000, Michael Ellerman wrote: > Christian Brauner writes: > > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > >> I think Vasily already has a clone3 patch for s390x with 435. > > > > A quick follow-up on this. Helge and Michael have asked whether there > > are any tests for clone3. Yes, there will be and I try to have them > > ready by the end of the this or next week for review. In the meantime I > > hope the following minimalistic test program that just verifies very > > very basic functionality (It's not pretty.) will help you test: > > Hi Christian, > > Thanks for the test. > > This actually oopses on powerpc, it hits the BUG_ON in CHECK_FULL_REGS > in process.c around line 1633: > > } else { > /* user thread */ > struct pt_regs *regs = current_pt_regs(); > CHECK_FULL_REGS(regs); > *childregs = *regs; > if (usp) > > > So I'll have to dig into how we fix that before we wire up clone3. > > Turns out testing is good! :) Indeed. I have a test-suite for clone3 in mind and I hope to have it ready by the end of next week. It's just always the finding the time part that is annoying. :) Thanks for digging into this, Michael! Christian
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
Christian Brauner writes: > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: >> I think Vasily already has a clone3 patch for s390x with 435. > > A quick follow-up on this. Helge and Michael have asked whether there > are any tests for clone3. Yes, there will be and I try to have them > ready by the end of the this or next week for review. In the meantime I > hope the following minimalistic test program that just verifies very > very basic functionality (It's not pretty.) will help you test: Hi Christian, Thanks for the test. This actually oopses on powerpc, it hits the BUG_ON in CHECK_FULL_REGS in process.c around line 1633: } else { /* user thread */ struct pt_regs *regs = current_pt_regs(); CHECK_FULL_REGS(regs); *childregs = *regs; if (usp) So I'll have to dig into how we fix that before we wire up clone3. Turns out testing is good! :) cheers
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On 16.07.19 20:55, Christian Brauner wrote: On Tue, Jul 16, 2019 at 08:53:10PM +0200, Sven Schnelle wrote: Hi, [Adding Helge to CC list] On Tue, Jul 16, 2019 at 03:06:33PM +0200, Christian Brauner wrote: On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: I think Vasily already has a clone3 patch for s390x with 435. A quick follow-up on this. Helge and Michael have asked whether there are any tests for clone3. Yes, there will be and I try to have them ready by the end of the this or next week for review. In the meantime I hope the following minimalistic test program that just verifies very very basic functionality (It's not pretty.) will help you test: [..] On PA-RISC this seems to work fine with Helge's patch to wire up the clone3 syscall. [...] In any case, I saw Helge's patch and I think I might've missed to add an Acked-by but feel free to add it. Thanks! I've added the patch to the parisc-linux for-next tree. Helge
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
Hi, [Adding Helge to CC list] On Tue, Jul 16, 2019 at 03:06:33PM +0200, Christian Brauner wrote: > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > > I think Vasily already has a clone3 patch for s390x with 435. > > A quick follow-up on this. Helge and Michael have asked whether there > are any tests for clone3. Yes, there will be and I try to have them > ready by the end of the this or next week for review. In the meantime I > hope the following minimalistic test program that just verifies very > very basic functionality (It's not pretty.) will help you test: > [..] On PA-RISC this seems to work fine with Helge's patch to wire up the clone3 syscall. root@c3750:/# clonetest Parent process received child's pid 84 as return value Parent process received child's pidfd 3 Parent process received child's pid 84 as return argument Child process with pid 84 root@c3750:/# echo $? 0 Regards Sven
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On Tue, Jul 16, 2019 at 08:53:10PM +0200, Sven Schnelle wrote: > Hi, > > [Adding Helge to CC list] > > On Tue, Jul 16, 2019 at 03:06:33PM +0200, Christian Brauner wrote: > > On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > > > I think Vasily already has a clone3 patch for s390x with 435. > > > > A quick follow-up on this. Helge and Michael have asked whether there > > are any tests for clone3. Yes, there will be and I try to have them > > ready by the end of the this or next week for review. In the meantime I > > hope the following minimalistic test program that just verifies very > > very basic functionality (It's not pretty.) will help you test: > > [..] > > On PA-RISC this seems to work fine with Helge's patch to wire up the > clone3 syscall. I think I already responded to Helge before and yes, I think that parisc doesn't do anything special for fork, vfork, clone, and by extension also probably doesn't need to for clone3. It should only be a problem for arches that require mucking explicitly with arguments of clone-like syscalls. In any case, I saw Helge's patch and I think I might've missed to add an Acked-by but feel free to add it. Thanks for testing it and sorry that I couldn't test! Christian
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > I think Vasily already has a clone3 patch for s390x with 435. A quick follow-up on this. Helge and Michael have asked whether there are any tests for clone3. Yes, there will be and I try to have them ready by the end of the this or next week for review. In the meantime I hope the following minimalistic test program that just verifies very very basic functionality (It's not pretty.) will help you test: #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef CLONE_PIDFD #define CLONE_PIDFD 0x1000 #endif #ifndef __NR_clone3 #define __NR_clone3 -1 #endif static pid_t sys_clone3(struct clone_args *args) { return syscall(__NR_clone3, args, sizeof(struct clone_args)); } static int wait_for_pid(pid_t pid) { int status, ret; again: ret = waitpid(pid, , 0); if (ret == -1) { if (errno == EINTR) goto again; return -1; } if (ret != pid) goto again; if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) return -1; return 0; } #define ptr_to_u64(ptr) ((__u64)((uintptr_t)(ptr))) int main(int argc, char *argv[]) { int pidfd = -1; pid_t parent_tid = -1, pid = -1; struct clone_args args = {0}; args.parent_tid = ptr_to_u64(_tid); /* CLONE_PARENT_SETTID */ args.pidfd = ptr_to_u64(); /* CLONE_PIDFD */ args.flags = CLONE_PIDFD | CLONE_PARENT_SETTID; args.exit_signal = SIGCHLD; pid = sys_clone3(); if (pid < 0) { fprintf(stderr, "%s - Failed to create new process\n", strerror(errno)); exit(EXIT_FAILURE); } if (pid == 0) { printf("Child process with pid %d\n", getpid()); exit(EXIT_SUCCESS); } printf("Parent process received child's pid %d as return value\n", pid); printf("Parent process received child's pidfd %d\n", *(int *)args.pidfd); printf("Parent process received child's pid %d as return argument\n", *(pid_t *)args.parent_tid); if (wait_for_pid(pid)) exit(EXIT_FAILURE); if (pid != *(pid_t *)args.parent_tid) exit(EXIT_FAILURE); close(pidfd); return 0; }
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
On Mon, Jul 15, 2019 at 03:56:04PM +0200, Christian Borntraeger wrote: > I think Vasily already has a clone3 patch for s390x with 435. Excellent. I'll leave the # 435 reserved for clone3 on s390x in until this patch has landed. It shouldn't be a merge conflict and if so it should be trivial. Christian
Re: [PATCH 1/2] arch: mark syscall number 435 reserved for clone3
I think Vasily already has a clone3 patch for s390x with 435. On 14.07.19 21:22, Christian Brauner wrote: > A while ago Arnd made it possible to give new system calls the same > syscall number on all architectures (except alpha). To not break this > nice new feature let's mark 435 for clone3 as reserved on all > architectures that do not yet implement it. > Even if an architecture does not plan to implement it this ensures that > new system calls coming after clone3 will have the same number on all > architectures. > > Signed-off-by: Christian Brauner > Cc: Arnd Bergmann > Cc: linux-a...@vger.kernel.org > Cc: linux-alpha@vger.kernel.org > Cc: linux-ker...@vger.kernel.org > Cc: linux-i...@vger.kernel.org > Cc: linux-m...@lists.linux-m68k.org > Cc: linux-m...@vger.kernel.org > Cc: linux-par...@vger.kernel.org > Cc: linuxppc-...@lists.ozlabs.org > Cc: linux-s...@vger.kernel.org > Cc: linux...@vger.kernel.org > Cc: sparcli...@vger.kernel.org > --- > arch/alpha/kernel/syscalls/syscall.tbl| 1 + > arch/ia64/kernel/syscalls/syscall.tbl | 1 + > arch/m68k/kernel/syscalls/syscall.tbl | 1 + > arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + > arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + > arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + > arch/parisc/kernel/syscalls/syscall.tbl | 1 + > arch/powerpc/kernel/syscalls/syscall.tbl | 1 + > arch/s390/kernel/syscalls/syscall.tbl | 1 + > arch/sh/kernel/syscalls/syscall.tbl | 1 + > arch/sparc/kernel/syscalls/syscall.tbl| 1 + > 11 files changed, 11 insertions(+) > > diff --git a/arch/alpha/kernel/syscalls/syscall.tbl > b/arch/alpha/kernel/syscalls/syscall.tbl > index 1db9bbcfb84e..728fe028c02c 100644 > --- a/arch/alpha/kernel/syscalls/syscall.tbl > +++ b/arch/alpha/kernel/syscalls/syscall.tbl > @@ -474,3 +474,4 @@ > 542 common fsmount sys_fsmount > 543 common fspick sys_fspick > 544 common pidfd_open sys_pidfd_open > +# 545 reserved for clone3 > diff --git a/arch/ia64/kernel/syscalls/syscall.tbl > b/arch/ia64/kernel/syscalls/syscall.tbl > index ecc44926737b..36d5faf4c86c 100644 > --- a/arch/ia64/kernel/syscalls/syscall.tbl > +++ b/arch/ia64/kernel/syscalls/syscall.tbl > @@ -355,3 +355,4 @@ > 432 common fsmount sys_fsmount > 433 common fspick sys_fspick > 434 common pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/m68k/kernel/syscalls/syscall.tbl > b/arch/m68k/kernel/syscalls/syscall.tbl > index 9a3eb2558568..a88a285a0e5f 100644 > --- a/arch/m68k/kernel/syscalls/syscall.tbl > +++ b/arch/m68k/kernel/syscalls/syscall.tbl > @@ -434,3 +434,4 @@ > 432 common fsmount sys_fsmount > 433 common fspick sys_fspick > 434 common pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl > b/arch/mips/kernel/syscalls/syscall_n32.tbl > index 97035e19ad03..c9c879ec9b6d 100644 > --- a/arch/mips/kernel/syscalls/syscall_n32.tbl > +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl > @@ -373,3 +373,4 @@ > 432 n32 fsmount sys_fsmount > 433 n32 fspick sys_fspick > 434 n32 pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl > b/arch/mips/kernel/syscalls/syscall_n64.tbl > index d7292722d3b0..bbce9159caa1 100644 > --- a/arch/mips/kernel/syscalls/syscall_n64.tbl > +++ b/arch/mips/kernel/syscalls/syscall_n64.tbl > @@ -349,3 +349,4 @@ > 432 n64 fsmount sys_fsmount > 433 n64 fspick sys_fspick > 434 n64 pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl > b/arch/mips/kernel/syscalls/syscall_o32.tbl > index dba084c92f14..9653591428ec 100644 > --- a/arch/mips/kernel/syscalls/syscall_o32.tbl > +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl > @@ -422,3 +422,4 @@ > 432 o32 fsmount sys_fsmount > 433 o32 fspick sys_fspick > 434 o32 pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/parisc/kernel/syscalls/syscall.tbl > b/arch/parisc/kernel/syscalls/syscall.tbl > index 5022b9e179c2..c7aadfef5386 100644 > --- a/arch/parisc/kernel/syscalls/syscall.tbl > +++ b/arch/parisc/kernel/syscalls/syscall.tbl > @@ -431,3 +431,4 @@ > 432 common fsmount sys_fsmount > 433 common fspick sys_fspick > 434 common pidfd_open sys_pidfd_open > +# 435 reserved for clone3 > diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl > b/arch/powerpc/kernel/syscalls/syscall.tbl > index