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) {
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());
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
* 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
* 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
* 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
linux-kselftest-mirror@lists.linaro.org