From patchwork Mon Dec 9 09:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D75D4E77180 for ; Mon, 9 Dec 2024 09:51:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67C058D0037; Mon, 9 Dec 2024 04:51:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 604188D0029; Mon, 9 Dec 2024 04:51:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F9A8D0037; Mon, 9 Dec 2024 04:51:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 220498D0029 for ; Mon, 9 Dec 2024 04:51:00 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DDFB81602A7 for ; Mon, 9 Dec 2024 09:50:59 +0000 (UTC) X-FDA: 82874951040.25.BD05E0F Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 8805140003 for ; Mon, 9 Dec 2024 09:50:39 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737844; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tzxFsnLSLWQZCHI+iQIMYg54lueLiq7qLk7zBhjN8k=; b=zEzB0f+jw0iOPbqbiaSC0l1aUDDex6cdXzgitqhBqdwSM90Gb4wV52OJH/WyKHmMFyfcyo jCLomQTL9JJydmT1kj47KRnq7ywHFzfq+c0s6BF/wTELYJvTLFUdlHd/kyVpLMEUINX+xB bGz0kCA4Wei6EV1CMPzTqgahKX4Xi1g= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737844; a=rsa-sha256; cv=none; b=e9jY/p4gIRIxe/W7k7pWAwaWoijurA+Fz+Wu5Syiqtnq9hDYQFhivqruAEwDjv66SCK8x7 ZVaJbpxp7d+ewmNCamqwz5inFYgYompAFGNF+VKwJxxjKFiaHjcMB29WFrz2vLkN9LHe7b WGQaHyiI2zBKoViXCQwzTZQifQGFjGs= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABF5B113E; Mon, 9 Dec 2024 01:51:25 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A27463F720; Mon, 9 Dec 2024 01:50:55 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , akpm@linux-foundation.org, aruna.ramakrishna@oracle.com, catalin.marinas@arm.com, dave.hansen@linux.intel.com, joey.gouly@arm.com, keith.lucas@oracle.com, ryan.roberts@arm.com, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, x86@kernel.org Subject: [PATCH 08/14] selftests/mm: Ensure pkey-*.h define inline functions only Date: Mon, 9 Dec 2024 09:50:13 +0000 Message-ID: <20241209095019.1732120-9-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241209095019.1732120-1-kevin.brodsky@arm.com> References: <20241209095019.1732120-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: ym47un3dm7kbynzmugwizrpep9bew6ot X-Rspamd-Queue-Id: 8805140003 X-Rspam-User: X-HE-Tag: 1733737839-953440 X-HE-Meta: U2FsdGVkX1+F98ODdCrZKBBhdRsciYiG7jM8fbcXwkb7EuFcW3jtugtHpUCa+PnRMGe1UiacaY25q4sWpZvzOTlFflGf0nOTjC44ovvY+5p7K4Rccnkqin6b4jvuQrC33f44gOYHFQkwbtoO38ANVWET31nJjp/nb318P6GWj0P86uf4tyoVFkA5gxUb0HHzo5twcBirtE0a17EtGka1flkGMp+AMC/aF/YfsEQaHg0PZnAF39/1lIi2Rr4CAGd2hXjlJWpTk9L7a1NgUI81NKkLTaEKf6fdJGbfOcyc++k6RBcbogfh0EiJQCeeS+Ts8xqJdhfHkM/dysiCK5P3Oc6+pVv5k2aXw1aNtP4sXXLWX8zp+D3suwfNu1upyBZET2sZYVP1e2Yl8N8qPpdaeKXqcx7wUtF/8prjPEB2AobAFNNL9R8Rp7huYo09tbcvdlK08hNV6xpnmxqWnZ4wuRbBHF8Eb/7t/zE+FEwdz5GeehJoQD7lwFZqb/zfuFnzlnj3yQGGqhPFcHBgpcmewOG9DSbzCkwEG4tr6S/erw5lk2+wkgveWCD3bvQc7VdBYlHmShwc8y6E02ZtHdA80s2maIG52moa2KMAqwUSG4hZaqBKFnDDwU+kUkx6ETFeJkTTFP20GBYqp/zrPe5QOHS3rOPPvBKyWjioX55Csf8684ZZssdirAh8S51p2fadWpf+jwBQlsJlKxwMcz2mS5PTF22JICpXhGYHOsOzlqL5QpgfrsMdqUl7Xe8TmlMpwO0lWnFjYrmhKGUQsaL/0Mry3SlMDSn7BiEHcZiHaT8JVbsK20FtHkfvXjvHVvIswypIgJ9wAIfvQdRaVvDfqqSLGSSxrViRg4CWGrC6DJNhSFeDFqlGVipvIzN+OV2wmv5BHvZgpPTxaGj8XODjycq+CydUtbL5mG/3qoPv58QksfzCWzq2+asOPcKNuyrqO+u4tKe8sEi0baWYw+n Ae8vVtum owRMjQ7/pmnPGwexTTRjGMRbquXKMqgUEO0HuHwy6pUwZyYQyfnVoUgPYW4uOnw4UyDi86f4e+tFIMGTtTqe2CAB9VskitXRzAuuB6pmi9lR6XmCWmXU7ncyG+cSRnCCOvPb6eon1MERaI1Syk13HyTrf9fuvr5G/akiHmiRqimqcxOa0aKR5BQgobHDCdpmwE/HEK+IchXaaBMwf1DaKmvmYR1LnBeIALdCBEdH2VoB5SU1R5UfbmrrYwA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Headers should not define non-inline functions, as this prevents them from being included more than once in a given program. pkey-helpers.h and the arch-specific headers it includes currently define multiple such non-inline functions. In most cases those functions can simply be made inline - this patch does just that. read_ptr() is an exception as it must not be inlined. Since it is only called from protection_keys.c, we just move it there. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-arm64.h | 4 ++-- tools/testing/selftests/mm/pkey-helpers.h | 8 +------- tools/testing/selftests/mm/pkey-powerpc.h | 4 ++-- tools/testing/selftests/mm/pkey-x86.h | 6 +++--- tools/testing/selftests/mm/protection_keys.c | 7 +++++++ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-arm64.h b/tools/testing/selftests/mm/pkey-arm64.h index d9d2100eafc0..9897e31f16dd 100644 --- a/tools/testing/selftests/mm/pkey-arm64.h +++ b/tools/testing/selftests/mm/pkey-arm64.h @@ -81,11 +81,11 @@ static inline int get_arch_reserved_keys(void) return NR_RESERVED_PKEYS; } -void expect_fault_on_read_execonly_key(void *p1, int pkey) +static inline void expect_fault_on_read_execonly_key(void *p1, int pkey) { } -void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +static inline void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) { return PTR_ERR_ENOTSUP; } diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 84376ab09545..bc81275a89d9 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -84,13 +84,7 @@ extern void abort_hooks(void); # define noinline __attribute__((noinline)) #endif -noinline int read_ptr(int *ptr) -{ - /* Keep GCC from optimizing this away somehow */ - barrier(); - return *ptr; -} - +noinline int read_ptr(int *ptr); void expected_pkey_fault(int pkey); int sys_pkey_alloc(unsigned long flags, unsigned long init_val); int sys_pkey_free(unsigned long pkey); diff --git a/tools/testing/selftests/mm/pkey-powerpc.h b/tools/testing/selftests/mm/pkey-powerpc.h index 3d0c0bdae5bc..1bad310d282a 100644 --- a/tools/testing/selftests/mm/pkey-powerpc.h +++ b/tools/testing/selftests/mm/pkey-powerpc.h @@ -91,7 +91,7 @@ static inline int get_arch_reserved_keys(void) return NR_RESERVED_PKEYS_64K_3KEYS; } -void expect_fault_on_read_execonly_key(void *p1, int pkey) +static inline void expect_fault_on_read_execonly_key(void *p1, int pkey) { /* * powerpc does not allow userspace to change permissions of exec-only @@ -105,7 +105,7 @@ void expect_fault_on_read_execonly_key(void *p1, int pkey) /* 4-byte instructions * 16384 = 64K page */ #define __page_o_noops() asm(".rept 16384 ; nop; .endr") -void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +static inline void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) { void *ptr; int ret; diff --git a/tools/testing/selftests/mm/pkey-x86.h b/tools/testing/selftests/mm/pkey-x86.h index ac91777c8917..f7ecd335df1e 100644 --- a/tools/testing/selftests/mm/pkey-x86.h +++ b/tools/testing/selftests/mm/pkey-x86.h @@ -113,7 +113,7 @@ static inline u32 pkey_bit_position(int pkey) #define XSTATE_PKEY 0x200 #define XSTATE_BV_OFFSET 512 -int pkey_reg_xstate_offset(void) +static inline int pkey_reg_xstate_offset(void) { unsigned int eax; unsigned int ebx; @@ -148,7 +148,7 @@ static inline int get_arch_reserved_keys(void) return NR_RESERVED_PKEYS; } -void expect_fault_on_read_execonly_key(void *p1, int pkey) +static inline void expect_fault_on_read_execonly_key(void *p1, int pkey) { int ptr_contents; @@ -157,7 +157,7 @@ void expect_fault_on_read_execonly_key(void *p1, int pkey) expected_pkey_fault(pkey); } -void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +static inline void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) { return PTR_ERR_ENOTSUP; } diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index fcbebc4490b4..82ece325b70c 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -54,6 +54,13 @@ int test_nr; u64 shadow_pkey_reg; int dprint_in_signal; +noinline int read_ptr(int *ptr) +{ + /* Keep GCC from optimizing this away somehow */ + barrier(); + return *ptr; +} + void cat_into_file(char *str, char *file) { int fd = open(file, O_RDWR);