diff mbox series

[2/2] pkey: correct the PKEY_DISABLE_ACCESS definitions on PowerPC

Message ID 20220411094048.1143292-2-liwang@redhat.com
State New
Headers show
Series [1/2] pkey01: print more info when write buff fail | expand

Commit Message

Li Wang April 11, 2022, 9:40 a.m. UTC
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jan Stancek April 11, 2022, 10:57 a.m. UTC | #1
On Mon, Apr 11, 2022 at 11:41 AM Li Wang <liwang@redhat.com> wrote:
>
> Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/pkeys/pkey.h b/testcases/kernel/syscalls/pkeys/pkey.h
> index 6e32326b6..6cda88ff1 100644
> --- a/testcases/kernel/syscalls/pkeys/pkey.h
> +++ b/testcases/kernel/syscalls/pkeys/pkey.h
> @@ -11,6 +11,13 @@
>  #include "lapi/syscalls.h"
>  #include "lapi/mmap.h"
>
> +#if defined(__powerpc__) || defined(__ppc__)
> +# undef PKEY_DISABLE_ACCESS
> +# define PKEY_DISABLE_ACCESS 0x3

Where does powerpc define PKEY_DISABLE_ACCESS as 0x3?

Comment in tools/testing/selftests/powerpc/include/pkeys.h says it's
older glibc that has this problem, but looking at latest glibc it
still defines it as 0x1:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/mman-shared.h;h=00a1f27c0ef51de1ec657071c5744e09299f7ff2;hb=HEAD#l41



> +# undef PKEY_DISABLE_WRITE
> +# define PKEY_DISABLE_WRITE  0x2
> +#endif
> +
>  #ifndef PKEY_DISABLE_ACCESS
>  # define PKEY_DISABLE_ACCESS 0x1
>  # define PKEY_DISABLE_WRITE  0x2
> --
> 2.31.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
Li Wang April 11, 2022, 12:35 p.m. UTC | #2
On Mon, Apr 11, 2022 at 6:57 PM Jan Stancek <jstancek@redhat.com> wrote:

> On Mon, Apr 11, 2022 at 11:41 AM Li Wang <liwang@redhat.com> wrote:
> >
> > Reference:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159
> >
> > Signed-off-by: Li Wang <liwang@redhat.com>
> > ---
> >  testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/testcases/kernel/syscalls/pkeys/pkey.h
> b/testcases/kernel/syscalls/pkeys/pkey.h
> > index 6e32326b6..6cda88ff1 100644
> > --- a/testcases/kernel/syscalls/pkeys/pkey.h
> > +++ b/testcases/kernel/syscalls/pkeys/pkey.h
> > @@ -11,6 +11,13 @@
> >  #include "lapi/syscalls.h"
> >  #include "lapi/mmap.h"
> >
> > +#if defined(__powerpc__) || defined(__ppc__)
> > +# undef PKEY_DISABLE_ACCESS
> > +# define PKEY_DISABLE_ACCESS 0x3
>
> Where does powerpc define PKEY_DISABLE_ACCESS as 0x3?
>

Good question, I previously thought that was officially defined as 0x3 on
PowerPC (per Ram's patch).

But after looking at 'powerpc/include/uapi/asm/mman.h' it still includes
header which define PKEY_DISABLE_ACCESS as 0x1.
    #include <asm-generic/mman-common.h>

@Ram Pai, could you explain why you're using 0x3 in kselftest?
Did I miss anything?
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/pkeys/pkey.h b/testcases/kernel/syscalls/pkeys/pkey.h
index 6e32326b6..6cda88ff1 100644
--- a/testcases/kernel/syscalls/pkeys/pkey.h
+++ b/testcases/kernel/syscalls/pkeys/pkey.h
@@ -11,6 +11,13 @@ 
 #include "lapi/syscalls.h"
 #include "lapi/mmap.h"
 
+#if defined(__powerpc__) || defined(__ppc__)
+# undef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x3
+# undef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE  0x2
+#endif
+
 #ifndef PKEY_DISABLE_ACCESS
 # define PKEY_DISABLE_ACCESS 0x1
 # define PKEY_DISABLE_WRITE  0x2