diff mbox

[RFC] powerpc: Wire up three syscalls

Message ID 54036090.1050104@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Pranith Kumar Aug. 31, 2014, 5:51 p.m. UTC
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(-)

Comments

David Herrmann Sept. 1, 2014, 11:33 a.m. UTC | #1
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
>
Pranith Kumar Sept. 1, 2014, 3:21 p.m. UTC | #2
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?
David Herrmann Sept. 1, 2014, 3:31 p.m. UTC | #3
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
Pranith Kumar Sept. 1, 2014, 5:16 p.m. UTC | #4
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.
David Herrmann Sept. 1, 2014, 5:28 p.m. UTC | #5
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
diff mbox

Patch

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();
     }
 }