LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Li Zhijian <lizhijian@cn.fujitsu.com>
To: <shuah@kernel.org>, <linux-kselftest@vger.kernel.org>
Cc: <mingo@kernel.org>, <tglx@linutronix.de>,
	<gregkh@linuxfoundation.org>, <pombredanne@nexb.com>,
	<ebiederm@xmission.com>, <luto@kernel.org>,
	<dave.hansen@linux.intel.com>, <linux-kernel@vger.kernel.org>,
	<philip.li@intel.com>, <leist.fnst@cn.fujitsu.com>,
	<zhijianx.li@intel.com>, Li Zhijian <lizhijian@cn.fujitsu.com>
Subject: [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'
Date: Tue, 8 May 2018 17:14:30 +0800	[thread overview]
Message-ID: <1525770870-19067-2-git-send-email-lizhijian@cn.fujitsu.com> (raw)
In-Reply-To: <1525770870-19067-1-git-send-email-lizhijian@cn.fujitsu.com>

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

  reply	other threads:[~2018-05-08  9:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-05-08 16:30   ` [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1525770870-19067-2-git-send-email-lizhijian@cn.fujitsu.com \
    --to=lizhijian@cn.fujitsu.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=leist.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=philip.li@intel.com \
    --cc=pombredanne@nexb.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=zhijianx.li@intel.com \
    --subject='Re: [PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for '\''pkey_get|pkey_set'\''' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).