* [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-30 3:36 Pranith Kumar 2014-08-31 8:53 ` Geert Uytterhoeven 0 siblings, 1 reply; 21+ messages in thread From: Pranith Kumar @ 2014-08-30 3:36 UTC (permalink / raw) To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list I see that the three syscalls seccomp, getrandom and memfd_create are not wired because of which we get a warning while compilation. So I wired them up in this patch. What else needs to be done? I tried the memfd_test after compiling this kernel, but it is failing. What am I missing for this to work? Any advice is really appreciated! :) Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- arch/powerpc/include/asm/systbl.h | 3 +++ arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h index 542bc0f..7d8a600 100644 --- a/arch/powerpc/include/asm/systbl.h +++ b/arch/powerpc/include/asm/systbl.h @@ -362,3 +362,6 @@ SYSCALL(ni_syscall) /* sys_kcmp */ SYSCALL_SPU(sched_setattr) SYSCALL_SPU(sched_getattr) SYSCALL_SPU(renameat2) +SYSCALL_SPU(seccomp) +SYSCALL_SPU(getrandom) +SYSCALL_SPU(memfd_create) diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h index 5ce5552..4e9af3f 100644 --- a/arch/powerpc/include/asm/unistd.h +++ b/arch/powerpc/include/asm/unistd.h @@ -12,7 +12,7 @@ #include <uapi/asm/unistd.h> -#define __NR_syscalls 358 +#define __NR_syscalls 361 #define __NR__exit __NR_exit #define NR_syscalls __NR_syscalls diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h index 2d526f7..0688fc0 100644 --- a/arch/powerpc/include/uapi/asm/unistd.h +++ b/arch/powerpc/include/uapi/asm/unistd.h @@ -380,5 +380,8 @@ #define __NR_sched_setattr 355 #define __NR_sched_getattr 356 #define __NR_renameat2 357 +#define __NR_seccomp 358 +#define __NR_getrandom 359 +#define __NR_memfd_create 360 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ -- 2.1.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-30 3:36 [RFC PATCH] powerpc: Wire up three syscalls Pranith Kumar @ 2014-08-31 8:53 ` Geert Uytterhoeven 0 siblings, 0 replies; 21+ messages in thread From: Geert Uytterhoeven @ 2014-08-31 8:53 UTC (permalink / raw) To: Pranith Kumar Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi Pranith, On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: > I see that the three syscalls seccomp, getrandom and memfd_create are not wired > because of which we get a warning while compilation. > > So I wired them up in this patch. What else needs to be done? I tried the > memfd_test after compiling this kernel, but it is failing. What am I missing for > this to work? Any advice is really appreciated! :) Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in tools/testing/selftests/memfd/Makefile? 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] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-31 8:53 ` Geert Uytterhoeven 0 siblings, 0 replies; 21+ messages in thread From: Geert Uytterhoeven @ 2014-08-31 8:53 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Paul Mackerras, Anton Blanchard, Andrew Morton, open list:LINUX FOR POWERPC... Hi Pranith, On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: > I see that the three syscalls seccomp, getrandom and memfd_create are not wired > because of which we get a warning while compilation. > > So I wired them up in this patch. What else needs to be done? I tried the > memfd_test after compiling this kernel, but it is failing. What am I missing for > this to work? Any advice is really appreciated! :) Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in tools/testing/selftests/memfd/Makefile? 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] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-31 8:53 ` Geert Uytterhoeven @ 2014-08-31 12:52 ` Pranith Kumar -1 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-08-31 12:52 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi Geert, On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Hi Pranith, > > On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >> because of which we get a warning while compilation. >> >> So I wired them up in this patch. What else needs to be done? I tried the >> memfd_test after compiling this kernel, but it is failing. What am I missing for >> this to work? Any advice is really appreciated! :) > > Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in > tools/testing/selftests/memfd/Makefile? > I removed that check and compiled memfd_test.c by hand. This is the following error which I get when I run the test: $ ./memfd_test memfd: CREATE memfd: BASIC 10 != 0 = GET_SEALS(3) Aborted This is basically when checking the seals which we already added. It should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. What else needs to be done for this to properly work? I see that for m68k, you just wired it up like in this patch. Did it work after that? -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-31 12:52 ` Pranith Kumar 0 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-08-31 12:52 UTC (permalink / raw) To: Geert Uytterhoeven Cc: open list, Fabian Frederick, Paul Mackerras, Anton Blanchard, Andrew Morton, open list:LINUX FOR POWERPC... Hi Geert, On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Hi Pranith, > > On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >> because of which we get a warning while compilation. >> >> So I wired them up in this patch. What else needs to be done? I tried the >> memfd_test after compiling this kernel, but it is failing. What am I missing for >> this to work? Any advice is really appreciated! :) > > Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in > tools/testing/selftests/memfd/Makefile? > I removed that check and compiled memfd_test.c by hand. This is the following error which I get when I run the test: $ ./memfd_test memfd: CREATE memfd: BASIC 10 != 0 = GET_SEALS(3) Aborted This is basically when checking the seals which we already added. It should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. What else needs to be done for this to properly work? I see that for m68k, you just wired it up like in this patch. Did it work after that? -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-31 12:52 ` Pranith Kumar @ 2014-08-31 14:14 ` Geert Uytterhoeven -1 siblings, 0 replies; 21+ messages in thread From: Geert Uytterhoeven @ 2014-08-31 14:14 UTC (permalink / raw) To: Pranith Kumar Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi Pranith, On Sun, Aug 31, 2014 at 2:52 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven > <geert@linux-m68k.org> wrote: >> On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >>> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >>> because of which we get a warning while compilation. >>> >>> So I wired them up in this patch. What else needs to be done? I tried the >>> memfd_test after compiling this kernel, but it is failing. What am I missing for >>> this to work? Any advice is really appreciated! :) >> >> Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in >> tools/testing/selftests/memfd/Makefile? > > I removed that check and compiled memfd_test.c by hand. This is the > following error which I get when I run the test: > > $ ./memfd_test > memfd: CREATE > memfd: BASIC > 10 != 0 = GET_SEALS(3) > Aborted > > This is basically when checking the seals which we already added. It > should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. So it does fail. > What else needs to be done for this to properly work? I see that for > m68k, you just wired it up like in this patch. Did it work after that? To be honest, I didn't run any tests. I had a few spare minutes, so I wanted to give it a try, but "make kselftest" doesn't work with building in a separate directory (O=), doesn't support CROSS_COMPILE=, etc... So I gave up (for now). 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] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-31 14:14 ` Geert Uytterhoeven 0 siblings, 0 replies; 21+ messages in thread From: Geert Uytterhoeven @ 2014-08-31 14:14 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Paul Mackerras, Anton Blanchard, Andrew Morton, open list:LINUX FOR POWERPC... Hi Pranith, On Sun, Aug 31, 2014 at 2:52 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven > <geert@linux-m68k.org> wrote: >> On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >>> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >>> because of which we get a warning while compilation. >>> >>> So I wired them up in this patch. What else needs to be done? I tried the >>> memfd_test after compiling this kernel, but it is failing. What am I missing for >>> this to work? Any advice is really appreciated! :) >> >> Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in >> tools/testing/selftests/memfd/Makefile? > > I removed that check and compiled memfd_test.c by hand. This is the > following error which I get when I run the test: > > $ ./memfd_test > memfd: CREATE > memfd: BASIC > 10 != 0 = GET_SEALS(3) > Aborted > > This is basically when checking the seals which we already added. It > should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. So it does fail. > What else needs to be done for this to properly work? I see that for > m68k, you just wired it up like in this patch. Did it work after that? To be honest, I didn't run any tests. I had a few spare minutes, so I wanted to give it a try, but "make kselftest" doesn't work with building in a separate directory (O=), doesn't support CROSS_COMPILE=, etc... So I gave up (for now). 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] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-31 12:52 ` Pranith Kumar @ 2014-08-31 14:34 ` David Herrmann -1 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-08-31 14:34 UTC (permalink / raw) To: Pranith Kumar Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi On Sun, Aug 31, 2014 at 2:52 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > Hi Geert, > > On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven > <geert@linux-m68k.org> wrote: >> Hi Pranith, >> >> On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >>> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >>> because of which we get a warning while compilation. >>> >>> So I wired them up in this patch. What else needs to be done? I tried the >>> memfd_test after compiling this kernel, but it is failing. What am I missing for >>> this to work? Any advice is really appreciated! :) >> >> Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in >> tools/testing/selftests/memfd/Makefile? >> > > I removed that check and compiled memfd_test.c by hand. This is the > following error which I get when I run the test: > > $ ./memfd_test > memfd: CREATE > memfd: BASIC > 10 != 0 = GET_SEALS(3) > Aborted > > This is basically when checking the seals which we already added. It > should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. > > What else needs to be done for this to properly work? I see that for > m68k, you just wired it up like in this patch. Did it work after that? The only arch-dependent code for memfd_test.c is the syscall invocation: memfd_create(const char *name, unsigned int flags); via glibc as: syscall(__NR_memfd_create, name, flags); Can you debug your test-run (maybe via simple printk() in mm/shmem.c memfd_create()) and see what's going wrong there? Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-31 14:34 ` David Herrmann 0 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-08-31 14:34 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... Hi On Sun, Aug 31, 2014 at 2:52 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > Hi Geert, > > On Sun, Aug 31, 2014 at 4:53 AM, Geert Uytterhoeven > <geert@linux-m68k.org> wrote: >> Hi Pranith, >> >> On Sat, Aug 30, 2014 at 5:36 AM, Pranith Kumar <bobby.prani@gmail.com> wrote: >>> I see that the three syscalls seccomp, getrandom and memfd_create are not wired >>> because of which we get a warning while compilation. >>> >>> So I wired them up in this patch. What else needs to be done? I tried the >>> memfd_test after compiling this kernel, but it is failing. What am I missing for >>> this to work? Any advice is really appreciated! :) >> >> Did it fail due to the (silly) "ifeq ($(ARCH),X86)" checks in >> tools/testing/selftests/memfd/Makefile? >> > > I removed that check and compiled memfd_test.c by hand. This is the > following error which I get when I run the test: > > $ ./memfd_test > memfd: CREATE > memfd: BASIC > 10 != 0 = GET_SEALS(3) > Aborted > > This is basically when checking the seals which we already added. It > should return 10 (F_SEAL_SHRINK | F_SEAL_WRITE), instead it is returning 0. > > What else needs to be done for this to properly work? I see that for > m68k, you just wired it up like in this patch. Did it work after that? The only arch-dependent code for memfd_test.c is the syscall invocation: memfd_create(const char *name, unsigned int flags); via glibc as: syscall(__NR_memfd_create, name, flags); Can you debug your test-run (maybe via simple printk() in mm/shmem.c memfd_create()) and see what's going wrong there? Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-31 14:34 ` David Herrmann @ 2014-08-31 17:51 ` Pranith Kumar -1 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-08-31 17:51 UTC (permalink / raw) To: David Herrmann Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list On 08/31/2014 10:34 AM, David Herrmann wrote: > The only arch-dependent code for memfd_test.c is the syscall invocation: > memfd_create(const char *name, unsigned int flags); > via glibc as: > syscall(__NR_memfd_create, name, flags); > > Can you debug your test-run (maybe via simple printk() in mm/shmem.c > memfd_create()) and see what's going wrong there? > Hi David, I figured out the problem. I am on a 32-bit system and using u64 for flags in fcntl() is the cause of the problem. Will you accept a patch making the test work on 32-bit systems as below? Thanks! -- Pranith From: Pranith Kumar <bobby.prani@gmail.com> Date: Sun, 31 Aug 2014 13:38:07 -0400 Subject: [PATCH] memfd_test: Make it work on 32-bit systems This test currently fails on 32-bit systems since we use u64 type to pass the flags to fcntl. This commit changes this to use u32 type for flags to fcntl making it work on 32-bit systems. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- tools/testing/selftests/memfd/memfd_test.c | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 3634c90..77e56ff 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags) } } -static __u64 mfd_assert_get_seals(int fd) +static __u32 mfd_assert_get_seals(int fd) { - long r; + int r; r = fcntl(fd, F_GET_SEALS); if (r < 0) { @@ -72,36 +72,36 @@ static __u64 mfd_assert_get_seals(int fd) return r; } -static void mfd_assert_has_seals(int fd, __u64 seals) +static void mfd_assert_has_seals(int fd, __u32 seals) { - __u64 s; + __u32 s; s = mfd_assert_get_seals(fd); if (s != seals) { - printf("%llu != %llu = GET_SEALS(%d)\n", - (unsigned long long)seals, (unsigned long long)s, fd); + printf("%lu != %lu = GET_SEALS(%d)\n", + (unsigned long)seals, (unsigned long)s, fd); abort(); } } -static void mfd_assert_add_seals(int fd, __u64 seals) +static void mfd_assert_add_seals(int fd, __u32 seals) { - long r; - __u64 s; + int r; + __u32 s; s = mfd_assert_get_seals(fd); r = fcntl(fd, F_ADD_SEALS, seals); if (r < 0) { - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %lu -> %lu) failed: %m\n", + fd, (unsigned long)s, (unsigned long)seals); abort(); } } -static void mfd_fail_add_seals(int fd, __u64 seals) +static void mfd_fail_add_seals(int fd, __u32 seals) { - long r; - __u64 s; + int r; + __u32 s; r = fcntl(fd, F_GET_SEALS); if (r < 0) @@ -111,8 +111,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals) r = fcntl(fd, F_ADD_SEALS, seals); if (r >= 0) { - printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %lu -> %lu) didn't fail as expected\n", + fd, (unsigned long)s, (unsigned long)seals); abort(); } } -- 2.1.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-08-31 17:51 ` Pranith Kumar 0 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-08-31 17:51 UTC (permalink / raw) To: David Herrmann Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... On 08/31/2014 10:34 AM, David Herrmann wrote: > The only arch-dependent code for memfd_test.c is the syscall invocation: > memfd_create(const char *name, unsigned int flags); > via glibc as: > syscall(__NR_memfd_create, name, flags); > > Can you debug your test-run (maybe via simple printk() in mm/shmem.c > memfd_create()) and see what's going wrong there? > Hi David, I figured out the problem. I am on a 32-bit system and using u64 for flags in fcntl() is the cause of the problem. Will you accept a patch making the test work on 32-bit systems as below? Thanks! -- Pranith From: Pranith Kumar <bobby.prani@gmail.com> Date: Sun, 31 Aug 2014 13:38:07 -0400 Subject: [PATCH] memfd_test: Make it work on 32-bit systems This test currently fails on 32-bit systems since we use u64 type to pass the flags to fcntl. This commit changes this to use u32 type for flags to fcntl making it work on 32-bit systems. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- tools/testing/selftests/memfd/memfd_test.c | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 3634c90..77e56ff 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags) } } -static __u64 mfd_assert_get_seals(int fd) +static __u32 mfd_assert_get_seals(int fd) { - long r; + int r; r = fcntl(fd, F_GET_SEALS); if (r < 0) { @@ -72,36 +72,36 @@ static __u64 mfd_assert_get_seals(int fd) return r; } -static void mfd_assert_has_seals(int fd, __u64 seals) +static void mfd_assert_has_seals(int fd, __u32 seals) { - __u64 s; + __u32 s; s = mfd_assert_get_seals(fd); if (s != seals) { - printf("%llu != %llu = GET_SEALS(%d)\n", - (unsigned long long)seals, (unsigned long long)s, fd); + printf("%lu != %lu = GET_SEALS(%d)\n", + (unsigned long)seals, (unsigned long)s, fd); abort(); } } -static void mfd_assert_add_seals(int fd, __u64 seals) +static void mfd_assert_add_seals(int fd, __u32 seals) { - long r; - __u64 s; + int r; + __u32 s; s = mfd_assert_get_seals(fd); r = fcntl(fd, F_ADD_SEALS, seals); if (r < 0) { - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %lu -> %lu) failed: %m\n", + fd, (unsigned long)s, (unsigned long)seals); abort(); } } -static void mfd_fail_add_seals(int fd, __u64 seals) +static void mfd_fail_add_seals(int fd, __u32 seals) { - long r; - __u64 s; + int r; + __u32 s; r = fcntl(fd, F_GET_SEALS); if (r < 0) @@ -111,8 +111,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals) r = fcntl(fd, F_ADD_SEALS, seals); if (r >= 0) { - printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %lu -> %lu) didn't fail as expected\n", + fd, (unsigned long)s, (unsigned long)seals); abort(); } } -- 2.1.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-08-31 17:51 ` Pranith Kumar @ 2014-09-01 11:33 ` David Herrmann -1 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 11:33 UTC (permalink / raw) To: Pranith Kumar Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi On Sun, Aug 31, 2014 at 7:51 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > > On 08/31/2014 10:34 AM, David Herrmann wrote: >> The only arch-dependent code for memfd_test.c is the syscall invocation: >> memfd_create(const char *name, unsigned int flags); >> via glibc as: >> syscall(__NR_memfd_create, name, flags); >> >> Can you debug your test-run (maybe via simple printk() in mm/shmem.c >> memfd_create()) and see what's going wrong there? >> > Hi David, > > I figured out the problem. I am on a 32-bit system and using u64 for flags in fcntl() is the cause of the problem. Will you accept a patch making the test work on 32-bit systems as below? > > Thanks! > -- > Pranith > > From: Pranith Kumar <bobby.prani@gmail.com> > Date: Sun, 31 Aug 2014 13:38:07 -0400 > Subject: [PATCH] memfd_test: Make it work on 32-bit systems > > This test currently fails on 32-bit systems since we use u64 type to pass the > flags to fcntl. > > This commit changes this to use u32 type for flags to fcntl making it work on > 32-bit systems. Nice catch. We changed 'flags' from u64 to "unsigned int" in the last revision of the series. Patch looks good, but I'd prefer using "unsigned int" as type, instead of __u32. Just to be consistent with the syscall interface. The return type of F_GET_SEALS is actually "int" and the MSB is reserved for signed error codes, so you can savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in mfd_assert_get_seals(). Thanks David > Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> > --- > tools/testing/selftests/memfd/memfd_test.c | 32 +++++++++++++++--------------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c > index 3634c90..77e56ff 100644 > --- a/tools/testing/selftests/memfd/memfd_test.c > +++ b/tools/testing/selftests/memfd/memfd_test.c > @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags) > } > } > > -static __u64 mfd_assert_get_seals(int fd) > +static __u32 mfd_assert_get_seals(int fd) > { > - long r; > + int r; > > r = fcntl(fd, F_GET_SEALS); > if (r < 0) { > @@ -72,36 +72,36 @@ static __u64 mfd_assert_get_seals(int fd) > return r; > } > > -static void mfd_assert_has_seals(int fd, __u64 seals) > +static void mfd_assert_has_seals(int fd, __u32 seals) > { > - __u64 s; > + __u32 s; > > s = mfd_assert_get_seals(fd); > if (s != seals) { > - printf("%llu != %llu = GET_SEALS(%d)\n", > - (unsigned long long)seals, (unsigned long long)s, fd); > + printf("%lu != %lu = GET_SEALS(%d)\n", > + (unsigned long)seals, (unsigned long)s, fd); > abort(); > } > } > > -static void mfd_assert_add_seals(int fd, __u64 seals) > +static void mfd_assert_add_seals(int fd, __u32 seals) > { > - long r; > - __u64 s; > + int r; > + __u32 s; > > s = mfd_assert_get_seals(fd); > r = fcntl(fd, F_ADD_SEALS, seals); > if (r < 0) { > - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", > - fd, (unsigned long long)s, (unsigned long long)seals); > + printf("ADD_SEALS(%d, %lu -> %lu) failed: %m\n", > + fd, (unsigned long)s, (unsigned long)seals); > abort(); > } > } > > -static void mfd_fail_add_seals(int fd, __u64 seals) > +static void mfd_fail_add_seals(int fd, __u32 seals) > { > - long r; > - __u64 s; > + int r; > + __u32 s; > > r = fcntl(fd, F_GET_SEALS); > if (r < 0) > @@ -111,8 +111,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals) > > r = fcntl(fd, F_ADD_SEALS, seals); > if (r >= 0) { > - printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", > - fd, (unsigned long long)s, (unsigned long long)seals); > + printf("ADD_SEALS(%d, %lu -> %lu) didn't fail as expected\n", > + fd, (unsigned long)s, (unsigned long)seals); > abort(); > } > } > -- > 2.1.0 > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-09-01 11:33 ` David Herrmann 0 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 11:33 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... Hi On Sun, Aug 31, 2014 at 7:51 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > > On 08/31/2014 10:34 AM, David Herrmann wrote: >> The only arch-dependent code for memfd_test.c is the syscall invocation: >> memfd_create(const char *name, unsigned int flags); >> via glibc as: >> syscall(__NR_memfd_create, name, flags); >> >> Can you debug your test-run (maybe via simple printk() in mm/shmem.c >> memfd_create()) and see what's going wrong there? >> > Hi David, > > I figured out the problem. I am on a 32-bit system and using u64 for flags in fcntl() is the cause of the problem. Will you accept a patch making the test work on 32-bit systems as below? > > Thanks! > -- > Pranith > > From: Pranith Kumar <bobby.prani@gmail.com> > Date: Sun, 31 Aug 2014 13:38:07 -0400 > Subject: [PATCH] memfd_test: Make it work on 32-bit systems > > This test currently fails on 32-bit systems since we use u64 type to pass the > flags to fcntl. > > This commit changes this to use u32 type for flags to fcntl making it work on > 32-bit systems. Nice catch. We changed 'flags' from u64 to "unsigned int" in the last revision of the series. Patch looks good, but I'd prefer using "unsigned int" as type, instead of __u32. Just to be consistent with the syscall interface. The return type of F_GET_SEALS is actually "int" and the MSB is reserved for signed error codes, so you can savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in mfd_assert_get_seals(). Thanks David > Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> > --- > tools/testing/selftests/memfd/memfd_test.c | 32 +++++++++++++++--------------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c > index 3634c90..77e56ff 100644 > --- a/tools/testing/selftests/memfd/memfd_test.c > +++ b/tools/testing/selftests/memfd/memfd_test.c > @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags) > } > } > > -static __u64 mfd_assert_get_seals(int fd) > +static __u32 mfd_assert_get_seals(int fd) > { > - long r; > + int r; > > r = fcntl(fd, F_GET_SEALS); > if (r < 0) { > @@ -72,36 +72,36 @@ static __u64 mfd_assert_get_seals(int fd) > return r; > } > > -static void mfd_assert_has_seals(int fd, __u64 seals) > +static void mfd_assert_has_seals(int fd, __u32 seals) > { > - __u64 s; > + __u32 s; > > s = mfd_assert_get_seals(fd); > if (s != seals) { > - printf("%llu != %llu = GET_SEALS(%d)\n", > - (unsigned long long)seals, (unsigned long long)s, fd); > + printf("%lu != %lu = GET_SEALS(%d)\n", > + (unsigned long)seals, (unsigned long)s, fd); > abort(); > } > } > > -static void mfd_assert_add_seals(int fd, __u64 seals) > +static void mfd_assert_add_seals(int fd, __u32 seals) > { > - long r; > - __u64 s; > + int r; > + __u32 s; > > s = mfd_assert_get_seals(fd); > r = fcntl(fd, F_ADD_SEALS, seals); > if (r < 0) { > - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", > - fd, (unsigned long long)s, (unsigned long long)seals); > + printf("ADD_SEALS(%d, %lu -> %lu) failed: %m\n", > + fd, (unsigned long)s, (unsigned long)seals); > abort(); > } > } > > -static void mfd_fail_add_seals(int fd, __u64 seals) > +static void mfd_fail_add_seals(int fd, __u32 seals) > { > - long r; > - __u64 s; > + int r; > + __u32 s; > > r = fcntl(fd, F_GET_SEALS); > if (r < 0) > @@ -111,8 +111,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals) > > r = fcntl(fd, F_ADD_SEALS, seals); > if (r >= 0) { > - printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", > - fd, (unsigned long long)s, (unsigned long long)seals); > + printf("ADD_SEALS(%d, %lu -> %lu) didn't fail as expected\n", > + fd, (unsigned long)s, (unsigned long)seals); > abort(); > } > } > -- > 2.1.0 > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-09-01 11:33 ` David Herrmann @ 2014-09-01 15:21 ` Pranith Kumar -1 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-09-01 15:21 UTC (permalink / raw) To: David Herrmann Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi David, On Mon, Sep 1, 2014 at 7:33 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > > Nice catch. We changed 'flags' from u64 to "unsigned int" in the last > revision of the series. Patch looks good, but I'd prefer using > "unsigned int" as type, instead of __u32. Just to be consistent with > the syscall interface. The return type of F_GET_SEALS is actually > "int" and the MSB is reserved for signed error codes, so you can > savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in > mfd_assert_get_seals(). > OK. Should I send a new patch with these changes or do you have one line up already? -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-09-01 15:21 ` Pranith Kumar 0 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-09-01 15:21 UTC (permalink / raw) To: David Herrmann Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... Hi David, On Mon, Sep 1, 2014 at 7:33 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > > Nice catch. We changed 'flags' from u64 to "unsigned int" in the last > revision of the series. Patch looks good, but I'd prefer using > "unsigned int" as type, instead of __u32. Just to be consistent with > the syscall interface. The return type of F_GET_SEALS is actually > "int" and the MSB is reserved for signed error codes, so you can > savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in > mfd_assert_get_seals(). > OK. Should I send a new patch with these changes or do you have one line up already? -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-09-01 15:21 ` Pranith Kumar @ 2014-09-01 15:31 ` David Herrmann -1 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 15:31 UTC (permalink / raw) To: Pranith Kumar Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi On Mon, Sep 1, 2014 at 5:21 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > Hi David, > > On Mon, Sep 1, 2014 at 7:33 AM, David Herrmann <dh.herrmann@gmail.com> wrote: >> >> Nice catch. We changed 'flags' from u64 to "unsigned int" in the last >> revision of the series. Patch looks good, but I'd prefer using >> "unsigned int" as type, instead of __u32. Just to be consistent with >> the syscall interface. The return type of F_GET_SEALS is actually >> "int" and the MSB is reserved for signed error codes, so you can >> savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in >> mfd_assert_get_seals(). >> > > OK. Should I send a new patch with these changes or do you have one > line up already? I'd appreciate if you can resend it. Btw., the original patch (wire up syscalls) can be applied unchanged. Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-09-01 15:31 ` David Herrmann 0 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 15:31 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... Hi On Mon, Sep 1, 2014 at 5:21 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > Hi David, > > On Mon, Sep 1, 2014 at 7:33 AM, David Herrmann <dh.herrmann@gmail.com> wrote: >> >> Nice catch. We changed 'flags' from u64 to "unsigned int" in the last >> revision of the series. Patch looks good, but I'd prefer using >> "unsigned int" as type, instead of __u32. Just to be consistent with >> the syscall interface. The return type of F_GET_SEALS is actually >> "int" and the MSB is reserved for signed error codes, so you can >> savely use "int r = fcntl(fd, F_GET_SEALS, 0)" in >> mfd_assert_get_seals(). >> > > OK. Should I send a new patch with these changes or do you have one > line up already? I'd appreciate if you can resend it. Btw., the original patch (wire up syscalls) can be applied unchanged. Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-09-01 15:31 ` David Herrmann @ 2014-09-01 17:16 ` Pranith Kumar -1 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-09-01 17:16 UTC (permalink / raw) To: David Herrmann Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list On Mon, Sep 1, 2014 at 11:31 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > > Btw., the original patch (wire up syscalls) can be applied unchanged. > Great! Can I use that as an Ack-by? I will send in the patch with updated changelog. -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-09-01 17:16 ` Pranith Kumar 0 siblings, 0 replies; 21+ messages in thread From: Pranith Kumar @ 2014-09-01 17:16 UTC (permalink / raw) To: David Herrmann Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... On Mon, Sep 1, 2014 at 11:31 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > > Btw., the original patch (wire up syscalls) can be applied unchanged. > Great! Can I use that as an Ack-by? I will send in the patch with updated changelog. -- Pranith ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls 2014-09-01 17:16 ` Pranith Kumar @ 2014-09-01 17:28 ` David Herrmann -1 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 17:28 UTC (permalink / raw) To: Pranith Kumar Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Anton Blanchard, Fabian Frederick, Andrew Morton, open list:LINUX FOR POWERPC..., open list Hi On Mon, Sep 1, 2014 at 7:16 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > On Mon, Sep 1, 2014 at 11:31 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > >> >> Btw., the original patch (wire up syscalls) can be applied unchanged. >> > > Great! Can I use that as an Ack-by? I will send in the patch with > updated changelog. Sure, go ahead! This syscall patch is: Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC PATCH] powerpc: Wire up three syscalls @ 2014-09-01 17:28 ` David Herrmann 0 siblings, 0 replies; 21+ messages in thread From: David Herrmann @ 2014-09-01 17:28 UTC (permalink / raw) To: Pranith Kumar Cc: open list, Fabian Frederick, Geert Uytterhoeven, Anton Blanchard, Paul Mackerras, Andrew Morton, open list:LINUX FOR POWERPC... Hi On Mon, Sep 1, 2014 at 7:16 PM, Pranith Kumar <bobby.prani@gmail.com> wrote: > On Mon, Sep 1, 2014 at 11:31 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > >> >> Btw., the original patch (wire up syscalls) can be applied unchanged. >> > > Great! Can I use that as an Ack-by? I will send in the patch with > updated changelog. Sure, go ahead! This syscall patch is: Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Thanks David ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2014-09-01 17:28 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-08-30 3:36 [RFC PATCH] powerpc: Wire up three syscalls Pranith Kumar 2014-08-31 8:53 ` Geert Uytterhoeven 2014-08-31 8:53 ` Geert Uytterhoeven 2014-08-31 12:52 ` Pranith Kumar 2014-08-31 12:52 ` Pranith Kumar 2014-08-31 14:14 ` Geert Uytterhoeven 2014-08-31 14:14 ` Geert Uytterhoeven 2014-08-31 14:34 ` David Herrmann 2014-08-31 14:34 ` David Herrmann 2014-08-31 17:51 ` Pranith Kumar 2014-08-31 17:51 ` Pranith Kumar 2014-09-01 11:33 ` David Herrmann 2014-09-01 11:33 ` David Herrmann 2014-09-01 15:21 ` Pranith Kumar 2014-09-01 15:21 ` Pranith Kumar 2014-09-01 15:31 ` David Herrmann 2014-09-01 15:31 ` David Herrmann 2014-09-01 17:16 ` Pranith Kumar 2014-09-01 17:16 ` Pranith Kumar 2014-09-01 17:28 ` David Herrmann 2014-09-01 17:28 ` David Herrmann
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.