LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
@ 2018-05-08 9:14 Li Zhijian
2018-05-08 9:14 ` [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set' Li Zhijian
2018-05-08 16:25 ` [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Dave Hansen
0 siblings, 2 replies; 10+ messages in thread
From: Li Zhijian @ 2018-05-08 9:14 UTC (permalink / raw)
To: shuah, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, dave.hansen,
linux-kernel, philip.li, leist.fnst, zhijianx.li, Li Zhijian
SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
fix the following issue:
-------------------
root@vm-lkp-nex04-4G-5 /usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86# make
gcc -m32 -o /usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_32 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 protection_keys.c -lrt -ldl -lm
gcc -m64 -o /usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_64 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 protection_keys.c -lrt -ldl
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
#define SEGV_BNDERR 3 /* failed address bound checks */
^
In file included from /usr/include/signal.h:58:0,
from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:117:0: note: this is the location of the previous definition
# define SEGV_BNDERR SEGV_BNDERR
^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
#define SEGV_PKUERR 4
^
In file included from /usr/include/signal.h:58:0,
from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:119:0: note: this is the location of the previous definition
# define SEGV_PKUERR SEGV_PKUERR
^
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
#define SEGV_BNDERR 3 /* failed address bound checks */
^
In file included from /usr/include/signal.h:58:0,
from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:117:0: note: this is the location of the previous definition
# define SEGV_BNDERR SEGV_BNDERR
^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
#define SEGV_PKUERR 4
^
In file included from /usr/include/signal.h:58:0,
from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:119:0: note: this is the location of the previous definition
# define SEGV_PKUERR SEGV_PKUERR
^
-------------------
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
tools/testing/selftests/x86/protection_keys.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
index f15aa5a..757bb16 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -225,8 +225,12 @@ void dump_mem(void *dumpme, int len_bytes)
}
}
-#define SEGV_BNDERR 3 /* failed address bound checks */
-#define SEGV_PKUERR 4
+#ifndef SEGV_BNDERR
+# define SEGV_BNDERR 3 /* failed address bound checks */
+#endif
+#ifndef SEGV_PKUERR
+# define SEGV_PKUERR 4
+#endif
static char *si_code_str(int si_code)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'
2018-05-08 9:14 [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Li Zhijian
@ 2018-05-08 9:14 ` Li Zhijian
2018-05-08 16:30 ` Dave Hansen
2018-05-08 16:25 ` [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Dave Hansen
1 sibling, 1 reply; 10+ messages in thread
From: Li Zhijian @ 2018-05-08 9:14 UTC (permalink / raw)
To: shuah, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, dave.hansen,
linux-kernel, philip.li, leist.fnst, zhijianx.li, Li Zhijian
pkey_get() and pkey_set() are implemented since glibc-2.27, here just
rename pkey_get|pkey_set to _pkey_get|_pkey_set simply
the compiling errors are like:
------------
protection_keys.c:399:5: error: conflicting types for 'pkey_get'
u32 pkey_get(int pkey, unsigned long flags)
^
In file included from /usr/include/bits/mman-linux.h:115:0,
from /usr/include/bits/mman.h:45,
from /usr/include/sys/mman.h:41,
from protection_keys.c:37:
/usr/include/bits/mman-shared.h:64:5: note: previous declaration of 'pkey_get' was here
int pkey_get (int __key) __THROW;
^
protection_keys.c:421:5: error: conflicting types for 'pkey_set'
int pkey_set(int pkey, unsigned long rights, unsigned long flags)
^
In file included from /usr/include/bits/mman-linux.h:115:0,
from /usr/include/bits/mman.h:45,
from /usr/include/sys/mman.h:41,
from protection_keys.c:37:
/usr/include/bits/mman-shared.h:60:5: note: previous declaration of 'pkey_set' was here
int pkey_set (int __key, unsigned int __access_rights) __THROW;
^
------------
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
tools/testing/selftests/x86/protection_keys.c | 32 +++++++++++++++------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
index 757bb16..ccbd81f 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -397,10 +397,14 @@ pid_t fork_lazy_child(void)
return forkret;
}
-#define PKEY_DISABLE_ACCESS 0x1
-#define PKEY_DISABLE_WRITE 0x2
+#ifndef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x1
+#endif
+#ifndef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE 0x2
+#endif
-u32 pkey_get(int pkey, unsigned long flags)
+u32 _pkey_get(int pkey, unsigned long flags)
{
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 pkru = __rdpkru();
@@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
return masked_pkru;
}
-int pkey_set(int pkey, unsigned long rights, unsigned long flags)
+int _pkey_set(int pkey, unsigned long rights, unsigned long flags)
{
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 old_pkru = __rdpkru();
@@ -456,15 +460,15 @@ void pkey_disable_set(int pkey, int flags)
pkey, flags);
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
- pkey_rights = pkey_get(pkey, syscall_flags);
+ pkey_rights = _pkey_get(pkey, syscall_flags);
- dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+ dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
pkey_rights |= flags;
- ret = pkey_set(pkey, pkey_rights, syscall_flags);
+ ret = _pkey_set(pkey, pkey_rights, syscall_flags);
assert(!ret);
/*pkru and flags have the same format */
shadow_pkru |= flags << (pkey * 2);
@@ -472,8 +476,8 @@ void pkey_disable_set(int pkey, int flags)
pkey_assert(ret >= 0);
- pkey_rights = pkey_get(pkey, syscall_flags);
- dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+ pkey_rights = _pkey_get(pkey, syscall_flags);
+ dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
@@ -487,24 +491,24 @@ void pkey_disable_clear(int pkey, int flags)
{
unsigned long syscall_flags = 0;
int ret;
- int pkey_rights = pkey_get(pkey, syscall_flags);
+ int pkey_rights = _pkey_get(pkey, syscall_flags);
u32 orig_pkru = rdpkru();
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
- dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+ dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
pkey_rights |= flags;
- ret = pkey_set(pkey, pkey_rights, 0);
+ ret = _pkey_set(pkey, pkey_rights, 0);
/* pkru and flags have the same format */
shadow_pkru &= ~(flags << (pkey * 2));
pkey_assert(ret >= 0);
- pkey_rights = pkey_get(pkey, syscall_flags);
- dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+ pkey_rights = _pkey_get(pkey, syscall_flags);
+ dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
2018-05-08 9:14 [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Li Zhijian
2018-05-08 9:14 ` [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set' Li Zhijian
@ 2018-05-08 16:25 ` Dave Hansen
2018-05-08 17:35 ` Shuah Khan
1 sibling, 1 reply; 10+ messages in thread
From: Dave Hansen @ 2018-05-08 16:25 UTC (permalink / raw)
To: Li Zhijian, shuah, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, linux-kernel,
philip.li, leist.fnst, zhijianx.li
On 05/08/2018 02:14 AM, Li Zhijian wrote:
> SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
Acked-by: Dave Hansen <dave.hansen@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'
2018-05-08 9:14 ` [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set' Li Zhijian
@ 2018-05-08 16:30 ` Dave Hansen
2018-05-08 17:36 ` Shuah Khan
2018-05-14 9:30 ` Ingo Molnar
0 siblings, 2 replies; 10+ messages in thread
From: Dave Hansen @ 2018-05-08 16:30 UTC (permalink / raw)
To: Li Zhijian, shuah, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, linux-kernel,
philip.li, leist.fnst, zhijianx.li
On 05/08/2018 02:14 AM, Li Zhijian wrote:
> -u32 pkey_get(int pkey, unsigned long flags)
> +u32 _pkey_get(int pkey, unsigned long flags)
> {
> u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
> u32 pkru = __rdpkru();
> @@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
> return masked_pkru;
> }
I'm not a huge fan of random underscores for undocumented reasons. But,
oh well.
Acked-by: Dave Hansen <dave.hansen@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
2018-05-08 16:25 ` [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Dave Hansen
@ 2018-05-08 17:35 ` Shuah Khan
2018-05-14 9:31 ` Ingo Molnar
0 siblings, 1 reply; 10+ messages in thread
From: Shuah Khan @ 2018-05-08 17:35 UTC (permalink / raw)
To: Dave Hansen, Li Zhijian, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, linux-kernel,
philip.li, leist.fnst, zhijianx.li, Shuah Khan
On 05/08/2018 10:25 AM, Dave Hansen wrote:
> On 05/08/2018 02:14 AM, Li Zhijian wrote:
>> SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
>
>
> Acked-by: Dave Hansen <dave.hansen@intel.com>
>
Thanks. Queuing this up for 4.17-rc5
-- Shuah
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'
2018-05-08 16:30 ` Dave Hansen
@ 2018-05-08 17:36 ` Shuah Khan
2018-05-14 9:30 ` Ingo Molnar
1 sibling, 0 replies; 10+ messages in thread
From: Shuah Khan @ 2018-05-08 17:36 UTC (permalink / raw)
To: Dave Hansen, Li Zhijian, linux-kselftest
Cc: mingo, tglx, gregkh, pombredanne, ebiederm, luto, linux-kernel,
philip.li, leist.fnst, zhijianx.li, Shuah Khan
On 05/08/2018 10:30 AM, Dave Hansen wrote:
> On 05/08/2018 02:14 AM, Li Zhijian wrote:
>> -u32 pkey_get(int pkey, unsigned long flags)
>> +u32 _pkey_get(int pkey, unsigned long flags)
>> {
>> u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
>> u32 pkru = __rdpkru();
>> @@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
>> return masked_pkru;
>> }
>
> I'm not a huge fan of random underscores for undocumented reasons. But,
> oh well.
>
> Acked-by: Dave Hansen <dave.hansen@intel.com>
>
Thanks. Queuing this up for 4.17-rc5
-- Shuah
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'
2018-05-08 16:30 ` Dave Hansen
2018-05-08 17:36 ` Shuah Khan
@ 2018-05-14 9:30 ` Ingo Molnar
1 sibling, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2018-05-14 9:30 UTC (permalink / raw)
To: Dave Hansen
Cc: Li Zhijian, shuah, linux-kselftest, tglx, gregkh, pombredanne,
ebiederm, luto, linux-kernel, philip.li, leist.fnst, zhijianx.li
* Dave Hansen <dave.hansen@intel.com> wrote:
> On 05/08/2018 02:14 AM, Li Zhijian wrote:
> > -u32 pkey_get(int pkey, unsigned long flags)
> > +u32 _pkey_get(int pkey, unsigned long flags)
> > {
> > u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
> > u32 pkru = __rdpkru();
> > @@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
> > return masked_pkru;
> > }
>
> I'm not a huge fan of random underscores for undocumented reasons. But,
> oh well.
>
> Acked-by: Dave Hansen <dave.hansen@intel.com>
So I saw these too late, fixed them already, and did it slightly differently:
I used a hw_*() prefix which I think is cleaner and more obvious than underscores.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
2018-05-08 17:35 ` Shuah Khan
@ 2018-05-14 9:31 ` Ingo Molnar
2018-05-15 20:08 ` Shuah Khan
0 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2018-05-14 9:31 UTC (permalink / raw)
To: Shuah Khan
Cc: Dave Hansen, Li Zhijian, linux-kselftest, tglx, gregkh,
pombredanne, ebiederm, luto, linux-kernel, philip.li, leist.fnst,
zhijianx.li
* Shuah Khan <shuah@kernel.org> wrote:
> On 05/08/2018 10:25 AM, Dave Hansen wrote:
> > On 05/08/2018 02:14 AM, Li Zhijian wrote:
> >> SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
> >
> >
> > Acked-by: Dave Hansen <dave.hansen@intel.com>
> >
>
> Thanks. Queuing this up for 4.17-rc5
Please drop these patches, I have fixed them slightly differently and there are
dependencies with followup patches.
Tanks,
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
2018-05-14 9:31 ` Ingo Molnar
@ 2018-05-15 20:08 ` Shuah Khan
2018-05-18 10:10 ` Ingo Molnar
0 siblings, 1 reply; 10+ messages in thread
From: Shuah Khan @ 2018-05-15 20:08 UTC (permalink / raw)
To: Ingo Molnar
Cc: Dave Hansen, Li Zhijian, linux-kselftest, tglx, gregkh,
pombredanne, ebiederm, luto, linux-kernel, philip.li, leist.fnst,
zhijianx.li, Shuah Khan
On 05/14/2018 03:31 AM, Ingo Molnar wrote:
>
> * Shuah Khan <shuah@kernel.org> wrote:
>
>> On 05/08/2018 10:25 AM, Dave Hansen wrote:
>>> On 05/08/2018 02:14 AM, Li Zhijian wrote:
>>>> SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
>>>
>>>
>>> Acked-by: Dave Hansen <dave.hansen@intel.com>
>>>
>>
>> Thanks. Queuing this up for 4.17-rc5
>
> Please drop these patches, I have fixed them slightly differently and there are
> dependencies with followup patches.
>
> Tanks,
>
> Ingo
>
Dropped now.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined
2018-05-15 20:08 ` Shuah Khan
@ 2018-05-18 10:10 ` Ingo Molnar
0 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2018-05-18 10:10 UTC (permalink / raw)
To: Shuah Khan
Cc: Dave Hansen, Li Zhijian, linux-kselftest, tglx, gregkh,
pombredanne, ebiederm, luto, linux-kernel, philip.li, leist.fnst,
zhijianx.li
* Shuah Khan <shuah@kernel.org> wrote:
> On 05/14/2018 03:31 AM, Ingo Molnar wrote:
> >
> > * Shuah Khan <shuah@kernel.org> wrote:
> >
> >> On 05/08/2018 10:25 AM, Dave Hansen wrote:
> >>> On 05/08/2018 02:14 AM, Li Zhijian wrote:
> >>>> SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27
> >>>
> >>>
> >>> Acked-by: Dave Hansen <dave.hansen@intel.com>
> >>>
> >>
> >> Thanks. Queuing this up for 4.17-rc5
> >
> > Please drop these patches, I have fixed them slightly differently and there are
> > dependencies with followup patches.
> >
> > Tanks,
> >
> > Ingo
> >
>
> Dropped now.
Thanks!
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-05-18 10:10 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 9:14 [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Li Zhijian
2018-05-08 9:14 ` [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set' Li Zhijian
2018-05-08 16:30 ` Dave Hansen
2018-05-08 17:36 ` Shuah Khan
2018-05-14 9:30 ` Ingo Molnar
2018-05-08 16:25 ` [PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined Dave Hansen
2018-05-08 17:35 ` Shuah Khan
2018-05-14 9:31 ` Ingo Molnar
2018-05-15 20:08 ` Shuah Khan
2018-05-18 10:10 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).