Linux-m68k Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] m68k: Wire up clone3() syscall
@ 2019-11-24 19:52 Kars de Jong
  2019-11-25  9:12 ` Geert Uytterhoeven
  2020-01-12 16:06 ` Geert Uytterhoeven
  0 siblings, 2 replies; 15+ messages in thread
From: Kars de Jong @ 2019-11-24 19:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-kernel, Kars de Jong, linux-m68k

Wire up the clone3() syscall for m68k. The special entry point is done in
assembler as was done for clone() as well. This is needed because all
registers need to be saved. The C wrapper then calls the generic
sys_clone3() with the correct arguments.

Tested on A1200 using the simple test program from:

  https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/

Cc: linux-m68k@vger.kernel.org
Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
---
 arch/m68k/include/asm/unistd.h        |  1 +
 arch/m68k/kernel/entry.S              |  7 +++++++
 arch/m68k/kernel/process.c            | 13 ++++++++++++-
 arch/m68k/kernel/syscalls/syscall.tbl |  2 +-
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 2e0047cf86f8..4ae52414cd9d 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -30,5 +30,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
+#define __ARCH_WANT_SYS_CLONE3
 
 #endif /* _ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 97cd3ea5f10b..9dd76fbb7c6b 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -69,6 +69,13 @@ ENTRY(__sys_vfork)
 	lea     %sp@(24),%sp
 	rts
 
+ENTRY(__sys_clone3)
+	SAVE_SWITCH_STACK
+	pea	%sp@(SWITCH_STACK_SIZE)
+	jbsr	m68k_clone3
+	lea	%sp@(28),%sp
+	rts
+
 ENTRY(sys_sigreturn)
 	SAVE_SWITCH_STACK
 	movel	%sp,%sp@-		  | switch_stack pointer
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 4e77a06735c1..22e6b8f4f958 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -30,8 +30,9 @@
 #include <linux/init_task.h>
 #include <linux/mqueue.h>
 #include <linux/rcupdate.h>
-
+#include <linux/syscalls.h>
 #include <linux/uaccess.h>
+
 #include <asm/traps.h>
 #include <asm/machdep.h>
 #include <asm/setup.h>
@@ -119,6 +120,16 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
 		       (int __user *)regs->d3, (int __user *)regs->d4);
 }
 
+/*
+ * Because extra registers are saved on the stack after the sys_clone3()
+ * arguments, this C wrapper extracts them from pt_regs * and then calls the
+ * generic sys_clone3() implementation.
+ */
+asmlinkage int m68k_clone3(struct pt_regs *regs)
+{
+	return sys_clone3((struct clone_args __user *)regs->d1, regs->d2);
+}
+
 int copy_thread(unsigned long clone_flags, unsigned long usp,
 		 unsigned long arg, struct task_struct *p)
 {
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl
index a88a285a0e5f..a00a5d0db602 100644
--- a/arch/m68k/kernel/syscalls/syscall.tbl
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -434,4 +434,4 @@
 432	common	fsmount				sys_fsmount
 433	common	fspick				sys_fspick
 434	common	pidfd_open			sys_pidfd_open
-# 435 reserved for clone3
+435	common	clone3				__sys_clone3
-- 
2.17.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-11-24 19:52 [PATCH] m68k: Wire up clone3() syscall Kars de Jong
@ 2019-11-25  9:12 ` Geert Uytterhoeven
  2019-11-26 14:41   ` Christian Brauner
  2020-01-12 16:06 ` Geert Uytterhoeven
  1 sibling, 1 reply; 15+ messages in thread
From: Geert Uytterhoeven @ 2019-11-25  9:12 UTC (permalink / raw)
  To: Kars de Jong; +Cc: Linux Kernel Mailing List, Linux/m68k

Hi Kars,

On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> Wire up the clone3() syscall for m68k. The special entry point is done in
> assembler as was done for clone() as well. This is needed because all
> registers need to be saved. The C wrapper then calls the generic
> sys_clone3() with the correct arguments.
>
> Tested on A1200 using the simple test program from:
>
>   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
>
> Cc: linux-m68k@vger.kernel.org
> Signed-off-by: Kars de Jong <jongk@linux-m68k.org>

Thanks a lot!
Works fine on ARAnyM, too.

Looks good to me, but I'll wait a bit before applying, so the syscall experts
can chime in, if needed.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-11-25  9:12 ` Geert Uytterhoeven
@ 2019-11-26 14:41   ` Christian Brauner
  2019-11-26 15:29     ` Kars de Jong
  0 siblings, 1 reply; 15+ messages in thread
From: Christian Brauner @ 2019-11-26 14:41 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k

On Mon, Nov 25, 2019 at 10:12:25AM +0100, Geert Uytterhoeven wrote:
> Hi Kars,
> 
> On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > Wire up the clone3() syscall for m68k. The special entry point is done in
> > assembler as was done for clone() as well. This is needed because all
> > registers need to be saved. The C wrapper then calls the generic
> > sys_clone3() with the correct arguments.
> >
> > Tested on A1200 using the simple test program from:
> >
> >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/

Please note that we now have a growing test-suite for the clone3()
syscall under
tools/testing/selftests/clone3/*

You can test on a suitable kernel with

make TARGETS=clone3 kselftest

> >
> > Cc: linux-m68k@vger.kernel.org
> > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
> 
> Thanks a lot!
> Works fine on ARAnyM, too.
> 
> Looks good to me, but I'll wait a bit before applying, so the syscall experts
> can chime in, if needed.

Otherwise this looks good to me.
Thanks for moving this forward. One day we'll be able to remove
ARCH_WANT_SYS_CLONE3 completely. :)

	Christian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-11-26 14:41   ` Christian Brauner
@ 2019-11-26 15:29     ` Kars de Jong
  2019-12-15 16:48       ` Geert Uytterhoeven
  0 siblings, 1 reply; 15+ messages in thread
From: Kars de Jong @ 2019-11-26 15:29 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Geert Uytterhoeven, Linux Kernel Mailing List, Linux/m68k

Hi Christian!

Op di 26 nov. 2019 om 15:41 schreef Christian Brauner
<christian.brauner@ubuntu.com>:
>
> On Mon, Nov 25, 2019 at 10:12:25AM +0100, Geert Uytterhoeven wrote:
> > Hi Kars,
> >
> > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > assembler as was done for clone() as well. This is needed because all
> > > registers need to be saved. The C wrapper then calls the generic
> > > sys_clone3() with the correct arguments.
> > >
> > > Tested on A1200 using the simple test program from:
> > >
> > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
>
> Please note that we now have a growing test-suite for the clone3()
> syscall under
> tools/testing/selftests/clone3/*
>
> You can test on a suitable kernel with
>
> make TARGETS=clone3 kselftest

I'm afraid my user space is almost prehistoric. I have a homebrewn
root filesystem of about 2001 vintage, and another one with Debian
3.1.
So until I have bootstrapped a more recent one, I'll leave that to others ;-)

Thanks for checking!

Kind regards,

Kars.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-11-26 15:29     ` Kars de Jong
@ 2019-12-15 16:48       ` Geert Uytterhoeven
  2019-12-15 17:01         ` John Paul Adrian Glaubitz
                           ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2019-12-15 16:48 UTC (permalink / raw)
  To: Kars de Jong; +Cc: Christian Brauner, Linux Kernel Mailing List, Linux/m68k

Hi Kars,

On Tue, Nov 26, 2019 at 4:29 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> Op di 26 nov. 2019 om 15:41 schreef Christian Brauner
> <christian.brauner@ubuntu.com>:
> > On Mon, Nov 25, 2019 at 10:12:25AM +0100, Geert Uytterhoeven wrote:
> > > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > > assembler as was done for clone() as well. This is needed because all
> > > > registers need to be saved. The C wrapper then calls the generic
> > > > sys_clone3() with the correct arguments.
> > > >
> > > > Tested on A1200 using the simple test program from:
> > > >
> > > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> >
> > Please note that we now have a growing test-suite for the clone3()
> > syscall under
> > tools/testing/selftests/clone3/*
> >
> > You can test on a suitable kernel with
> >
> > make TARGETS=clone3 kselftest
>
> I'm afraid my user space is almost prehistoric. I have a homebrewn
> root filesystem of about 2001 vintage, and another one with Debian
> 3.1.
> So until I have bootstrapped a more recent one, I'll leave that to others ;-)

With Ubuntu's libc6-m68k-cross installed, the selftest binaries cross-build
fine.  Running them on a very old Debian requires some hackery:

  1. Copy ld.so.1, ld-2.27.so, libc.so.6, and libc-2.27.so from
     /usr/m68k-linux-gnu/lib/ to /tmp/lib on the m68k target,
  2. mkdir /tmp/proc && mount proc /tmp/proc -t proc,
  3. chroot /tmp /tmp/<test-binary>.

Unfortunately some tests failed:

atari:~# chroot /tmp /tmp/clone3
# clone3() syscall supported
TAP version 13
1..17
# [825] Trying clone3() with flags 0 (size 0)
# I am the parent (825). My child's pid is 826
# I am the child, my PID is 826
# [825] clone3() with flags says: 0 expected 0
ok 1 [825] Result (0) matches expectation (0)
# [825] Trying clone3() with flags 0x20000000 (size 0)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected 0
not ok 2 [825] Result (-22) is different than expected (0)
# [825] Trying clone3() with flags 0 (size 64)
# I am the parent (825). My child's pid is 827
# I am the child, my PID is 827
# [825] clone3() with flags says: 0 expected 0
ok 3 [825] Result (0) matches expectation (0)
# [825] Trying clone3() with flags 0 (size 56)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 4 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0 (size 88)
# I am the parent (825). My child's pid is 828
# I am the child, my PID is 828
# [825] clone3() with flags says: 0 expected 0
ok 5 [825] Result (0) matches expectation (0)
# [825] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 6 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 7 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 8 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 9 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0 (size 88)
# I am the parent (825). My child's pid is 829
# I am the child, my PID is 829
# [825] clone3() with flags says: 0 expected 0
ok 10 [825] Result (0) matches expectation (0)
# [825] Trying clone3() with flags 0 (size 96)
# Argument list too long - Failed to create new process
# [825] clone3() with flags says: -7 expected -7
ok 11 [825] Result (-7) matches expectation (-7)
# [825] Trying clone3() with flags 0 (size 160)
# Argument list too long - Failed to create new process
# [825] clone3() with flags says: -7 expected -7
ok 12 [825] Result (-7) matches expectation (-7)
# [825] Trying clone3() with flags 0 (size 4104)
# Argument list too long - Failed to create new process
# [825] clone3() with flags says: -7 expected -7
ok 13 [825] Result (-7) matches expectation (-7)
# [825] Trying clone3() with flags 0x20000000 (size 64)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected 0
not ok 14 [825] Result (-22) is different than expected (0)
# [825] Trying clone3() with flags 0x20000000 (size 56)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected -22
ok 15 [825] Result (-22) matches expectation (-22)
# [825] Trying clone3() with flags 0x20000000 (size 88)
# Invalid argument - Failed to create new process
# [825] clone3() with flags says: -22 expected 0
not ok 16 [825] Result (-22) is different than expected (0)
# [825] Trying clone3() with flags 0x20000000 (size 4104)
# Argument list too long - Failed to create new process
# [825] clone3() with flags says: -7 expected -7
ok 17 [825] Result (-7) matches expectation (-7)
Bail out!
# Pass 14 Fail 3 Xfail 0 Xpass 0 Skip 0 Error 0
atari:~# chroot /tmp /tmp/clone3_set_tid
TAP version 13
# clone3() syscall supported
1..29
# /proc/sys/kernel/pid_max 32768
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 1 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 2 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 3 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 4 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 5 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 6 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 7 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 8 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 9 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 10 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 11 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 12 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 13 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to -1 and 0x20000000
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 14 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 1 and 0x0
# File exists - Failed to create new process
# [830] clone3() with CLONE_SET_TID 1 says :-17 - expected -17
ok 15 [830] Result (-17) matches expectation (-17)
# [830] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 1 says :-22 - expected 0
not ok 16 [830] Result (-22) is different than expected (0)
# [830] Trying clone3() with CLONE_SET_TID to 32768 and 0x0
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
ok 17 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 32768 and 0x20000000
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
ok 18 [830] Result (-22) matches expectation (-22)
# Child has PID 831
# [830] Trying clone3() with CLONE_SET_TID to 831 and 0x0
# I am the parent (830). My child's pid is 831
# I am the child, my PID is 831 (expected 831)
# [830] clone3() with CLONE_SET_TID 831 says :0 - expected 0
ok 19 [830] Result (0) matches expectation (0)
# [830] Trying clone3() with CLONE_SET_TID to 831 and 0x20000000
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 831 says :-22 - expected -22
ok 20 [830] Result (-22) matches expectation (-22)
# [830] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# Invalid argument - Failed to create new process
# [830] clone3() with CLONE_SET_TID 1 says :-22 - expected 0
not ok 21 [830] Result (-22) is different than expected (0)
# unshare PID namespace
Bail out! unshare(CLONE_NEWPID) failed: Invalid argument
# Planned tests != run tests (29 != 21)
# Pass 19 Fail 2 Xfail 0 Xpass 0 Skip 0 Error 0
atari:~# chroot /tmp /tmp/clone3_clear_sighand
TAP version 13
# clone3() syscall supported
1..1
Bail out! Failed to clear signal handler for child process
# Planned tests != run tests (1 != 0)
# Pass 0 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
atari:~#

So this needs a bit more work?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-12-15 16:48       ` Geert Uytterhoeven
@ 2019-12-15 17:01         ` John Paul Adrian Glaubitz
  2019-12-15 20:06           ` Geert Uytterhoeven
  2019-12-16 10:31         ` Christian Brauner
  2019-12-18  9:57         ` Kars de Jong
  2 siblings, 1 reply; 15+ messages in thread
From: John Paul Adrian Glaubitz @ 2019-12-15 17:01 UTC (permalink / raw)
  To: Geert Uytterhoeven, Kars de Jong
  Cc: Christian Brauner, Linux Kernel Mailing List, Linux/m68k

On 12/15/19 5:48 PM, Geert Uytterhoeven wrote:
> With Ubuntu's libc6-m68k-cross installed, the selftest binaries cross-build
> fine.  Running them on a very old Debian requires some hackery:
> 
>   1. Copy ld.so.1, ld-2.27.so, libc.so.6, and libc-2.27.so from
>      /usr/m68k-linux-gnu/lib/ to /tmp/lib on the m68k target,
>   2. mkdir /tmp/proc && mount proc /tmp/proc -t proc,
>   3. chroot /tmp /tmp/<test-binary>.
Why not use a recent environment?

> https://wiki.debian.org/M68k/QemuSystemM68k

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-12-15 17:01         ` John Paul Adrian Glaubitz
@ 2019-12-15 20:06           ` Geert Uytterhoeven
  0 siblings, 0 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2019-12-15 20:06 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Kars de Jong, Christian Brauner, Linux Kernel Mailing List, Linux/m68k

Hi Adrian,

On Sun, Dec 15, 2019 at 6:01 PM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 12/15/19 5:48 PM, Geert Uytterhoeven wrote:
> > With Ubuntu's libc6-m68k-cross installed, the selftest binaries cross-build
> > fine.  Running them on a very old Debian requires some hackery:
> >
> >   1. Copy ld.so.1, ld-2.27.so, libc.so.6, and libc-2.27.so from
> >      /usr/m68k-linux-gnu/lib/ to /tmp/lib on the m68k target,
> >   2. mkdir /tmp/proc && mount proc /tmp/proc -t proc,
> >   3. chroot /tmp /tmp/<test-binary>.
> Why not use a recent environment?
>
> > https://wiki.debian.org/M68k/QemuSystemM68k

Yeah, I will give that a try... one day...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-12-15 16:48       ` Geert Uytterhoeven
  2019-12-15 17:01         ` John Paul Adrian Glaubitz
@ 2019-12-16 10:31         ` Christian Brauner
  2019-12-18  9:57         ` Kars de Jong
  2 siblings, 0 replies; 15+ messages in thread
From: Christian Brauner @ 2019-12-16 10:31 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k

On Sun, Dec 15, 2019 at 05:48:10PM +0100, Geert Uytterhoeven wrote:
> Hi Kars,
> 
> On Tue, Nov 26, 2019 at 4:29 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > Op di 26 nov. 2019 om 15:41 schreef Christian Brauner
> > <christian.brauner@ubuntu.com>:
> > > On Mon, Nov 25, 2019 at 10:12:25AM +0100, Geert Uytterhoeven wrote:
> > > > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > > > assembler as was done for clone() as well. This is needed because all
> > > > > registers need to be saved. The C wrapper then calls the generic
> > > > > sys_clone3() with the correct arguments.
> > > > >
> > > > > Tested on A1200 using the simple test program from:
> > > > >
> > > > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> > >
> > > Please note that we now have a growing test-suite for the clone3()
> > > syscall under
> > > tools/testing/selftests/clone3/*
> > >
> > > You can test on a suitable kernel with
> > >
> > > make TARGETS=clone3 kselftest
> >
> > I'm afraid my user space is almost prehistoric. I have a homebrewn
> > root filesystem of about 2001 vintage, and another one with Debian
> > 3.1.
> > So until I have bootstrapped a more recent one, I'll leave that to others ;-)
> 
> With Ubuntu's libc6-m68k-cross installed, the selftest binaries cross-build
> fine.  Running them on a very old Debian requires some hackery:
> 
>   1. Copy ld.so.1, ld-2.27.so, libc.so.6, and libc-2.27.so from
>      /usr/m68k-linux-gnu/lib/ to /tmp/lib on the m68k target,
>   2. mkdir /tmp/proc && mount proc /tmp/proc -t proc,
>   3. chroot /tmp /tmp/<test-binary>.
> 
> Unfortunately some tests failed:

Thanks for going through the trouble of testing this, Geert!
Christian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-12-15 16:48       ` Geert Uytterhoeven
  2019-12-15 17:01         ` John Paul Adrian Glaubitz
  2019-12-16 10:31         ` Christian Brauner
@ 2019-12-18  9:57         ` Kars de Jong
  2 siblings, 0 replies; 15+ messages in thread
From: Kars de Jong @ 2019-12-18  9:57 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Christian Brauner, Linux Kernel Mailing List, Linux/m68k,
	John Paul Adrian Glaubitz

Hi Geert!

Op zo 15 dec. 2019 om 17:48 schreef Geert Uytterhoeven <geert@linux-m68k.org>:
> Unfortunately some tests failed:
>
> atari:~# chroot /tmp /tmp/clone3
> # clone3() syscall supported
> TAP version 13
> 1..17
> # [825] Trying clone3() with flags 0 (size 0)
> # I am the parent (825). My child's pid is 826
> # I am the child, my PID is 826
> # [825] clone3() with flags says: 0 expected 0
> ok 1 [825] Result (0) matches expectation (0)
> # [825] Trying clone3() with flags 0x20000000 (size 0)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected 0
> not ok 2 [825] Result (-22) is different than expected (0)
> # [825] Trying clone3() with flags 0 (size 64)
> # I am the parent (825). My child's pid is 827
> # I am the child, my PID is 827
> # [825] clone3() with flags says: 0 expected 0
> ok 3 [825] Result (0) matches expectation (0)
> # [825] Trying clone3() with flags 0 (size 56)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 4 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0 (size 88)
> # I am the parent (825). My child's pid is 828
> # I am the child, my PID is 828
> # [825] clone3() with flags says: 0 expected 0
> ok 5 [825] Result (0) matches expectation (0)
> # [825] Trying clone3() with flags 0 (size 0)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 6 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0 (size 0)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 7 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0 (size 0)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 8 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0 (size 0)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 9 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0 (size 88)
> # I am the parent (825). My child's pid is 829
> # I am the child, my PID is 829
> # [825] clone3() with flags says: 0 expected 0
> ok 10 [825] Result (0) matches expectation (0)
> # [825] Trying clone3() with flags 0 (size 96)
> # Argument list too long - Failed to create new process
> # [825] clone3() with flags says: -7 expected -7
> ok 11 [825] Result (-7) matches expectation (-7)
> # [825] Trying clone3() with flags 0 (size 160)
> # Argument list too long - Failed to create new process
> # [825] clone3() with flags says: -7 expected -7
> ok 12 [825] Result (-7) matches expectation (-7)
> # [825] Trying clone3() with flags 0 (size 4104)
> # Argument list too long - Failed to create new process
> # [825] clone3() with flags says: -7 expected -7
> ok 13 [825] Result (-7) matches expectation (-7)
> # [825] Trying clone3() with flags 0x20000000 (size 64)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected 0
> not ok 14 [825] Result (-22) is different than expected (0)
> # [825] Trying clone3() with flags 0x20000000 (size 56)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected -22
> ok 15 [825] Result (-22) matches expectation (-22)
> # [825] Trying clone3() with flags 0x20000000 (size 88)
> # Invalid argument - Failed to create new process
> # [825] clone3() with flags says: -22 expected 0
> not ok 16 [825] Result (-22) is different than expected (0)
> # [825] Trying clone3() with flags 0x20000000 (size 4104)
> # Argument list too long - Failed to create new process
> # [825] clone3() with flags says: -7 expected -7
> ok 17 [825] Result (-7) matches expectation (-7)
> Bail out!
> # Pass 14 Fail 3 Xfail 0 Xpass 0 Skip 0 Error 0

I created a new environment as described by Adrian (thanks!), built a
5.5.0-rc2 kernel based on Debian config-5.3.0-3-m68k, and ran these
tests too:

kars@q800:/$ sudo ./clone3
# clone3() syscall supported
TAP version 13
1..17
# [406] Trying clone3() with flags 0 (size 0)
# I am the parent (406). My child's pid is 407
# [406] clone3() with flags says: 0 expected 0
ok 1 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0x20000000 (size 0)
# I am the parent (406). My child's pid is 408
# [406] clone3() with flags says: 0 expected 0
ok 2 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0 (size 64)
# I am the parent (406). My child's pid is 409
# [406] clone3() with flags says: 0 expected 0
ok 3 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0 (size 56)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 4 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0 (size 88)
# I am the parent (406). My child's pid is 410
# [406] clone3() with flags says: 0 expected 0
ok 5 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 6 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 7 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 8 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0 (size 0)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 9 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0 (size 88)
# I am the parent (406). My child's pid is 411
# [406] clone3() with flags says: 0 expected 0
ok 10 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0 (size 96)
# Argument list too long - Failed to create new process
# [406] clone3() with flags says: -7 expected -7
ok 11 [406] Result (-7) matches expectation (-7)
# [406] Trying clone3() with flags 0 (size 160)
# Argument list too long - Failed to create new process
# [406] clone3() with flags says: -7 expected -7
ok 12 [406] Result (-7) matches expectation (-7)
# [406] Trying clone3() with flags 0 (size 4104)
# Argument list too long - Failed to create new process
# [406] clone3() with flags says: -7 expected -7
ok 13 [406] Result (-7) matches expectation (-7)
# [406] Trying clone3() with flags 0x20000000 (size 64)
# I am the parent (406). My child's pid is 412
# [406] clone3() with flags says: 0 expected 0
ok 14 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0x20000000 (size 56)
# Invalid argument - Failed to create new process
# [406] clone3() with flags says: -22 expected -22
ok 15 [406] Result (-22) matches expectation (-22)
# [406] Trying clone3() with flags 0x20000000 (size 88)
# I am the parent (406). My child's pid is 413
# [406] clone3() with flags says: 0 expected 0
ok 16 [406] Result (0) matches expectation (0)
# [406] Trying clone3() with flags 0x20000000 (size 4104)
# Argument list too long - Failed to create new process
# [406] clone3() with flags says: -7 expected -7
ok 17 [406] Result (-7) matches expectation (-7)
# Pass 17 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0

So that works OK.

> atari:~# chroot /tmp /tmp/clone3_set_tid
> TAP version 13
> # clone3() syscall supported
> 1..29
> # /proc/sys/kernel/pid_max 32768
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 1 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 2 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 3 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 4 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 5 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 6 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 7 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 8 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 9 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 10 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 0 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
> ok 11 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 12 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 13 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to -1 and 0x20000000
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
> ok 14 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 1 and 0x0
> # File exists - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 1 says :-17 - expected -17
> ok 15 [830] Result (-17) matches expectation (-17)
> # [830] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 1 says :-22 - expected 0
> not ok 16 [830] Result (-22) is different than expected (0)
> # [830] Trying clone3() with CLONE_SET_TID to 32768 and 0x0
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
> ok 17 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 32768 and 0x20000000
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
> ok 18 [830] Result (-22) matches expectation (-22)
> # Child has PID 831
> # [830] Trying clone3() with CLONE_SET_TID to 831 and 0x0
> # I am the parent (830). My child's pid is 831
> # I am the child, my PID is 831 (expected 831)
> # [830] clone3() with CLONE_SET_TID 831 says :0 - expected 0
> ok 19 [830] Result (0) matches expectation (0)
> # [830] Trying clone3() with CLONE_SET_TID to 831 and 0x20000000
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 831 says :-22 - expected -22
> ok 20 [830] Result (-22) matches expectation (-22)
> # [830] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
> # Invalid argument - Failed to create new process
> # [830] clone3() with CLONE_SET_TID 1 says :-22 - expected 0
> not ok 21 [830] Result (-22) is different than expected (0)
> # unshare PID namespace
> Bail out! unshare(CLONE_NEWPID) failed: Invalid argument
> # Planned tests != run tests (29 != 21)
> # Pass 19 Fail 2 Xfail 0 Xpass 0 Skip 0 Error 0

kars@q800:/$ sudo ./clone3_set_tid
TAP version 13
# clone3() syscall supported
1..29
# /proc/sys/kernel/pid_max 32768
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 1 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 2 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 3 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 4 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 5 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 6 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 7 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 8 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 9 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 10 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 0 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 0 says :-22 - expected -22
ok 11 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 12 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 13 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to -1 and 0x20000000
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID -1 says :-22 - expected -22
ok 14 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 1 and 0x0
# File exists - Failed to create new process
# [435] clone3() with CLONE_SET_TID 1 says :-17 - expected -17
ok 15 [435] Result (-17) matches expectation (-17)
# [435] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# I am the child, my PID is 1 (expected 1)
# I am the parent (435). My child's pid is 436
# [435] clone3() with CLONE_SET_TID 1 says :0 - expected 0
ok 16 [435] Result (0) matches expectation (0)
# [435] Trying clone3() with CLONE_SET_TID to 32768 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
ok 17 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 32768 and 0x20000000
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
ok 18 [435] Result (-22) matches expectation (-22)
# Child has PID 437
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 32768 says :-22 - expected -22
ok 18 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 437 and 0x0
# I am the child, my PID is 437 (expected 437)
# I am the parent (435). My child's pid is 437
# [435] clone3() with CLONE_SET_TID 437 says :0 - expected 0
ok 19 [435] Result (0) matches expectation (0)
# [435] Trying clone3() with CLONE_SET_TID to 437 and 0x20000000
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 437 says :-22 - expected -22
ok 20 [435] Result (-22) matches expectation (-22)
# [435] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# I am the child, my PID is 1 (expected 1)
# I am the parent (435). My child's pid is 437
# [435] clone3() with CLONE_SET_TID 1 says :0 - expected 0
ok 21 [435] Result (0) matches expectation (0)
# unshare PID namespace
# [435] Trying clone3() with CLONE_SET_TID to 437 and 0x0
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 437 says :-22 - expected -22
ok 22 [435] Result (-22) matches expectation (-22)
# [1] Trying clone3() with CLONE_SET_TID to 43 and 0x0
# Invalid argument - Failed to create new process
# [1] clone3() with CLONE_SET_TID 43 says :-22 - expected -22
ok 23 [1] Result (-22) matches expectation (-22)
# [1] Trying clone3() with CLONE_SET_TID to 43 and 0x0
# I am the child, my PID is 43 (expected 43)
# I am the parent (1). My child's pid is 43
# [1] clone3() with CLONE_SET_TID 43 says :0 - expected 0
ok 24 [1] Result (0) matches expectation (0)
# Child in PID namespace has PID 1
# [1] Trying clone3() with CLONE_SET_TID to 2 and 0x0
# I am the child, my PID is 2 (expected 2)
# I am the parent (1). My child's pid is 2
# [1] clone3() with CLONE_SET_TID 2 says :0 - expected 0
ok 25 [1] Result (0) matches expectation (0)
# [1] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# Invalid argument - Failed to create new process
# [1] clone3() with CLONE_SET_TID 1 says :-22 - expected -22
ok 26 [1] Result (-22) matches expectation (-22)
# [1] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# Invalid argument - Failed to create new process
# [1] clone3() with CLONE_SET_TID 1 says :-22 - expected -22
ok 27 [1] Result (-22) matches expectation (-22)
# [1] Trying clone3() with CLONE_SET_TID to 1 and 0x20000000
# I am the child, my PID is 1 (expected 1)
# [1] Child is ready and waiting
# I am the parent (1). My child's pid is 42
# [1] clone3() with CLONE_SET_TID 1 says :0 - expected 0
ok 28 [1] Result (0) matches expectation (0)
# Invalid argument - Failed to create new process
# [435] clone3() with CLONE_SET_TID 437 says :-22 - expected -22
ok 22 [435] Result (-22) matches expectation (-22)
# [435] Child is ready and waiting
ok 29 PIDs in all namespaces as expected (437,42,1)
# Pass 29 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0

So those all pass too. Maybe your kernel configuration is not suited
for these tests (in which case I would expect them to fail at compile
time by the way, the test should assert that).

> atari:~# chroot /tmp /tmp/clone3_clear_sighand
> TAP version 13
> # clone3() syscall supported
> 1..1
> Bail out! Failed to clear signal handler for child process
> # Planned tests != run tests (1 != 0)
> # Pass 0 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
> atari:~#

That one fails the same way for me, but I don't think this is actually
a problem with the wiring up of the system call.
I tried debugging it, the child process exits at line 99 (the check
whether the SIGUSR1 signal handler is indeed cleared in the child):

94                      ret = sigaction(SIGUSR1, NULL, &act);
95                      if (ret < 0)
96                              exit(EXIT_FAILURE);
97
98                      if (act.sa_handler != SIG_DFL)
99                              exit(EXIT_FAILURE);          <--- failure point

Oh, I did have problems with gdb and the 'next' and 'nexti' commands,
they did not quite stop where I expected them too, they stopped
somewhere in libc assembly instead.
But that's probably unrelated.

Kind regards,

Kars.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2019-11-24 19:52 [PATCH] m68k: Wire up clone3() syscall Kars de Jong
  2019-11-25  9:12 ` Geert Uytterhoeven
@ 2020-01-12 16:06 ` Geert Uytterhoeven
  2020-01-13  9:10   ` Geert Uytterhoeven
  1 sibling, 1 reply; 15+ messages in thread
From: Geert Uytterhoeven @ 2020-01-12 16:06 UTC (permalink / raw)
  To: Kars de Jong; +Cc: Linux Kernel Mailing List, Linux/m68k

On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> Wire up the clone3() syscall for m68k. The special entry point is done in
> assembler as was done for clone() as well. This is needed because all
> registers need to be saved. The C wrapper then calls the generic
> sys_clone3() with the correct arguments.
>
> Tested on A1200 using the simple test program from:
>
>   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
>
> Cc: linux-m68k@vger.kernel.org
> Signed-off-by: Kars de Jong <jongk@linux-m68k.org>

Thanks, applied and queued for v5.6.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2020-01-12 16:06 ` Geert Uytterhoeven
@ 2020-01-13  9:10   ` Geert Uytterhoeven
  2020-01-13  9:18     ` Christian Brauner
  0 siblings, 1 reply; 15+ messages in thread
From: Geert Uytterhoeven @ 2020-01-13  9:10 UTC (permalink / raw)
  To: Kars de Jong
  Cc: Linux Kernel Mailing List, Linux/m68k, Christian Brauner,
	Amanieu d'Antras

On Sun, Jan 12, 2020 at 5:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > Wire up the clone3() syscall for m68k. The special entry point is done in
> > assembler as was done for clone() as well. This is needed because all
> > registers need to be saved. The C wrapper then calls the generic
> > sys_clone3() with the correct arguments.
> >
> > Tested on A1200 using the simple test program from:
> >
> >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> >
> > Cc: linux-m68k@vger.kernel.org
> > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
>
> Thanks, applied and queued for v5.6.

Which is now broken because of commit dd499f7a7e342702 ("clone3: ensure
copy_thread_tls is implemented") in v5.5-rc6 :-(

BTW, was this the reason for the failures at the end of
https://lore.kernel.org/lkml/CACz-3rhmUfxbfhznvA6NOF69SR49NDZwnkZ=Bmhw_cf4SkiadQ@mail.gmail.com/?

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2020-01-13  9:10   ` Geert Uytterhoeven
@ 2020-01-13  9:18     ` Christian Brauner
  2020-01-13  9:34       ` Geert Uytterhoeven
  0 siblings, 1 reply; 15+ messages in thread
From: Christian Brauner @ 2020-01-13  9:18 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k,
	Amanieu d'Antras

On Mon, Jan 13, 2020 at 10:10:26AM +0100, Geert Uytterhoeven wrote:
> On Sun, Jan 12, 2020 at 5:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > assembler as was done for clone() as well. This is needed because all
> > > registers need to be saved. The C wrapper then calls the generic
> > > sys_clone3() with the correct arguments.
> > >
> > > Tested on A1200 using the simple test program from:
> > >
> > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> > >
> > > Cc: linux-m68k@vger.kernel.org
> > > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
> >
> > Thanks, applied and queued for v5.6.
> 
> Which is now broken because of commit dd499f7a7e342702 ("clone3: ensure
> copy_thread_tls is implemented") in v5.5-rc6 :-(

Sorry, just for clarification what and how is it broken by 
dd499f7a7e342702 ("clone3: ensure > copy_thread_tls is implemented")
?

> 
> BTW, was this the reason for the failures at the end of
> https://lore.kernel.org/lkml/CACz-3rhmUfxbfhznvA6NOF69SR49NDZwnkZ=Bmhw_cf4SkiadQ@mail.gmail.com/?

Unlikely since CLONE_SETTLS is currently not covered by the
clone3()/process creation test suite because it is highly arch
dependent on how to retrieve the tls pointer. But we're going to add
tests soon I hope.

Thanks!
Christian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2020-01-13  9:18     ` Christian Brauner
@ 2020-01-13  9:34       ` Geert Uytterhoeven
  2020-01-13 10:17         ` Christian Brauner
  0 siblings, 1 reply; 15+ messages in thread
From: Geert Uytterhoeven @ 2020-01-13  9:34 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k,
	Amanieu d'Antras

Hi Christian,

On Mon, Jan 13, 2020 at 10:18 AM Christian Brauner
<christian.brauner@ubuntu.com> wrote:
> On Mon, Jan 13, 2020 at 10:10:26AM +0100, Geert Uytterhoeven wrote:
> > On Sun, Jan 12, 2020 at 5:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > > assembler as was done for clone() as well. This is needed because all
> > > > registers need to be saved. The C wrapper then calls the generic
> > > > sys_clone3() with the correct arguments.
> > > >
> > > > Tested on A1200 using the simple test program from:
> > > >
> > > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> > > >
> > > > Cc: linux-m68k@vger.kernel.org
> > > > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
> > >
> > > Thanks, applied and queued for v5.6.
> >
> > Which is now broken because of commit dd499f7a7e342702 ("clone3: ensure
> > copy_thread_tls is implemented") in v5.5-rc6 :-(
>
> Sorry, just for clarification what and how is it broken by
> dd499f7a7e342702 ("clone3: ensure > copy_thread_tls is implemented")
> ?

Because m68k does not implement copy_thread_tls() yet, and doesn't
select HAVE_COPY_THREAD_TLS yet.

Looking into fixing that...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2020-01-13  9:34       ` Geert Uytterhoeven
@ 2020-01-13 10:17         ` Christian Brauner
  2020-01-13 10:31           ` Geert Uytterhoeven
  0 siblings, 1 reply; 15+ messages in thread
From: Christian Brauner @ 2020-01-13 10:17 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k,
	Amanieu d'Antras

On Mon, Jan 13, 2020 at 10:34:35AM +0100, Geert Uytterhoeven wrote:
> Hi Christian,
> 
> On Mon, Jan 13, 2020 at 10:18 AM Christian Brauner
> <christian.brauner@ubuntu.com> wrote:
> > On Mon, Jan 13, 2020 at 10:10:26AM +0100, Geert Uytterhoeven wrote:
> > > On Sun, Jan 12, 2020 at 5:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > > > assembler as was done for clone() as well. This is needed because all
> > > > > registers need to be saved. The C wrapper then calls the generic
> > > > > sys_clone3() with the correct arguments.
> > > > >
> > > > > Tested on A1200 using the simple test program from:
> > > > >
> > > > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> > > > >
> > > > > Cc: linux-m68k@vger.kernel.org
> > > > > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
> > > >
> > > > Thanks, applied and queued for v5.6.
> > >
> > > Which is now broken because of commit dd499f7a7e342702 ("clone3: ensure
> > > copy_thread_tls is implemented") in v5.5-rc6 :-(
> >
> > Sorry, just for clarification what and how is it broken by
> > dd499f7a7e342702 ("clone3: ensure > copy_thread_tls is implemented")
> > ?
> 
> Because m68k does not implement copy_thread_tls() yet, and doesn't
> select HAVE_COPY_THREAD_TLS yet.

Oh right, sorry. I forgot that m68k has a patchset to enable clone3() up
for merging. I should've remembered that and warned you that we will
have to require copy_thread_tls() going forward. I hope the merge is
explanatory enough why we're doing it this way.

> 
> Looking into fixing that...

Thank you! Much appreciated!
Christian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] m68k: Wire up clone3() syscall
  2020-01-13 10:17         ` Christian Brauner
@ 2020-01-13 10:31           ` Geert Uytterhoeven
  0 siblings, 0 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2020-01-13 10:31 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Kars de Jong, Linux Kernel Mailing List, Linux/m68k,
	Amanieu d'Antras

Hi Christian,

On Mon, Jan 13, 2020 at 11:18 AM Christian Brauner
<christian.brauner@ubuntu.com> wrote:
> On Mon, Jan 13, 2020 at 10:34:35AM +0100, Geert Uytterhoeven wrote:
> > On Mon, Jan 13, 2020 at 10:18 AM Christian Brauner
> > <christian.brauner@ubuntu.com> wrote:
> > > On Mon, Jan 13, 2020 at 10:10:26AM +0100, Geert Uytterhoeven wrote:
> > > > On Sun, Jan 12, 2020 at 5:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > > > On Sun, Nov 24, 2019 at 8:52 PM Kars de Jong <jongk@linux-m68k.org> wrote:
> > > > > > Wire up the clone3() syscall for m68k. The special entry point is done in
> > > > > > assembler as was done for clone() as well. This is needed because all
> > > > > > registers need to be saved. The C wrapper then calls the generic
> > > > > > sys_clone3() with the correct arguments.
> > > > > >
> > > > > > Tested on A1200 using the simple test program from:
> > > > > >
> > > > > >   https://lore.kernel.org/lkml/20190716130631.tohj4ub54md25dys@brauner.io/
> > > > > >
> > > > > > Cc: linux-m68k@vger.kernel.org
> > > > > > Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
> > > > >
> > > > > Thanks, applied and queued for v5.6.
> > > >
> > > > Which is now broken because of commit dd499f7a7e342702 ("clone3: ensure
> > > > copy_thread_tls is implemented") in v5.5-rc6 :-(
> > >
> > > Sorry, just for clarification what and how is it broken by
> > > dd499f7a7e342702 ("clone3: ensure > copy_thread_tls is implemented")
> > > ?
> >
> > Because m68k does not implement copy_thread_tls() yet, and doesn't
> > select HAVE_COPY_THREAD_TLS yet.
>
> Oh right, sorry. I forgot that m68k has a patchset to enable clone3() up
> for merging. I should've remembered that and warned you that we will
> have to require copy_thread_tls() going forward. I hope the merge is
> explanatory enough why we're doing it this way.

Yeah, an early warning would have been nice...

> > Looking into fixing that...
>
> Thank you! Much appreciated!

Patch sent.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-24 19:52 [PATCH] m68k: Wire up clone3() syscall Kars de Jong
2019-11-25  9:12 ` Geert Uytterhoeven
2019-11-26 14:41   ` Christian Brauner
2019-11-26 15:29     ` Kars de Jong
2019-12-15 16:48       ` Geert Uytterhoeven
2019-12-15 17:01         ` John Paul Adrian Glaubitz
2019-12-15 20:06           ` Geert Uytterhoeven
2019-12-16 10:31         ` Christian Brauner
2019-12-18  9:57         ` Kars de Jong
2020-01-12 16:06 ` Geert Uytterhoeven
2020-01-13  9:10   ` Geert Uytterhoeven
2020-01-13  9:18     ` Christian Brauner
2020-01-13  9:34       ` Geert Uytterhoeven
2020-01-13 10:17         ` Christian Brauner
2020-01-13 10:31           ` Geert Uytterhoeven

Linux-m68k Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-m68k/0 linux-m68k/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-m68k linux-m68k/ https://lore.kernel.org/linux-m68k \
		linux-m68k@vger.kernel.org linux-m68k@lists.linux-m68k.org
	public-inbox-index linux-m68k

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-m68k


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git