From patchwork Mon Dec 9 09:50:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899184 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 060BCE77180 for ; Mon, 9 Dec 2024 09:50:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 764FF8D0030; Mon, 9 Dec 2024 04:50:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EE148D0029; Mon, 9 Dec 2024 04:50:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58F118D0030; Mon, 9 Dec 2024 04:50:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 308668D0029 for ; Mon, 9 Dec 2024 04:50:44 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D51561203AA for ; Mon, 9 Dec 2024 09:50:43 +0000 (UTC) X-FDA: 82874950704.15.B4F28D2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id B644A180016 for ; Mon, 9 Dec 2024 09:50:39 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737833; 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=4mPs3wye+bX06omYN6bcJnJM599UffflhhHId/XaClw=; b=52amNUfUjtgS8V+i+1dWWSxByH91NYg2LShzwa6NfXRgkYJtTdE3JH4DiaUHAUbKMoofh4 JXSotyzSsEzTkFIaZvQpAZ0ehO16eSC/lcUgrkYeFs6+UqjVj1eyuC4LrSaa+NJ3WN27pN /nr/FWzw+vgBfjTonT9c5IT7PVZtJJI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737833; a=rsa-sha256; cv=none; b=FYH5qWs1V/8HWtCVOH/OnYoV9bXusK0DoaSPyp4k873TLejAOUI78hfS0cDIO/LkNP+72n ylYhlUEoYDIHztoL8us4l/3vCrTqYz701WkvdDFAslRwJNMHrn/nQs4NvvlxxY3eBZMx0z JDhtVOmeigm2N6rAltOuIH785Hn8gnQ= 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 AE5D0143D; Mon, 9 Dec 2024 01:51:09 -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 A4ABF3F720; Mon, 9 Dec 2024 01:50:39 -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 01/14] selftests/mm: Fix condition in uffd_move_test_common() Date: Mon, 9 Dec 2024 09:50:06 +0000 Message-ID: <20241209095019.1732120-2-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-Queue-Id: B644A180016 X-Stat-Signature: a66webheewucxmhubu9d6bnnn65ctu99 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733737839-787395 X-HE-Meta: U2FsdGVkX1+tjLXqhwhcf2p2GnslnvK54uXraWXNzXfMeg6UOoSclOWB42kyXq0Q95fN3R7cJS+rMkpZnBJFz9z8MLrzCXBt7OB5/scQKp6pPs00t2ppEYDpA5w43HKL2SVivRkwj5zlTRF0kqMSnsIjtilUjpHt95tioG3fnhWISRnK/jQ57tO8rVSilU4u2pNjv8DUSOt6XVlSPBwdEbmibNKyQpvRa/dt+jbFrYatiBYri7KWbO1WBYnmcrc82bG/D/zlQKlPu2gTob7pMboDJ4C4PmeeLYqT7dqkhrBpiTGPnhMrKqoSma6CSq1f99HrBUfPr1V+OtQQ3TsCwPBzSWvshBM3CYE9oUgPivdBQ3vMDpkvEpPhktFIqopfrwlj3vofOOp7fJyLm2eH7tJuBTTn7P1bXOKb2B1Qo2NOVXh4o9dAt3SyFhXJFfd06y/lWJ7Y1MxqZONUas8IZKbvwMxm0EuXuiMdt4kewg0lJKPqt0KmTu+D/Cv3Xzz28zfu5GXLsUnfn5281vxF8O18bp6vgiZTetzcaAGzh4X+8bXIh9T+JW0rWEbxR3g698QJW9ycUo5RoTnvleT82mRipEgs84zIjpEJBXXAnJelqm/iu33WTEd4Fw6AqYHST2pGbswiFrK+wt8NLi7XbpdWkRdxagI3j608XT/eHVyepw9kOL/p9QYWKVh/7EdqaYUsXsYuMse1zPLTZjd9Hjz2BKn6DuGPEw0hj9TTA5BVqHtqF0+F0Ht9VuNpLBQ5ge4NSkIlsmR/oGoGL4qXs741ot59kLaKe4MCXAk03+eDTTyaxZDXdMgRvXSnI/UEeieF26GHLFXJGRpl+JdzBFMa9SFNLs5rJ4jepFGPnZQRaozLkgKC1fRP4nf0i3uaGUjfB/RFPcRJNcAUuiYIVI2e7wtf/0Gv5iqPg0RHaYvaTLUtFz5cPR9a6X2W8EAJTSFSl/PdCFNeYpVqwYE fwjcesny DvJba4RkQzIa5efhNJO3N0QuoLnj2qvkB3/EIPCTWg4eTDK7tKcUs6niPWlFRdLt9dEv2q11K1B2jnUYCJZOJDGZ3pYf1TVYD36U+9IyFXMw0Kjwe9tvzLfK5+U04ZCvxRhh5aW/MZ4kPymTVyZjySWnThWHU8c5JUI7nKTagat/Eua49ekX0x1Jz91oNfPop9J8Se0dpUzTjJdf9KgSh9cZ+YTipuvJw05muHDCwfPh+Xn4rbNXrQL0MJboe+KWEgIVdVSOVyvT2ihb7n9sLwutl8YlKu1A2uNkXqLk2NzzoFweXLIVCf3aAHCkmFRIczZrz 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: area_src and area_dst are saved at the beginning of the function if chunk_size > page_size. The intention is quite clearly to restore them at the end based on the same condition, but step_size is considered instead of chunk_size. Considering that step_size is a number of pages, the condition is likely to be false. Use the same condition as when saving so that the globals are restored as intended. Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test") Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/uffd-unit-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index a2e71b1636e7..74c884713bf7 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -1190,7 +1190,7 @@ uffd_move_test_common(uffd_test_args_t *targs, unsigned long chunk_size, nr, count, count_verify[src_offs + nr + i]); } } - if (step_size > page_size) { + if (chunk_size > page_size) { area_src = orig_area_src; area_dst = orig_area_dst; } From patchwork Mon Dec 9 09:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899185 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 36831E7717D for ; Mon, 9 Dec 2024 09:50:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE7818D0031; Mon, 9 Dec 2024 04:50:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A71DB8D0029; Mon, 9 Dec 2024 04:50:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EA6B8D0031; Mon, 9 Dec 2024 04:50:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6E8678D0029 for ; Mon, 9 Dec 2024 04:50:46 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2CE961A0353 for ; Mon, 9 Dec 2024 09:50:46 +0000 (UTC) X-FDA: 82874950872.04.F1626B1 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 8A6851C000E for ; Mon, 9 Dec 2024 09:50:05 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737835; a=rsa-sha256; cv=none; b=VtRzklkSqggOcC8tyKN6qX4aBEBW9nEyLlDS/xPbOTp9QJJYNxYGdcO9R36dPZL8R6WhMj reA/PJKsZ6BviNqZtL2Txc7GJY4/gsok3poEVIg+ySXtLqueKdCKfoS+q2KXEuanqwLfa+ VxEvAi28WQo0Q7/nQae34broNstAHew= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737835; 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=HCzdiDFlbZh79PcakPauCEvqAaIH/wVADAjSs7kWDGA=; b=bhd1AVbPbLlQhSGu6gcLVloWWe8JIFzf2+LdMtfbSQ3Rz8j52O+F5XfwN7UOMOl4wNrcNK sByTWAHwuLMuZh1nH7yJzS3CbXEEo8BXme2jiJFG7ieqq84vEKGHIbJMDbEIbZ08gvgez7 R53+4g5jmkZomEctLpTFCzKnrNUH8uA= 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 F3C21113E; Mon, 9 Dec 2024 01:51:11 -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 EA0E13F720; Mon, 9 Dec 2024 01:50:41 -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 02/14] selftests/mm: Fix -Wmaybe-uninitialized warnings Date: Mon, 9 Dec 2024 09:50:07 +0000 Message-ID: <20241209095019.1732120-3-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8A6851C000E X-Stat-Signature: 1se1mbppf59zncfc1z9dwd4gu1yj1jgt X-HE-Tag: 1733737805-744461 X-HE-Meta: U2FsdGVkX1/hW2Rd7FhtYmeG5u5l7ANpXtNK0ufxxt55CkY4OWYGlLKCfB9XOa3dll+n5uU/8lQFQvJPx2fB3+h0072ZnToL6d2SPBi0j9m9qxJb9EIrGs1dUDlk9pVwLCnrexSD1f6ZjEidXdbwXTCTXQOzfkLOmfmeL3cZ8sB6WSSmGeoc6Gu8IKuPOkgITgwi18dhAcRaQlES38tE1WmL6zOLSMu64Zjtfhbh/606OIpwZg9fC3Zf+OnHCf3dsDhQgAG9oizBaPodQvqqJAvsONLRaIQvRFUQ3KzvTpQYQM3NcJ93V79ppXmZOtSVMl8u96kSBv94I7Uoo/vaZj23mu0fU6J/AOH+oeMiZCC8CMPTB21aPqlc+i0yBrx4b5d+rRfL1MCxFUy8QwYaw3npRkf3IJuHaD5n8qpyc+PjJ9387mqZ+5XWc7nEfObPF2bRnyDPu+trlwfo+fldmEqxYH6EaVmKROswXnB84FckhXV3UtyFRKoLDqFHCHOlo9JsgeG9pucBwJ0S15LuzREPC+quXwM3Sfd3cISYogNkTLidpKfiMKrbywO+dxMoRnIqqXkOm8JC5m9FaUpSneg7tg6RqGNfMotZj6ZV3HsoGmIk79VKQ/4RN1oHdOI4qpeANQTkUG17coazs6Ik4/DlYzIhvROeQlNQeC1ps2rK6Ie5QGHoRvWyiJGgnVkh0kmY5nAAlyEC88SQbDIhU13XLLo04pPOuK1yCcaPutw2Z2HiOW+sPLnMsLmATMBXQ1+CKo5xj40L/o+1lpxHCvWPji8GV914/mp7cd8mwozkvEn0+IhnoiaT4pXii2KRZp23xdg1WDcb9P95Q1OukIpMkw0iCiYUJh9z0CupqYbP3q/NMqaeUKedBbpVuzAlumhuOuS12+6SxDzbbYrRHBmesPmngfH6JfWNvtO33R4MHYwajxLehTWPz9n68Pousf/HxdVodCSPQfl7izQ N01eeTUk 9cTEjnQfFcKferft97IwniVvYTRQWFun9+2UKNmNTcbcCdd54pXWnKRD+WgmyzhSiXsPvkriUaLxXxEaVTvoiSWeynWTA7QPxV+U5Ug1tpNSACqOYqYoXQzfIH3C1D4WrOYZ1LStTp8o2yK8jyIKKW+9uyCZaPlFBWKpai3si1AeEV915BYVfa+b/QbXxuOh134VT72fLQzkvKvsAR67OjHeCGlUau9TZg/gJiTOojUlVepN9yIMtaKb9prIEvVisPrny 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: A few -Wmaybe-uninitialized warnings show up when building the mm tests with -O2. None of them looks worrying; silence them by initialising the problematic variables. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/ksm_tests.c | 2 +- tools/testing/selftests/mm/mremap_test.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/uffd-unit-tests.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c index b748c48908d9..dcdd5bb20f3d 100644 --- a/tools/testing/selftests/mm/ksm_tests.c +++ b/tools/testing/selftests/mm/ksm_tests.c @@ -776,7 +776,7 @@ static int ksm_cow_time(int merge_type, int mapping, int prot, int timeout, size int main(int argc, char *argv[]) { - int ret, opt; + int ret = 0, opt; int prot = 0; int ksm_scan_limit_sec = KSM_SCAN_LIMIT_SEC_DEFAULT; int merge_type = KSM_MERGE_TYPE_DEFAULT; diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c index 5a3a9bcba640..056b227f4a30 100644 --- a/tools/testing/selftests/mm/mremap_test.c +++ b/tools/testing/selftests/mm/mremap_test.c @@ -384,7 +384,7 @@ static void mremap_move_within_range(unsigned int pattern_seed, char *rand_addr) static long long remap_region(struct config c, unsigned int threshold_mb, char *rand_addr) { - void *addr, *src_addr, *dest_addr, *dest_preamble_addr; + void *addr, *src_addr, *dest_addr, *dest_preamble_addr = NULL; unsigned long long t, d; struct timespec t_start = {0, 0}, t_end = {0, 0}; long long start_ns, end_ns, align_mask, ret, offset; diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c index bdfa5d085f00..8e1462ce0532 100644 --- a/tools/testing/selftests/mm/soft-dirty.c +++ b/tools/testing/selftests/mm/soft-dirty.c @@ -128,7 +128,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon) { const char *type[] = {"file", "anon"}; const char *fname = "./soft-dirty-test-file"; - int test_fd; + int test_fd = 0; char *map; if (anon) { diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 74c884713bf7..9ff71fa1f9bf 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -1122,7 +1122,7 @@ uffd_move_test_common(uffd_test_args_t *targs, unsigned long chunk_size, char c; unsigned long long count; struct uffd_args args = { 0 }; - char *orig_area_src, *orig_area_dst; + char *orig_area_src = NULL, *orig_area_dst = NULL; unsigned long step_size, step_count; unsigned long src_offs = 0; unsigned long dst_offs = 0; From patchwork Mon Dec 9 09:50:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899186 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 B38D2E77173 for ; Mon, 9 Dec 2024 09:50:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51D128D0032; Mon, 9 Dec 2024 04:50:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 455D68D0029; Mon, 9 Dec 2024 04:50:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A8648D0032; Mon, 9 Dec 2024 04:50:49 -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 057118D0029 for ; Mon, 9 Dec 2024 04:50:48 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 811BBC02A7 for ; Mon, 9 Dec 2024 09:50:48 +0000 (UTC) X-FDA: 82874950704.21.A509DC9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id DFC0010000F for ; Mon, 9 Dec 2024 09:50:07 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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=1733737833; 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=TXhOkF+BRkbjEZRD727KKe3G5fsf3ooidZDOS5wP8XY=; b=fLX+1GxaMwCTJ3Gm1L9tvvHseJuEIqy3xYBx33M03hwQOLpZSYFh93gjbxPMS7Bbdo7+Co CjHbL4fmT3N0qhK2vFnDIC2RE80f7or7dy3igMFNO9raXhxkWr51tyi6IfpE28lRUFtABm POImlnHfS3d19mynUat7O5uYc2ggv10= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737833; a=rsa-sha256; cv=none; b=dzkxRFBVuKYGytyA0PgoC2j0cCTsYHmsMo7PtOk0yk2kSsfWmRTwsSU3za4AlTF5HBOq/T 2ctXbnKugjw9rjD7QhFcR+3U89LnGJ1ESbEPHBdIbPfsWTsF8hAoGmu2ZrrDFaArFUFTw+ 0Q0Cg5XorCUde4pMg6dDM/WWz64fVXk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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 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 44BAB143D; Mon, 9 Dec 2024 01:51:14 -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 3B6F33F720; Mon, 9 Dec 2024 01:50:44 -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 03/14] selftests/mm: Fix strncpy() length Date: Mon, 9 Dec 2024 09:50:08 +0000 Message-ID: <20241209095019.1732120-4-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: rspam02 X-Rspamd-Queue-Id: DFC0010000F X-Stat-Signature: szhfqrcec7zixwe346actfuptxe88113 X-Rspam-User: X-HE-Tag: 1733737807-252962 X-HE-Meta: U2FsdGVkX18V2v0II+VronJ80y9LbNmakPUcZoKHZ1dAPfaLCSItWX0ktKQu+imUkinAep/2VePrlT27PqgTuYRhbbVXEC1BuU/sCWFl+EbCkptCqh/lMQaS+JLBWRHwPyXyWC69C6yzWRh1+eJ+DVZSBiDlYPj8a8V1ZdxAeJd9PK2gykYxsKT0NS7dG/Td4cy0WhSE6awRXMgAjfTRSleDs0+Q9bCPgRdEf+xvesnb0H9gLGQlWoNWkz8zmM9boxFfiswWP4a0u0cN7w7L52VW5psbToroLSdCom/KUAKvjb6YDA+xXcLrmcpd1EZAddcdlsN+Brz02/XlcFDNItlVB1EYHM1yNyvCXvvFr7GZ0NYBmXT5I8ili6VjWOKbAQFEZHb6Ye3t3HGLKIxTXG1h4Nad6JzmFzm98Wq5+na+vijOp7wTt3XMKmbXpeq8+C9CoRapEmCpvjoir9NdbA4y2N/hkmKMUOEDlTG+h9xfAVXBf9//KlXHPjPg/Z+P1rMCB9hhgI3o6q5S8I6fi57ZYchEZw27z7ss+Omf+k2JYeDKKPwf63ZV68PMPrhj2fe9m6gbsXi7bg16+x+jQvLcSMvpDJucCK8RALqebYoCrbnEr9OTSE3f5UfgrmXq5ZsTL32bBJbC8VGQjw+SRDwrKY0ywuMF6/pt/3QD369tPRDmFNdEGFaMltV+RwSqs9UkfWNOe/o7OwqJl6aM1RHM2cVShqnJls0t7lDtuQyacsCqing7ondaoAS2kHufHApaxUc2zEokdANL/hWoNN5OEe/JMn6oJn5VgX/mJQyXBT7jlNqv5b49cvxv0ujbmOlWP672yTZk2/pHqKIyvyeKn+Jp32uA6raPGHDJJh1GDgrQfDkF/YzdLn/MuYilU+H3k5m6YHP3djjVuUmmfGdaptCx6CBRu8lWv2fcRtNMj9tRlLpjC2IB7VFc2YmEzU0Xd/x24wgheb1p5H4 kdJbE/C/ 5h1yU+Jzjqt4p90rhAXErrHaT2zNuXPjc8buycVIgC0PQiPWLPOlRm/JWI1clNd+kQ8scJLD4NPBJ/GXAnSC8ZhNp8+kEmaj2JQHvLbYCVP2bAzWiGBbtyoWKVqtWgi76AcUSis8o1Gf03/USaRpZ2IuogDzm4VKuePxt2ZbG149oJ0Fa9KEO/POtYgGu6o8+eQHQZpw5HfnmrbM6O0DPXyEnQfYqDbAfubYXe5O8u1fi1PvpB6CZ8keSxg== 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: GCC complains (with -O2) that the length is equal to the destination size, which is indeed invalid. Subtract 1 from the size of the array to leave room for '\0'. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/write_to_hugetlbfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/write_to_hugetlbfs.c b/tools/testing/selftests/mm/write_to_hugetlbfs.c index 1289d311efd7..34c91f7e6128 100644 --- a/tools/testing/selftests/mm/write_to_hugetlbfs.c +++ b/tools/testing/selftests/mm/write_to_hugetlbfs.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) size = atoi(optarg); break; case 'p': - strncpy(path, optarg, sizeof(path)); + strncpy(path, optarg, sizeof(path) - 1); break; case 'm': if (atoi(optarg) >= MAX_METHOD) { From patchwork Mon Dec 9 09:50:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899187 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 D24A1E77181 for ; Mon, 9 Dec 2024 09:50:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 657318D0033; Mon, 9 Dec 2024 04:50:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B6DD8D0029; Mon, 9 Dec 2024 04:50:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E1778D0033; Mon, 9 Dec 2024 04:50:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0FB118D0029 for ; Mon, 9 Dec 2024 04:50:51 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B98BDA03AB for ; Mon, 9 Dec 2024 09:50:50 +0000 (UTC) X-FDA: 82874951292.14.4FD265E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 1B9A980007 for ; Mon, 9 Dec 2024 09:50:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737833; 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=aabiX5NnKb1HgBUNA27QTjCuXgUs5Hva7boPFb+v/xc=; b=Ur0CZdgfQJ+qRo5Cvkx+BY/U/voZo8DRoBYCbUCojkq4iZUJ8xjWK6vcLfL4yH9Q2Sk+8S 4KV5ZDvNZMy2OOHIrV21WAhzxnH+zDvntd15xU01mwB6CHGOjKJtFWglk9x64DwxlIbXsB R8K8ZT6DhqdWudJ5P5DF/wOo0Jz17Ow= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737833; a=rsa-sha256; cv=none; b=LHL21HGtTCL+zbRdU4Mg1g2gMFXKMfzFGDYQXhLdeBBbJe19PezsZKpoh5O9KnIstU6wLR mGysyKgK9k+wSIsNZE4P5nk1qJ4+UOqD9A9kxGzbQY/OLqzk5el2ueyxs6gtitwjOMx8sA x32SWFEMkArCJVlrhVpS50jKTbcHHpc= 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 89FB5113E; Mon, 9 Dec 2024 01:51:16 -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 80A133F720; Mon, 9 Dec 2024 01:50:46 -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 04/14] selftests/mm: Fix -Warray-bounds warnings in pkey_sighandler_tests Date: Mon, 9 Dec 2024 09:50:09 +0000 Message-ID: <20241209095019.1732120-5-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-Queue-Id: 1B9A980007 X-Rspamd-Server: rspam12 X-Stat-Signature: z5gc19m953wz4mapmbbi6f1qjmbcc69a X-Rspam-User: X-HE-Tag: 1733737809-754200 X-HE-Meta: U2FsdGVkX18ztI4o8kCMpjDxxBghLl8lpiu+spBXOIVr+iBDQQLdeIKi7ZYXaQU5mHoXMEnvAQt2npfmtUA9VDLMMyclNxhX5FcT/KohcUQwxTHIxOkm9zZTcRNM+itmJRzBwusjG7NxEvwzpcslvbZQgMrabDnn6ghDgknT/ChukQEb/tD1KpSoeLoW5vPH0Zqn7QWTdiRTgexBQrNj7kYdmL/T+wjRH/xmTNLORfa4iXjAa8x4oNK2v/Qq+P3bCk8ayPX3JSot5MZw8fTOqQUdir1ysa6YVPhxHqbIifB7+N/lumKjP4xr+j5QW2Zp2khkyseKM8TWr3uaDk7ZBsTOcQnH7588JtCoyXAJPEX7YixMHHHsd1DCI7vL6iOo5/LkXoJMUTAdoV7/nBEv9GrVTXtMkgUKkndHUXVLsmwwvU+f7yu9ST750N48BZXzQtHQEd1iSgNil/nqcXtmyW1tlvXn8+GKBbiwvgAgZxDPCFv/a+L067Di/+yni90+KzEoOo0+K4kL72J+9WhFHQmjHIhzSIk0Wq8T2mrDSgG4yJRQPz77EX64NZuoiuvWq5T+jxErwmUUKMAMQYafREnDKTnm9ZDgAqqIRg35dHRU+RVlLKp0gZ8zB2MnQAKV9W9CDuypi9scGQBjAahUg/+rzsdY4HWljjtKcFhx2GB6lST4m3He651b5+YQwP+owhG4nlio8/BGcysGuZmC+KqhHcQru5rFcCjfT7WBBGK6CDJUx8w8OvVK/Dqk/voUa2grgfQf44qCaWgrRaJ0vVBMlMrXxTD7lOHBvNp/9lR+8H8W5vREuGucL2F2ZC9SZ+SEPvVDDXx4fT2iTPL9FRJLfkSs4b642nD7AZ6Yj5tqBQy5cVheXjoBfOt5iQQphICp7swOok8P7hjtx8qBIrDRFwg3NC1sWCoC0DA+tvIxCq+a/eU5kmutVWzXGimgQ5Jb6zMY2o3AJBufxJK DrF9oN5R PEEXdcYrmVRelr+QQKT+v/41MIB3dGCHWdblqYunXQR8EXUoPK5CXlEhMHj12PH4T6DE6j5QT7lqVF9bKFdeU5POMzeZpe4EAhUCde3j0vV7dyUv0ks2YfaX3xuSnsw8w9WGx3JZZBwjD0WJ79RQS645EmhoIzr0Iqxd2N7dap29nA6Ln4UPzW5ZPgf7F9t51ryybhICC5WW8odnSlsnb01oCXjCNQV2uR8qNEIZkh2kzbcq0o9aX27Q9CIl2dHAD7KhwMCtdMa+fZ4ip0IDctv0dj4axiiUKzPXbN0TfZiseTfOJfICBmHu04KLaZOwVX4T4 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: GCC doesn't like dereferencing a pointer set to 0x1 (when building at -O2): pkey_sighandler_tests.c:166:9: warning: array subscript 0 is outside array bounds of 'int[0]' [-Warray-bounds=] 166 | *(int *) (0x1) = 1; | ^~~~~~~~~~~~~~ cc1: note: source object is likely at address zero Using NULL instead seems to make it happy. This should make no difference in practice (SIGSEGV with SEGV_MAPERR will be the outcome regardless), we just need to update the expected si_addr. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey_sighandler_tests.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index c593a426341c..e7b91794f184 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -163,7 +163,7 @@ static void *thread_segv_with_pkey0_disabled(void *ptr) __write_pkey_reg(pkey_reg_restrictive_default()); /* Segfault (with SEGV_MAPERR) */ - *(int *) (0x1) = 1; + *(int *)NULL = 1; return NULL; } @@ -179,7 +179,6 @@ static void *thread_segv_pkuerr_stack(void *ptr) static void *thread_segv_maperr_ptr(void *ptr) { stack_t *stack = ptr; - int *bad = (int *)1; u64 pkey_reg; /* @@ -195,7 +194,7 @@ static void *thread_segv_maperr_ptr(void *ptr) __write_pkey_reg(pkey_reg); /* Segfault */ - *bad = 1; + *(int *)NULL = 1; syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0); return NULL; } @@ -234,7 +233,7 @@ static void test_sigsegv_handler_with_pkey0_disabled(void) ksft_test_result(siginfo.si_signo == SIGSEGV && siginfo.si_code == SEGV_MAPERR && - siginfo.si_addr == (void *)1, + siginfo.si_addr == NULL, "%s\n", __func__); } @@ -349,7 +348,7 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void) ksft_test_result(siginfo.si_signo == SIGSEGV && siginfo.si_code == SEGV_MAPERR && - siginfo.si_addr == (void *)1, + siginfo.si_addr == NULL, "%s\n", __func__); } From patchwork Mon Dec 9 09:50:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899188 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 267DDE7717D for ; Mon, 9 Dec 2024 09:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9B078D0034; Mon, 9 Dec 2024 04:50:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D55B8D0029; Mon, 9 Dec 2024 04:50:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 801378D0034; Mon, 9 Dec 2024 04:50:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 555188D0029 for ; Mon, 9 Dec 2024 04:50:53 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 02AC31203B2 for ; Mon, 9 Dec 2024 09:50:52 +0000 (UTC) X-FDA: 82874950620.08.FF5D2AC Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 6618D1C000F for ; Mon, 9 Dec 2024 09:50:12 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737836; 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=q+2UJHxz6a7MH5+pr+GjIBI71Qv2ftK6J++0dCfXv90=; b=ZCrTfjL1TpZijtsz0zv7oGbusSPvirP82ki7sgV1gcbFrsBDbVO2XRCJo4MtyMhmVkpDBs EWDqtEuCU2DgOjUOFxi3AVe4Udz5KtZDqt00XX0FwtSzo1r4f94jipDE08cquqE+ehC2/o PiihkbfpHLtqr+YZHHVFdah5qn+pEKE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737836; a=rsa-sha256; cv=none; b=E9qICgXadp5xOTfRO9YUY7L+PvK4TWJK4T6I1ol01frVfPEEOoeJjZIRccC8sCvyiuRl3R heFfehTUCK0rdc7sU9Uw8aNpmVyGJrFHNJHP11m3BcQdPWUtwji3QT/FCuE747PWMSqbwu Va1NG5bzJEoXVYgBvstoBM658uVn8xk= 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 CF86E143D; Mon, 9 Dec 2024 01:51:18 -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 C5A5E3F720; Mon, 9 Dec 2024 01:50:48 -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 05/14] selftests/mm: Build with -O2 Date: Mon, 9 Dec 2024 09:50:10 +0000 Message-ID: <20241209095019.1732120-6-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-Queue-Id: 6618D1C000F X-Rspamd-Server: rspam12 X-Stat-Signature: kqq19cctmf8eu8uup19if9k7tusi4j5e X-Rspam-User: X-HE-Tag: 1733737812-596704 X-HE-Meta: U2FsdGVkX19VBIU4RxBwx/DnKZ6RTzShZBrmqJ+CS1ty2eI9PPCagcqhfiGMurRwQ79z1PaYT53p1Gk0jazLriEQ8iWCRqmlTmWeJcfjB4YouZb8X5tQP+Tkzj7qOC7mU2I2SEUXB3JKHAYKFgqGOQZBrLN1sQL0ftB+kM5jz1Mkrdj2alCat/39seBXbCTELazjAQBsiz2KyLH09D8gx0VoHlMj/VOaBhKorQjih7PKPsL8+nDIa2kmK8Ol0qQXwMMQSFvz168624q8E0wtyuOzPOKgbSGbXhwhURjDr8vi9P4JJSTNlBi5J7DMj4Lk6pPAF+p2BwmcT+wE15lZ0j6QlltxVJeN26gO9Fu1Az0lIcw36tdr1fM9h1vKfDQrd007vL5fMtvz7KW2iOoREgY28YjJrRkEbXqNKF5H7bJwQuZmX/BbSJz5FfT0hggE4nIWJ/JIaoEQIPkR1CiqbeY04U3PiNKadmBUMqTVaB4vyCMb/Gdb7rgRFweYz3SxdbGofdIAaV6Y8fpzSkPKbRcoywPD/5wjCsNzhxMB5B9yQh/c6CTOuNyZx+33JXkQ9PZ+NFKE/Gz0SIN+dn+yzh/tHgJ/gmut0yYcrcQcXawr/a20UYF6fO4HXh1SRhaYYBDZKgmWNszSFc8rXHsmGAsqZ3xGHbF5buqtrIEOunuc3t+sRxmZk68huRBCrNkYvr7czRC3/LRfZWNZGd4Bcvidr3d6UaRxBeHiueeMowwfNaAGPjbR8GY5fya8IudD2GqqOj5Fl9YykJJ+F0nsfdwOZGKvEvuGP+3CKU+zfNnfLRsidFW/AhQUoqKoNATy9tbQkWn9tdtigBr0wOjez7sVbQ1t08787AoufREW1pMcFaAY+wO8ARZcnaGZ1TxTbvQPS5WyawzcylVbt292gTdx0UMbokgnP7C1xNiiUEbkaIpqo4SeCk7rqy5XapbxlvQESYmOXpGKkt+tYpN CRZJiQbF 0frMCd7ULxMHpHEse9TprSu7AKdUBa/H/orWo8Gzq0VJyt+5cbxAnv4IfAwb9VNSRZR7Rpht6WQnOoPCNfKh0XaBZit5U6lI8XQ7mtpXs15GgaYtwllHQUE3W3KlHMAp95yY1MMPsYOMNE0nZxGDl4eifFPxcO96M4CApLt5ATWjNUtOOSUOL+573PW/T32wDjeWgAEXABSl0ov/Y4I+IJpq+rduOJo9ajT0AhGuKbaaRHRtx0jZ6sekcJw== 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: The mm kselftests are currently built with no optimisation (-O0). It's unclear why, and besides being obviously suboptimal, this also prevents the pkeys tests from working as intended. Let's build all the tests with -O2. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 3de23ea4663f..814b17a43385 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -33,7 +33,7 @@ endif # LDLIBS. MAKEFLAGS += --no-builtin-rules -CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES) +CFLAGS = -Wall -O2 -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES) LDLIBS = -lrt -lpthread -lm KDIR ?= /lib/modules/$(shell uname -r)/build From patchwork Mon Dec 9 09:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899189 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 A4A03E7717D for ; Mon, 9 Dec 2024 09:50:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F9E48D0035; Mon, 9 Dec 2024 04:50:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 281BA8D0029; Mon, 9 Dec 2024 04:50:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 039888D0035; Mon, 9 Dec 2024 04:50:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C286E8D0029 for ; Mon, 9 Dec 2024 04:50:55 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 78FEB1A02E4 for ; Mon, 9 Dec 2024 09:50:55 +0000 (UTC) X-FDA: 82874951082.12.A2C2223 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id EA8FC120015 for ; Mon, 9 Dec 2024 09:50:24 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@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=UOq30mCTMw8bLBxJLSt678CfNIOCZrff0ceauMXHs6E=; b=gwt5sjQMg0NFCyAvtk3ANO7sBTsRgDad/dGlLlni2g3gEPe2X2I1sYCnjWhqgMR3DzL5YZ WTpsl/5UibJEDSusxDRmsNx8msC+/zURN7vECEm1XDeoizpLAHj2lsQN2Zzvhuv/JBH+Il RNXj6KtW5U8GYKc+CbyfOIOWdl8iX+Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737844; a=rsa-sha256; cv=none; b=me++k5q4OdbuIHSDyaj6ovmlsGyBMNZPZq6dUHATKXKJ66+ki/p0kovrpTefQMSeVovKCN FThMfu7Pq8TBYSvcY5WvMw+I1ZCiruJcGfdaGsechsGt1elFvBr40e2/OXxlJKMfkSAOe6 D3bwdxhLKwi7Nu0wJSPC9LyQiVTrHUE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com 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 20D711650; Mon, 9 Dec 2024 01:51:21 -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 173E63F720; Mon, 9 Dec 2024 01:50:50 -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 06/14] selftests/mm: Remove unused pkey helpers Date: Mon, 9 Dec 2024 09:50:11 +0000 Message-ID: <20241209095019.1732120-7-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-Stat-Signature: ify9qw3rjqu9hiiwn6cqhpsbosaon9d6 X-Rspamd-Queue-Id: EA8FC120015 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1733737824-129822 X-HE-Meta: U2FsdGVkX1/0/EcFRmbr89Qc7dwofFh8kj1sYBWskhsbu8c+P4wvjwXo6s3ousoAmK+y9FbY2zN/nj1gGAc18KBpv5m5DnGTaKEEAzWfuY1qm4sOJpJPZ3HrM67n/ooGbhAq4dxcXkd21oS5ydn6CXjx79UWwt3HJqkA9woUwc1bBFRxqyUvh+h+Q8VJfQBWpnxlpE0jm2Dm532jn7f6MneDyyKNu2hv9dVJAW2Mj/oR00Y7lZzogoOf4Ka2gox7UEr4PpixImxd6i6FG+Ojk5h4vW/KFdf4vOeAwTDMYWD0qKLk9UOMbrmeRL0Y6buBU+hCdjQk+4PpCut3isXs0mStiJECakmK5lrQ4worl/WEb+MKn/GOe3iZmhrdWlMAa9zKRFZ03A+tirs73oVzELN6lyMViv8wd68TRqu24zJwBLIG+NGg9TKvUlttK1xm95SDt7GejdXiQcHi7Y0gf8hgtATYUhwLYyxufITJ2RjcujHoQSZQrO0EbqRN1KBpIhYz5hFXGcACz20q2dMTi7QDE1Wz1WC8j3iEciOi5KwIUX5ilvBZmR0fFr3Mjtjn6VbGurmAOE6FtP/VLblzcZtajr18eSMsBhF3NuPXL3hVfpA0XTXinGZ2La1rpXTXtNV5k5SBDNyqfTk0348jd0KiAJtYcH8qU9LimkkUan0urH7oFRbWqRRNSRqPSTQDnPyet9aq+uPxR8EuImR0yXCAk77UtrelXRD3FnBSMb2wzXxIJaFj9fb2p0tXMp6g0tzAhBHY4QnAgHG5iRDrFUcKow/0DKr0Y18NJMx/+Y6tKqUF/yQCT8OdNIgtMYMvgse+mEReO9VtwLwjU0GQWv6kFsIo2e+3jPD+zz+5rNWz0qqoPt8gDcyxa40ghzG5Wq533B2piA6bn5iDdm+goyDI+sgmMFi5uZPE0uzlzaa6LqC4yncYv4KcQA0NbL1E/0jKWI95dsqQtBlq5yu 3C7Ctyir tUA5cZ+GB0CNNMm61AND9wanHzvfFbMBa/bIvdZwElIzZYaiOGeWPsC3onQFkT8YCGFrJcf03Wj5FClcSkY+ERGOy64DMfM69GFtUhrwjouXwHMYIOLqFgA09OOa6e2m+Rs+ffM2PsgfRGBpbQ0M2+Rdh5oRBSmDfY9J0uzBxruQFWh9IQImK6YI91hjRLiJvnu6pVRXxWhqvuhEfaF7mbpXTe3FOfJb7tbLhxw3jPHRc5XYng1saENKvkQ== 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: Commit 5f23f6d082a9 ("x86/pkeys: Add self-tests") introduced a number of helpers and functions that don't seem to have ever been used. Let's remove them. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-helpers.h | 34 -------------------- tools/testing/selftests/mm/protection_keys.c | 34 -------------------- 2 files changed, 68 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index f7cfe163b0ff..472febd992eb 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -26,9 +26,7 @@ #ifndef DEBUG_LEVEL #define DEBUG_LEVEL 0 #endif -#define DPRINT_IN_SIGNAL_BUF_SIZE 4096 extern int dprint_in_signal; -extern char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; extern int test_nr; extern int iteration_nr; @@ -171,38 +169,6 @@ static inline void write_pkey_reg(u64 pkey_reg) pkey_reg, __read_pkey_reg()); } -/* - * These are technically racy. since something could - * change PKEY register between the read and the write. - */ -static inline void __pkey_access_allow(int pkey, int do_allow) -{ - u64 pkey_reg = read_pkey_reg(); - int bit = pkey * 2; - - if (do_allow) - pkey_reg &= (1<= 0); - - ptr = mmap(0, size, prot, MAP_SHARED, fd, 0); - pkey_assert(ptr != (void *)-1); - - mprotect_pkey(ptr, size, prot, pkey); - - record_pkey_malloc(ptr, size, prot); - - dprintf1("mmap()'d for pkey %d @ %p\n", pkey, ptr); - close(fd); - return ptr; -} - void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { malloc_pkey_with_mprotect, malloc_pkey_with_mprotect_subpage, malloc_pkey_anon_huge, malloc_pkey_hugetlb -/* can not do direct with the pkey_mprotect() API: - malloc_pkey_mmap_direct, - malloc_pkey_mmap_dax, -*/ }; void *malloc_pkey(long size, int prot, u16 pkey) From patchwork Mon Dec 9 09:50:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899190 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 A2B96E77173 for ; Mon, 9 Dec 2024 09:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FB6D8D0036; Mon, 9 Dec 2024 04:50:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 235378D0029; Mon, 9 Dec 2024 04:50:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0ADD48D0036; Mon, 9 Dec 2024 04:50:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DB9D88D0029 for ; Mon, 9 Dec 2024 04:50:57 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 974558027C for ; Mon, 9 Dec 2024 09:50:57 +0000 (UTC) X-FDA: 82874950956.07.347A3CC Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 349841A000B for ; Mon, 9 Dec 2024 09:50:34 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737846; a=rsa-sha256; cv=none; b=DKm9MyfsJvww/R9BvGIWDO5/JEpsSEMZhoJLW7paTJhE6+7JFd6loixGc9mbsKArLsME2Q Ri+6GcmJ2yXYFOKhewB+YFqJ152s9uL6YhedJ+fm0Rkr3mkPdx0QRERqu7JCHp7HdMj69S oi6epzRt/qzwYpCEW780QxoBhRpE+0M= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737846; 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=DPrNqYZIVPL79Qc1TOF3mtxorgRM38fEG2ZYgHTWBPY=; b=oV5rCIpkTCOQSWmmzaQWxp9yK8WWvnvpQkuCdwAiN3qMagYCUTUcwYaUetly7b0uAVNXjI F9ukAD0NCewdzZ8TfWDA3bdtyMGRki5NTd5a35J4HTc5fn+bZ4zJ/Y+Q8bM8uM40pvhfOM A1KI80DIQiPUBJokxmobBbMwsoxdSh8= 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 664AB113E; Mon, 9 Dec 2024 01:51:23 -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 5CC003F720; Mon, 9 Dec 2024 01:50:53 -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 07/14] selftests/mm: Define types using typedef in pkey-helpers.h Date: Mon, 9 Dec 2024 09:50:12 +0000 Message-ID: <20241209095019.1732120-8-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 349841A000B X-Stat-Signature: 5gasmm4da9hk5ua3ny7wwqptd9je1t35 X-HE-Tag: 1733737834-3119 X-HE-Meta: U2FsdGVkX1/0OGeaaqRlQcep8V9KgLgaUeAsEMidEmRXePJlYBGmpWRm9XCFc2hH3jp6NtrqnhAkC4Vt2x+MqMDFh8x/17QSeWqiSCTTiy6IsI8HyqnqPHXOOEeBEqORE+zOTvMDeGkg8CzNogcvx8YBY6+CvI8I0wJTZx6n7VI7Tt8J02Vff1v6COlavyvCCcZtdIGX+NhEUCMPKwTsCAeRu3GeYUcjeZOlA4TY3PGz7zRmzXnvni1Scbzc04HQfLnBn1fibVjKBPrJ+sPxV2whbIzTEOvjW3229A/YirlrkECE69jF60T0z+lOdwcZIjm4inVnCqy+jMR5o0O3Sv2/zYs4iwCWvQa4ZboBZaWlIfH4tX4r6/6Rqgvb4uQAayMXu7tuap+oLRYslfo1TMOBcX9n4j6g7miZlqPIlxtHXK7aJwINBGBVgBd5Jhmp/UPImd+sLX1iGNpQuvFd1FhEP+e5ocWMFQbdElldT0u/I0MVCmKH9+VsSnMy7GPAkJ0aa/tBMIORYGh8O4WU5g+Bn+QdIaajWD/AEn06dORpQGUsaVgRwzFaN3vPrY7xfPX9bNOMgkp5GUlZQvMrI0lOtruWUjpEBvbwteQAdhdXt4RRPzCIcQQpT+gtxrWMOYZmjFAr1J5tvaY4HFmH7xGGt4CfYku6ONNhWy22oYb6VW9nWgZLLFo0vD8Ni4mgEBe4s/ANbFGdnGbunR08eTeTOZ4FcMvByX+x1Y6CPebSYkpcoINE3eX/zbKgx+aUwNsNABFUrkcyrS2iU6/tay4zqH6KDWxoPmxC+zFIBH5c9ckhdieBcuknoj01uMhFWNdTyf4tpSVYSYwKU6vMhxuYbICop18uuGLuhIKW7I6Mi3Y2SVKlXPu5fZ4pAGXCIMDoUD/hSBauyo4I/bVwbHTEsERocV7Ux6TquLMHOZj3osKwxsgvxph7jyZBw+Pp6WytchMe1vm9Beh6vKa h0cRdrk/ eJrucguYW65K5TTOc8WVT9lWYVeEzJldcs3RtdXY2b86Lc5gnKpfOQKTsx8Xd3ODTeS628Ij/YSs/yjO7f8lV79Ylu4sQC1cSJRBHt/iuQAx2vcAfrFOxpOBBH5K/T2jLNKvdj8iTctFephnCzzr+AVgOj1ehnMzo7mwhwGLEflYxDIVCEYK98lsxmqDyCTQp5wBnoQEVP2pdyVIbQBaiNswFUh+SmQeJe41wiq8ux+l4mPWLQ3kYP2MdD5pOq9KyABEODXedbe4iV1WoOlYa1JJckg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Using #define to define types should be avoided. Use typedef instead. Also ensure that __u* types are actually defined by including . Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-helpers.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 472febd992eb..84376ab09545 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -13,13 +13,15 @@ #include #include +#include + #include "../kselftest.h" /* Define some kernel-like types */ -#define u8 __u8 -#define u16 __u16 -#define u32 __u32 -#define u64 __u64 +typedef __u8 u8; +typedef __u16 u16; +typedef __u32 u32; +typedef __u64 u64; #define PTR_ERR_ENOTSUP ((void *)-ENOTSUP) 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); From patchwork Mon Dec 9 09:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899192 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 629DEE7717D for ; Mon, 9 Dec 2024 09:51:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FED38D0038; Mon, 9 Dec 2024 04:51:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9874E8D0029; Mon, 9 Dec 2024 04:51:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 801298D0038; Mon, 9 Dec 2024 04:51:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5E8AF8D0029 for ; Mon, 9 Dec 2024 04:51:02 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2A7FB1602A7 for ; Mon, 9 Dec 2024 09:51:02 +0000 (UTC) X-FDA: 82874951502.05.DBA65E3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf23.hostedemail.com (Postfix) with ESMTP id F324E14000A for ; Mon, 9 Dec 2024 09:50:46 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.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=1733737846; 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=w2y+Dg42mIu9JWvjXkfAniTHPccqNpvaYDKwTs4BPKw=; b=IK65EYAHgdKyRkqcKs3kRDBoVnjTVP+XYcsY7PSmGsENCnXlNyjTXfo/mfJUQ3d9SYXfdk L0UCna2/sFszRtZsHfJvfAGQQzomBlnGA4UqhJmWqir+Y+CQCQ/L6P1WNpkRJdO9iIkui5 X0oO9dA+I46Lb6sJNd7pBC+c2ubYqTA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.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=1733737846; a=rsa-sha256; cv=none; b=ai19Gw3HiLmXh2h1yu9KE5sEmDc75kBNPmX9k2JsHMkPJ7tGbo4PC0agrEO/T3zZiC3160 BJqgIQ+cDesY33D+l4WzkCHVxxvdu3oS8zgg/Yajnfioj//RjSu/j6gTUb/wpd7u1UBYQP D+ayqm16EAUCNbAwVysnPueUBQ9QjJo= 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 F0FA0143D; Mon, 9 Dec 2024 01:51:27 -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 E7F5E3F720; Mon, 9 Dec 2024 01:50:57 -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 09/14] selftests/mm: Remove empty pkey helper definition Date: Mon, 9 Dec 2024 09:50:14 +0000 Message-ID: <20241209095019.1732120-10-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: xhpy3eq1yeeneqq36kpahb5bq5x4efzj X-Rspamd-Queue-Id: F324E14000A X-Rspam-User: X-HE-Tag: 1733737846-487069 X-HE-Meta: U2FsdGVkX195IWZPLZ70oPgKsoOm0ttGf9n1g0JR5xq7kBMsBaCMfbUHaReiE/jvQUZNi7QC0Xryw0f9G3q3pPYCn9Y6KWdnuxqAcfeA6Pd5AuVodSSsGwh9L/uHSSsg1M3K4uvP7c4EX5EbeSWKBwD39e3qnQiSo+lapk+kJdpwOvu8CAclpXOa/5+7eqo2oRMh+fm8jHU1ZtLu+8GsUAYFTlKxK12en2j91XBbxsweDkZQ1s8giQJz6/IHrmCMhD++O04jnnd29YETus4/OKJAnHcKBRrBWpi0+KSwEc2rK8XOlBQJ3cT9h+boZCyZHzgOoPl0vNw8rcZ33oU/RZm/0GXqXGymKAYYcQlEuMzMoBJKHJUaWiSD0ndNARuxunGYZeVcvVFOXX6qwANyvD4cpnVyfYMJiiLvkjWvMLLMk/BxI+kDrnvxt3b/p0PtOfYafsW63rIWPDkRVqnlBXkL6MKBYrPuKEHxbaz56MrZTX0TrelYmZYbx4MgHdhL2RijYsjWtBwAe7HGPEQ5FCPTTg63v1Gh2R0cxfrFe5PhNPP8fzsrylYWXBEmnfJtYH3JKc4X5ZILKA2DaN2k5jm8xYqYhCCTl5ef84ZR7V8jeesxXGcZ07Cx+u15kNOPt9jGmaiZIDwJnMMIyFnxRRTyhQc0kT9Rn24TAF1JlnlQpbCjyp6o2rBuuBMD2BE+T1QXibEyZ4y4mNUsCjSzSb1DB6HtHcv5g0nsyPAPxWVefEjegYtNc7ZfByirHG2BRZ+4sMxC6zTQO+tlnKvSt+bLO0qnQV/8/KVUfWlEN1/i1wOHZfMJBrwEbj0SLDQLr+nWDY7QR2tajSRkrF38Wh/Q9ZWrDdQEXgf18Rwe2zU0IcdhAPjAo+jmbcvXEAOC9jVcwj+xfM89MF5jS5uqGI/h5UFKa2aAzE5AggT0uT4REMqWjyfh918vAptz6zpe0QLTlXu2ZylZMkCVlAz Xv7AjVeS UCCGP9L91YQ4K0EfLZr01BxCp2zEmphQluVkcHoDVU6f4AmY/G1GpJGR/hXOn6Ocjf2hvauIDpbUFECe9Ri5RqDW5NpL1Y5KWaKoa5nQa57gZWuoYk/0x+YQCUGtjNMkFO2jollnaOs7lW0jj0v1dVoaBPV8ZbCEpS8U+Z/CNUh0rlQHh4+oB67bXzD2jjKOXWhp+n/0h1fAlsFoYceGKNa7OVB0hDarVQJThm4qL5ZRhN/CfXshgp/PR0Q== 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: Some of the functions declared in pkey-helpers.h are actually defined in protections_keys.c, meaning they can only be called from protections_keys.c. This is less than ideal, but it is hard to avoid as these helpers are themselves called from inline functions in pkey-.h. Let's at least add a comment clarifying that. We can also remove the empty definition in pkey_sighandler_tests.c: expected_pkey_fault() is not meant to be called from there. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-helpers.h | 6 ++++-- tools/testing/selftests/mm/pkey_sighandler_tests.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index bc81275a89d9..7604cc66ef0e 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -84,10 +84,12 @@ extern void abort_hooks(void); # define noinline __attribute__((noinline)) #endif -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); + +/* For functions called from protection_keys.c only */ +noinline int read_ptr(int *ptr); +void expected_pkey_fault(int pkey); int mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, unsigned long pkey); void record_pkey_malloc(void *ptr, long size, int prot); diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index e7b91794f184..d18e38b19792 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -32,8 +32,6 @@ #define STACK_SIZE PTHREAD_STACK_MIN -void expected_pkey_fault(int pkey) {} - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; siginfo_t siginfo = {0}; From patchwork Mon Dec 9 09:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899193 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 D53FEE77180 for ; Mon, 9 Dec 2024 09:51:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40B878D003B; Mon, 9 Dec 2024 04:51:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 393C68D0029; Mon, 9 Dec 2024 04:51:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199808D003B; Mon, 9 Dec 2024 04:51:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E37408D0029 for ; Mon, 9 Dec 2024 04:51:04 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A2FCF409EC for ; Mon, 9 Dec 2024 09:51:04 +0000 (UTC) X-FDA: 82874951250.13.454839B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 97EFC18000B for ; Mon, 9 Dec 2024 09:50:48 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.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=1733737841; 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=IOyMkFiy9dvZ24jl1FV1Ru0VpOa/gABElXzTX8I9LwY=; b=G6SvARYUlDQiqBBrVA3rpu1jUNtk4vMB0370iHXIwZwxkESeA+bNjbuBgHEiFjXLDqX1R1 pH4xHHxCJ5TOHqucK/pFctoia3vBs2abYslucXclwb9TdT1amEGuUAFaDMLV9GxF02RdhZ ogD2A+HxTB/VlOM1xvB/RvULJa32fvQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.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=1733737841; a=rsa-sha256; cv=none; b=G3vk2Dq+wQdIA9LZWoUhwt6ttuwZ74d0xYUo30BsgSn1ZnRhG2KczYbHCXbc6EhYwIQknv E1CjFiANEbVmuywy5BNOwtFmSxC/1PKV5O8sb8jhZ/vzVXn09Ee5rTMCONNsSxeL5F1TFM kljBwbtz4OMmR8ONW+8NeDgqIMC3uJM= 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 623EB113E; Mon, 9 Dec 2024 01:51:30 -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 3A0FD3F720; Mon, 9 Dec 2024 01:51:00 -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 10/14] selftests/mm: Ensure non-global pkey symbols are marked static Date: Mon, 9 Dec 2024 09:50:15 +0000 Message-ID: <20241209095019.1732120-11-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: rspam06 X-Rspamd-Queue-Id: 97EFC18000B X-Rspam-User: X-Stat-Signature: fo4ibhgmpez7qe6kiqmerd365aenk8ap X-HE-Tag: 1733737848-113256 X-HE-Meta: U2FsdGVkX18grfx2o6oKrPEn78WLS7WgvdvzzaJ1o+MYOxBqHexam56/X86xbVpWVMSpb3LsFd9IMoJVebVCGcCNHC1y2ZMm5UpV3vCojhxY3KRUTcL6xxJD5MbUTUvpyJEpfeRCax0lzH6mKogj3WUN00Kz7cS9mmjKH9xgelvdN6AYGaqo5IzB8qF5WSVhkVInVCGGKn3em8RUqyrB1O1trxU7CNwHXNttpjKbZFKm78seGdEGT7wpH4mxHMMNxAM/CKkrHkAarr7YlYFOvnXvhhSXNj44/oNBbt2jkWd3DAXxkZVdTlde1ouq7xzArGZfe+YDPKNsj9UtkyG5oXcIoy6e4TDeGDMQRmGLHcibxsqVtCpcU489cgh6pdQUJ/kt1sIaGbEVzqEavsi+x/TsGghuiAbEcBgaAzJrgLzsd0Eiuu3BITColCtybqrp0JoY+c4zQEa22fyHhj3LA9uRvPxOEeZgEsYse/YLuCl61pclRrGUrSubjWQUquQiN9ILTqafM49vAv69r9sFYPH5tMuX9oOzC09VTw9wLkE0McWB0uli/6BfvCLUR7x91Lejq7VQdBHVW/OAxdjL00lv/FleFnETDV4/7OEZOkfgNW9LLF3/PPAnZngB3KrtiAxxBQysciKB0aurTM6Qpx7yBUKnSPL/zifHHtBzw+u24MjmwO2cFmLbnuuY2mYtNgGXR9M/Oo2efA3TUQKFTYC4BdovQ9IC8cJGt4eH03hVvDqMdwXEV/LwIkAVw5D/TTCuV/k9bfRX8mBpaGJMaYQE4hssBQp5lA26vn/1UWsOfUIL870Ihf7Uy5PYzPKUeFkhYqDpYBMB0dnB1D/45KKpmfMMdMYuAwAJUpTQzvAH+tnaxTG2Ccssjas5Fo570o5Kb9s8goND16XChHuMmtwLPEcbBIp6rQZaJekRliWxL3A+Y29LoAGvN0DphHk2l2ghDljJG6B78i3gORG NifPSPR3 VkojBfi52EYysFtB8oi0/y0ONUSwrzToJ76JNNpoakLm//Ut0f/Ge1B2isIQ/XrMelDKXzPfWDA61RUjvvGnQtlUGnQAfa0gwp5NVRhvk7EgsjoyUIbJU1nL4X5R39cIoTxUMswVIto4ep8zqymT5EPkyKlPxyyTwcKx6heADNQs3TKM+7Uun3C7K0uUILxcrlOqBhLY0ATl4GaGIIbnBjvKnWvxhPRsdDmIDE+/V06o4jPzlR+uJDRobXQ== 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: The pkey tests define a whole lot of functions and some global variables. A few are truly global (declared in pkey-helpers.h), but the majority are file-scoped. Make sure those are labelled static. Some of the pkey_{access,write}_{allow,deny} helpers are not called, or only called when building for some architectures. Mark them __maybe_unused to suppress compiler warnings. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-helpers.h | 3 + .../selftests/mm/pkey_sighandler_tests.c | 6 +- tools/testing/selftests/mm/protection_keys.c | 132 +++++++++--------- 3 files changed, 72 insertions(+), 69 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 7604cc66ef0e..6f0ab7b42738 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -83,6 +83,9 @@ extern void abort_hooks(void); #ifndef noinline # define noinline __attribute__((noinline)) #endif +#ifndef __maybe_unused +# define __maybe_unused __attribute__((__unused__)) +#endif 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_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index d18e38b19792..e1aaeb65cfae 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -32,9 +32,9 @@ #define STACK_SIZE PTHREAD_STACK_MIN -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -siginfo_t siginfo = {0}; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +static siginfo_t siginfo = {0}; /* * We need to use inline assembly instead of glibc's syscall because glibc's diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index 82ece325b70c..f43cf3b75d8e 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -61,7 +61,7 @@ noinline int read_ptr(int *ptr) return *ptr; } -void cat_into_file(char *str, char *file) +static void cat_into_file(char *str, char *file) { int fd = open(file, O_RDWR); int ret; @@ -88,7 +88,7 @@ void cat_into_file(char *str, char *file) #if CONTROL_TRACING > 0 static int warned_tracing; -int tracing_root_ok(void) +static int tracing_root_ok(void) { if (geteuid() != 0) { if (!warned_tracing) @@ -101,7 +101,7 @@ int tracing_root_ok(void) } #endif -void tracing_on(void) +static void tracing_on(void) { #if CONTROL_TRACING > 0 #define TRACEDIR "/sys/kernel/tracing" @@ -125,7 +125,7 @@ void tracing_on(void) #endif } -void tracing_off(void) +static void tracing_off(void) { #if CONTROL_TRACING > 0 if (!tracing_root_ok()) @@ -159,7 +159,7 @@ __attribute__((__aligned__(65536))) #else __attribute__((__aligned__(PAGE_SIZE))) #endif -void lots_o_noops_around_write(int *write_to_me) +static void lots_o_noops_around_write(int *write_to_me) { dprintf3("running %s()\n", __func__); __page_o_noops(); @@ -170,7 +170,7 @@ void lots_o_noops_around_write(int *write_to_me) dprintf3("%s() done\n", __func__); } -void dump_mem(void *dumpme, int len_bytes) +static void dump_mem(void *dumpme, int len_bytes) { char *c = (void *)dumpme; int i; @@ -213,7 +213,7 @@ static int hw_pkey_set(int pkey, unsigned long rights, unsigned long flags) return 0; } -void pkey_disable_set(int pkey, int flags) +static void pkey_disable_set(int pkey, int flags) { unsigned long syscall_flags = 0; int ret; @@ -251,7 +251,7 @@ void pkey_disable_set(int pkey, int flags) pkey, flags); } -void pkey_disable_clear(int pkey, int flags) +static void pkey_disable_clear(int pkey, int flags) { unsigned long syscall_flags = 0; int ret; @@ -277,19 +277,19 @@ void pkey_disable_clear(int pkey, int flags) pkey, read_pkey_reg()); } -void pkey_write_allow(int pkey) +__maybe_unused static void pkey_write_allow(int pkey) { pkey_disable_clear(pkey, PKEY_DISABLE_WRITE); } -void pkey_write_deny(int pkey) +__maybe_unused static void pkey_write_deny(int pkey) { pkey_disable_set(pkey, PKEY_DISABLE_WRITE); } -void pkey_access_allow(int pkey) +__maybe_unused static void pkey_access_allow(int pkey) { pkey_disable_clear(pkey, PKEY_DISABLE_ACCESS); } -void pkey_access_deny(int pkey) +__maybe_unused static void pkey_access_deny(int pkey) { pkey_disable_set(pkey, PKEY_DISABLE_ACCESS); } @@ -307,9 +307,9 @@ static char *si_code_str(int si_code) return "UNKNOWN"; } -int pkey_faults; -int last_si_pkey = -1; -void signal_handler(int signum, siginfo_t *si, void *vucontext) +static int pkey_faults; +static int last_si_pkey = -1; +static void signal_handler(int signum, siginfo_t *si, void *vucontext) { ucontext_t *uctxt = vucontext; int trapno; @@ -403,14 +403,14 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) dprint_in_signal = 0; } -void sig_chld(int x) +static void sig_chld(int x) { dprint_in_signal = 1; dprintf2("[%d] SIGCHLD: %d\n", getpid(), x); dprint_in_signal = 0; } -void setup_sigsegv_handler(void) +static void setup_sigsegv_handler(void) { int r, rs; struct sigaction newact; @@ -436,13 +436,13 @@ void setup_sigsegv_handler(void) pkey_assert(r == 0); } -void setup_handlers(void) +static void setup_handlers(void) { signal(SIGCHLD, &sig_chld); setup_sigsegv_handler(); } -pid_t fork_lazy_child(void) +static pid_t fork_lazy_child(void) { pid_t forkret; @@ -488,7 +488,7 @@ int sys_pkey_alloc(unsigned long flags, unsigned long init_val) return ret; } -int alloc_pkey(void) +static int alloc_pkey(void) { int ret; unsigned long init_val = 0x0; @@ -546,7 +546,7 @@ int sys_pkey_free(unsigned long pkey) * not cleared. This ensures we get lots of random bit sets * and clears on the vma and pte pkey bits. */ -int alloc_random_pkey(void) +static int alloc_random_pkey(void) { int max_nr_pkey_allocs; int ret; @@ -629,7 +629,7 @@ struct pkey_malloc_record { }; struct pkey_malloc_record *pkey_malloc_records; struct pkey_malloc_record *pkey_last_malloc_record; -long nr_pkey_malloc_records; +static long nr_pkey_malloc_records; void record_pkey_malloc(void *ptr, long size, int prot) { long i; @@ -667,7 +667,7 @@ void record_pkey_malloc(void *ptr, long size, int prot) nr_pkey_malloc_records++; } -void free_pkey_malloc(void *ptr) +static void free_pkey_malloc(void *ptr) { long i; int ret; @@ -694,8 +694,7 @@ void free_pkey_malloc(void *ptr) pkey_assert(false); } - -void *malloc_pkey_with_mprotect(long size, int prot, u16 pkey) +static void *malloc_pkey_with_mprotect(long size, int prot, u16 pkey) { void *ptr; int ret; @@ -715,7 +714,7 @@ void *malloc_pkey_with_mprotect(long size, int prot, u16 pkey) return ptr; } -void *malloc_pkey_anon_huge(long size, int prot, u16 pkey) +static void *malloc_pkey_anon_huge(long size, int prot, u16 pkey) { int ret; void *ptr; @@ -745,10 +744,10 @@ void *malloc_pkey_anon_huge(long size, int prot, u16 pkey) return ptr; } -int hugetlb_setup_ok; +static int hugetlb_setup_ok; #define SYSFS_FMT_NR_HUGE_PAGES "/sys/kernel/mm/hugepages/hugepages-%ldkB/nr_hugepages" #define GET_NR_HUGE_PAGES 10 -void setup_hugetlbfs(void) +static void setup_hugetlbfs(void) { int err; int fd; @@ -796,7 +795,7 @@ void setup_hugetlbfs(void) hugetlb_setup_ok = 1; } -void *malloc_pkey_hugetlb(long size, int prot, u16 pkey) +static void *malloc_pkey_hugetlb(long size, int prot, u16 pkey) { void *ptr; int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB; @@ -817,7 +816,7 @@ void *malloc_pkey_hugetlb(long size, int prot, u16 pkey) return ptr; } -void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { +static void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { malloc_pkey_with_mprotect, malloc_pkey_with_mprotect_subpage, @@ -825,7 +824,7 @@ void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { malloc_pkey_hugetlb }; -void *malloc_pkey(long size, int prot, u16 pkey) +static void *malloc_pkey(long size, int prot, u16 pkey) { void *ret; static int malloc_type; @@ -855,7 +854,7 @@ void *malloc_pkey(long size, int prot, u16 pkey) return ret; } -int last_pkey_faults; +static int last_pkey_faults; #define UNKNOWN_PKEY -2 void expected_pkey_fault(int pkey) { @@ -897,9 +896,9 @@ void expected_pkey_fault(int pkey) pkey_assert(last_pkey_faults == pkey_faults); \ } while (0) -int test_fds[10] = { -1 }; -int nr_test_fds; -void __save_test_fd(int fd) +static int test_fds[10] = { -1 }; +static int nr_test_fds; +static void __save_test_fd(int fd) { pkey_assert(fd >= 0); pkey_assert(nr_test_fds < ARRAY_SIZE(test_fds)); @@ -907,14 +906,14 @@ void __save_test_fd(int fd) nr_test_fds++; } -int get_test_read_fd(void) +static int get_test_read_fd(void) { int test_fd = open("/etc/passwd", O_RDONLY); __save_test_fd(test_fd); return test_fd; } -void close_test_fds(void) +static void close_test_fds(void) { int i; @@ -927,7 +926,7 @@ void close_test_fds(void) nr_test_fds = 0; } -void test_pkey_alloc_free_attach_pkey0(int *ptr, u16 pkey) +static void test_pkey_alloc_free_attach_pkey0(int *ptr, u16 pkey) { int i, err; int max_nr_pkey_allocs; @@ -979,7 +978,7 @@ void test_pkey_alloc_free_attach_pkey0(int *ptr, u16 pkey) pkey_assert(!err); } -void test_read_of_write_disabled_region(int *ptr, u16 pkey) +static void test_read_of_write_disabled_region(int *ptr, u16 pkey) { int ptr_contents; @@ -989,7 +988,7 @@ void test_read_of_write_disabled_region(int *ptr, u16 pkey) dprintf1("*ptr: %d\n", ptr_contents); dprintf1("\n"); } -void test_read_of_access_disabled_region(int *ptr, u16 pkey) +static void test_read_of_access_disabled_region(int *ptr, u16 pkey) { int ptr_contents; @@ -1001,7 +1000,7 @@ void test_read_of_access_disabled_region(int *ptr, u16 pkey) expected_pkey_fault(pkey); } -void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, +static void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, u16 pkey) { int ptr_contents; @@ -1018,7 +1017,7 @@ void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } -void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, +static void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, u16 pkey) { *ptr = __LINE__; @@ -1029,14 +1028,14 @@ void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } -void test_write_of_write_disabled_region(int *ptr, u16 pkey) +static void test_write_of_write_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey); pkey_write_deny(pkey); *ptr = __LINE__; expected_pkey_fault(pkey); } -void test_write_of_access_disabled_region(int *ptr, u16 pkey) +static void test_write_of_access_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling access to PKEY[%02d], doing write\n", pkey); pkey_access_deny(pkey); @@ -1044,7 +1043,7 @@ void test_write_of_access_disabled_region(int *ptr, u16 pkey) expected_pkey_fault(pkey); } -void test_write_of_access_disabled_region_with_page_already_mapped(int *ptr, +static void test_write_of_access_disabled_region_with_page_already_mapped(int *ptr, u16 pkey) { *ptr = __LINE__; @@ -1055,7 +1054,7 @@ void test_write_of_access_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } -void test_kernel_write_of_access_disabled_region(int *ptr, u16 pkey) +static void test_kernel_write_of_access_disabled_region(int *ptr, u16 pkey) { int ret; int test_fd = get_test_read_fd(); @@ -1067,7 +1066,8 @@ void test_kernel_write_of_access_disabled_region(int *ptr, u16 pkey) dprintf1("read ret: %d\n", ret); pkey_assert(ret); } -void test_kernel_write_of_write_disabled_region(int *ptr, u16 pkey) + +static void test_kernel_write_of_write_disabled_region(int *ptr, u16 pkey) { int ret; int test_fd = get_test_read_fd(); @@ -1080,7 +1080,7 @@ void test_kernel_write_of_write_disabled_region(int *ptr, u16 pkey) pkey_assert(ret); } -void test_kernel_gup_of_access_disabled_region(int *ptr, u16 pkey) +static void test_kernel_gup_of_access_disabled_region(int *ptr, u16 pkey) { int pipe_ret, vmsplice_ret; struct iovec iov; @@ -1102,7 +1102,7 @@ void test_kernel_gup_of_access_disabled_region(int *ptr, u16 pkey) close(pipe_fds[1]); } -void test_kernel_gup_write_to_write_disabled_region(int *ptr, u16 pkey) +static void test_kernel_gup_write_to_write_disabled_region(int *ptr, u16 pkey) { int ignored = 0xdada; int futex_ret; @@ -1120,7 +1120,7 @@ void test_kernel_gup_write_to_write_disabled_region(int *ptr, u16 pkey) } /* Assumes that all pkeys other than 'pkey' are unallocated */ -void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) +static void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) { int err; int i; @@ -1143,7 +1143,7 @@ void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) } /* Assumes that all pkeys other than 'pkey' are unallocated */ -void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) +static void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) { int err; int bad_pkey = NR_PKEYS+99; @@ -1153,7 +1153,7 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) pkey_assert(err); } -void become_child(void) +static void become_child(void) { pid_t forkret; @@ -1169,7 +1169,7 @@ void become_child(void) } /* Assumes that all pkeys other than 'pkey' are unallocated */ -void test_pkey_alloc_exhaust(int *ptr, u16 pkey) +static void test_pkey_alloc_exhaust(int *ptr, u16 pkey) { int err; int allocated_pkeys[NR_PKEYS] = {0}; @@ -1236,7 +1236,7 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) } } -void arch_force_pkey_reg_init(void) +static void arch_force_pkey_reg_init(void) { #if defined(__i386__) || defined(__x86_64__) /* arch */ u64 *buf; @@ -1275,7 +1275,7 @@ void arch_force_pkey_reg_init(void) * a long-running test that continually checks the pkey * register. */ -void test_pkey_init_state(int *ptr, u16 pkey) +static void test_pkey_init_state(int *ptr, u16 pkey) { int err; int allocated_pkeys[NR_PKEYS] = {0}; @@ -1313,7 +1313,7 @@ void test_pkey_init_state(int *ptr, u16 pkey) * have to call pkey_alloc() to use it first. Make sure that it * is usable. */ -void test_mprotect_with_pkey_0(int *ptr, u16 pkey) +static void test_mprotect_with_pkey_0(int *ptr, u16 pkey) { long size; int prot; @@ -1337,7 +1337,7 @@ void test_mprotect_with_pkey_0(int *ptr, u16 pkey) mprotect_pkey(ptr, size, prot, pkey); } -void test_ptrace_of_child(int *ptr, u16 pkey) +static void test_ptrace_of_child(int *ptr, u16 pkey) { __attribute__((__unused__)) int peek_result; pid_t child_pid; @@ -1413,7 +1413,7 @@ void test_ptrace_of_child(int *ptr, u16 pkey) free(plain_ptr_unaligned); } -void *get_pointer_to_instructions(void) +static void *get_pointer_to_instructions(void) { void *p1; @@ -1434,7 +1434,7 @@ void *get_pointer_to_instructions(void) return p1; } -void test_executing_on_unreadable_memory(int *ptr, u16 pkey) +static void test_executing_on_unreadable_memory(int *ptr, u16 pkey) { void *p1; int scratch; @@ -1466,7 +1466,7 @@ void test_executing_on_unreadable_memory(int *ptr, u16 pkey) pkey_assert(!ret); } -void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey) +static void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey) { void *p1; int scratch; @@ -1515,7 +1515,7 @@ void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey) } #if defined(__i386__) || defined(__x86_64__) -void test_ptrace_modifies_pkru(int *ptr, u16 pkey) +static void test_ptrace_modifies_pkru(int *ptr, u16 pkey) { u32 new_pkru; pid_t child; @@ -1638,7 +1638,7 @@ void test_ptrace_modifies_pkru(int *ptr, u16 pkey) #endif #if defined(__aarch64__) -void test_ptrace_modifies_pkru(int *ptr, u16 pkey) +static void test_ptrace_modifies_pkru(int *ptr, u16 pkey) { pid_t child; int status, ret; @@ -1715,7 +1715,7 @@ void test_ptrace_modifies_pkru(int *ptr, u16 pkey) } #endif -void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) +static void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) { int size = PAGE_SIZE; int sret; @@ -1729,7 +1729,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) pkey_assert(sret < 0); } -void (*pkey_tests[])(int *ptr, u16 pkey) = { +static void (*pkey_tests[])(int *ptr, u16 pkey) = { test_read_of_write_disabled_region, test_read_of_access_disabled_region, test_read_of_access_disabled_region_with_page_already_mapped, @@ -1755,7 +1755,7 @@ void (*pkey_tests[])(int *ptr, u16 pkey) = { #endif }; -void run_tests_once(void) +static void run_tests_once(void) { int *ptr; int prot = PROT_READ|PROT_WRITE; @@ -1789,7 +1789,7 @@ void run_tests_once(void) iteration_nr++; } -void pkey_setup_shadow(void) +static void pkey_setup_shadow(void) { shadow_pkey_reg = __read_pkey_reg(); } From patchwork Mon Dec 9 09:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899194 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 A829EE7717D for ; Mon, 9 Dec 2024 09:51:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F3CB8D0040; Mon, 9 Dec 2024 04:51:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67B868D0029; Mon, 9 Dec 2024 04:51:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F4438D0040; Mon, 9 Dec 2024 04:51:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 24CA18D0029 for ; Mon, 9 Dec 2024 04:51:07 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D3E7E14027A for ; Mon, 9 Dec 2024 09:51:06 +0000 (UTC) X-FDA: 82874951754.16.2D44DDF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 7077E40014 for ; Mon, 9 Dec 2024 09:50:46 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737856; 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=Ikxvul1YEZ1JZMqMyeWN6QrFnKi6/EKYx8Mcx81qqDY=; b=2yNpop7aYFpzYyY7+4DnmbYpaa8gD0ce678pPSScOU6MEL5Y9D7/T1dd1tTPIEDKQRkOQ/ bJY6fEUimTqwbPq4SGeWrqufuFu4nahLTelX40ruiHP+pU4mzaXx0uRycDc85waRE7Nopm Y8HfxHTT8oPdqk/rTB2QHEECE6sDGZQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737856; a=rsa-sha256; cv=none; b=jAqSQQo5kLiLWecZGhAV0iqv8vNmpt0Hs/7ahgxlsouHtvG6ldfkUNtLv13wOosuc66Q+e nLgppdemrg/4v/p94aV6DfWm/h15e3KJBEOprMklZUx22Fe7kZK7Stcjj5w/4brMfikESS 0vnMVhOlMyxDQhGvbG4dtkl6t8aetnc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 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 A82F6143D; Mon, 9 Dec 2024 01:51:32 -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 9E7263F720; Mon, 9 Dec 2024 01:51:02 -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 11/14] selftests/mm: Use sys_pkey helpers consistently Date: Mon, 9 Dec 2024 09:50:16 +0000 Message-ID: <20241209095019.1732120-12-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-Stat-Signature: eshu9hmcjc6816u8a519o8dgdq4nefbn X-Rspamd-Queue-Id: 7077E40014 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1733737846-282044 X-HE-Meta: U2FsdGVkX1+Ic0zHOxsSh0IdNZEZcsxYUduAiJzds/FFhOi7apQVEIGKbd0NwA3XEfiMJtHvG1Sfciuc6N3qM5hAGK696PVUIBoJUOofMur7T31PbEvLwz5J5JL/nm9kcq6W463J0HEYE+U24Sgo6XON1yBFppaoJjuOWPqpHiOeVoNzrrMbRpmjSkbMFo/k9iROwz0gyWI6O//KV0EDp4dsiIbcope/vNRWmBCbg+w5wrZlTavuUE4nHuDbcZENyJ8PiiXMDoDpbDhXsLGK/vRjTx3cYEEflYqVqbB+/l4VeCW6w9PD2d20N0FSMsRwsgAFk9dZTO4MKR0hlkw1ibyI+x34aYEPNpBagnqurXbp9UUKs4QN4821gjKqB4eGcdcWhD+J1+HYYVyg6bd+U8NNoJMNKZ3aB5hxsUqdx/AgVDpYaz0yj/w5VWj6sUW2XUYiG/dU+P8sozWBbpUbHAII9a/pflmOyuc+0yFrEh+rkcYND8CkUkJqXqgqACc5UbzHvRaVTcFgFeHOtJCt+jDpXyDWU28lKc6eBxD1qdUIiAvJDbsuES67gddzr1wibt4pkq/NGgYs1S3qGtwaCp35W/G/j4KVo089afOr+JpdC7DiQ528pUDtEP+1U965ovILiJVqYrIdmDakCXa78u/X+wuqBLCsD6UnCDgDl8W90y/Os9svgI4BJlSerk/P3WuYHF/LoNsvfDydyw3egQ0RobrZixPEGMrYgbrUloiW8uPiER5fDqPvMmBpNm01kouI6xFU63GUpb9Hk+LBDeOjYKZDcx3tfXDCu5UvN5iJxKef0bfSFlhUilVTQOOWDg4CKwhG9feGQhUkwf1GVcEz04ob3vyEycbsGU1M69DzJbrUocSMmObS4FUvb0zZXNIrSP1Ws54ZFc+sEavD15QMw+ArEFgPfqHZYthwKH+GTqXLMoYwnBqY8k8cIMllovnhe7DC9/DBg0gcYa5 xfuvZj6D 7nhSGK3vcOVCJhuoOmTe5uAX5xWP3DSOqU1G/cn/2ueE9U5uEj97eBmn33wXQ7PZp7MpLCIJxjL0bjVi2myMVPvd13TdFQC5d6/epsPdIkzz7feRFIDLTy4ptcbYwP8qm0K3RO5yLO3DsHI2hRaFKM3gmZd7Tetmq4XcKamzZRRLz12HD9Ne4yIEQKthlkphlZTYuEQei66J9492EQcen9vZ3IYqp53QnR5PZ3HYlhDqJK+CG4r6F7w5Nsc8wcV1h1N+eYFOYl9MuJmrHOLJLI/5e5jZlpvlidVsKIwEdqB4SSwLUUQp1yF6trISTW5SilGA3dzffgp12r0E= 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: sys_pkey_alloc, sys_pkey_free and sys_mprotect_pkey are currently used in protections_keys.c, while pkey_sighandler_tests.c calls the libc wrappers directly (e.g. pkey_mprotect()). This is probably ok when using glibc (those symbols appeared a while ago), but Musl does not currently provide them. The logging in the helpers from pkey-helpers.h can also come in handy. Make things more consistent by using the sys_pkey helpers in pkey_sighandler_tests.c too. To that end their implementation is moved to a common .c file (pkey_util.c). This also enables calling is_pkeys_supported() outside of protections_keys.c, since it relies on sys_pkey_{alloc,free}. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/Makefile | 4 +- tools/testing/selftests/mm/pkey-helpers.h | 2 + .../selftests/mm/pkey_sighandler_tests.c | 8 ++-- tools/testing/selftests/mm/pkey_util.c | 40 +++++++++++++++++++ tools/testing/selftests/mm/protection_keys.c | 35 ---------------- 5 files changed, 48 insertions(+), 41 deletions(-) create mode 100644 tools/testing/selftests/mm/pkey_util.c diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 814b17a43385..1f0743d9459d 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -147,8 +147,8 @@ TEST_FILES += write_hugetlb_memory.sh include ../lib.mk -$(TEST_GEN_PROGS): vm_util.c thp_settings.c -$(TEST_GEN_FILES): vm_util.c thp_settings.c +$(TEST_GEN_PROGS): vm_util.c thp_settings.c pkey_util.c +$(TEST_GEN_FILES): vm_util.c thp_settings.c pkey_util.c $(OUTPUT)/uffd-stress: uffd-common.c $(OUTPUT)/uffd-unit-tests: uffd-common.c diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 6f0ab7b42738..f080e97b39be 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -89,6 +89,8 @@ extern void abort_hooks(void); int sys_pkey_alloc(unsigned long flags, unsigned long init_val); int sys_pkey_free(unsigned long pkey); +int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, + unsigned long pkey); /* For functions called from protection_keys.c only */ noinline int read_ptr(int *ptr); diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index e1aaeb65cfae..c73cee192b88 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -311,8 +311,8 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void) __write_pkey_reg(pkey_reg); /* Protect the new stack with MPK 1 */ - pkey = pkey_alloc(0, 0); - pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); + pkey = sys_pkey_alloc(0, 0); + sys_mprotect_pkey(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, @@ -484,8 +484,8 @@ static void test_pkru_sigreturn(void) __write_pkey_reg(pkey_reg); /* Protect the stack with MPK 2 */ - pkey = pkey_alloc(0, 0); - pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); + pkey = sys_pkey_alloc(0, 0); + sys_mprotect_pkey(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, diff --git a/tools/testing/selftests/mm/pkey_util.c b/tools/testing/selftests/mm/pkey_util.c new file mode 100644 index 000000000000..ca4ad0d44ab2 --- /dev/null +++ b/tools/testing/selftests/mm/pkey_util.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include + +#include "pkey-helpers.h" + +int sys_pkey_alloc(unsigned long flags, unsigned long init_val) +{ + int ret = syscall(SYS_pkey_alloc, flags, init_val); + dprintf1("%s(flags=%lx, init_val=%lx) syscall ret: %d errno: %d\n", + __func__, flags, init_val, ret, errno); + return ret; +} + +int sys_pkey_free(unsigned long pkey) +{ + int ret = syscall(SYS_pkey_free, pkey); + dprintf1("%s(pkey=%ld) syscall ret: %d\n", __func__, pkey, ret); + return ret; +} + +int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, + unsigned long pkey) +{ + int sret; + + dprintf2("%s(0x%p, %zx, prot=%lx, pkey=%lx)\n", __func__, + ptr, size, orig_prot, pkey); + + errno = 0; + sret = syscall(__NR_pkey_mprotect, ptr, size, orig_prot, pkey); + if (errno) { + dprintf2("SYS_mprotect_key sret: %d\n", sret); + dprintf2("SYS_mprotect_key prot: 0x%lx\n", orig_prot); + dprintf2("SYS_mprotect_key failed, errno: %d\n", errno); + if (DEBUG_LEVEL >= 2) + perror("SYS_mprotect_pkey"); + } + return sret; +} diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index f43cf3b75d8e..3688571e6b39 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -460,34 +460,6 @@ static pid_t fork_lazy_child(void) return forkret; } -int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, - unsigned long pkey) -{ - int sret; - - dprintf2("%s(0x%p, %zx, prot=%lx, pkey=%lx)\n", __func__, - ptr, size, orig_prot, pkey); - - errno = 0; - sret = syscall(__NR_pkey_mprotect, ptr, size, orig_prot, pkey); - if (errno) { - dprintf2("SYS_mprotect_key sret: %d\n", sret); - dprintf2("SYS_mprotect_key prot: 0x%lx\n", orig_prot); - dprintf2("SYS_mprotect_key failed, errno: %d\n", errno); - if (DEBUG_LEVEL >= 2) - perror("SYS_mprotect_pkey"); - } - return sret; -} - -int sys_pkey_alloc(unsigned long flags, unsigned long init_val) -{ - int ret = syscall(SYS_pkey_alloc, flags, init_val); - dprintf1("%s(flags=%lx, init_val=%lx) syscall ret: %d errno: %d\n", - __func__, flags, init_val, ret, errno); - return ret; -} - static int alloc_pkey(void) { int ret; @@ -534,13 +506,6 @@ static int alloc_pkey(void) return ret; } -int sys_pkey_free(unsigned long pkey) -{ - int ret = syscall(SYS_pkey_free, pkey); - dprintf1("%s(pkey=%ld) syscall ret: %d\n", __func__, pkey, ret); - return ret; -} - /* * I had a bug where pkey bits could be set by mprotect() but * not cleared. This ensures we get lots of random bit sets From patchwork Mon Dec 9 09:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899195 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 720C5E77180 for ; Mon, 9 Dec 2024 09:51:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8188D0041; Mon, 9 Dec 2024 04:51:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 961BE8D0029; Mon, 9 Dec 2024 04:51:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DE378D0041; Mon, 9 Dec 2024 04:51:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 597448D0029 for ; Mon, 9 Dec 2024 04:51:09 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1F90440B4B for ; Mon, 9 Dec 2024 09:51:09 +0000 (UTC) X-FDA: 82874951796.05.373B106 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 7FA3D1C0003 for ; Mon, 9 Dec 2024 09:50:28 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1733737858; 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=cbBxn5qOQ9J377eYviEtKB0cQDc5LmCO4foK1XGor9k=; b=zAi0xtqquR0znrSjscwKVZlB4ncBHZMz4upcD90FMqtHHYkgCw4JbaCRH+6xgKn9yfFAtP ODDhj+IWFueRKgWU+QOXwIkNViwynNFOmAuLt19rg59M0CuKMJBe1N6Dq7TpX+BTz3uvfD AjxgSPHYhMvik6Oz0t7f2GF2Hss27Zw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737858; a=rsa-sha256; cv=none; b=shVURAdiZ4FwjrZH9XU3qD8aPD/dftaypvKvYLNBSsZGyCOCcWtliTS0fhRVZV7hQHPKVQ Ac8V5dX84sTqedQfbLemJpNpEXn6FsK4qo7CJdH61aPt65A3cRRdZ1LkMSH34aCJWEBLDJ Ud9+m0ZMVpfUyEXMXoK1vcNKPW1fGYw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.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 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 EDC24113E; Mon, 9 Dec 2024 01:51:34 -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 E43033F720; Mon, 9 Dec 2024 01:51:04 -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 12/14] selftests/mm: Rename pkey register macro Date: Mon, 9 Dec 2024 09:50:17 +0000 Message-ID: <20241209095019.1732120-13-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: rspam10 X-Rspamd-Queue-Id: 7FA3D1C0003 X-Stat-Signature: 1qwfk3hsjrtqnwgaf74mw6tk1ma41grh X-Rspam-User: X-HE-Tag: 1733737828-450019 X-HE-Meta: U2FsdGVkX18lrGkRKgb27pxTOJLn8uP+ij4fwHN010DOfNv2shvPiMTECWurCh+0H7o6aGpE0YXmQSdvklwa6AVTvHmOSMV9o/5GRzbue5o2vazDueW9XwM6W5WjssxfJSIbh8rhHgRSiz35r35N8KQFeIlNjqmxRhHyrs84TvGkC0sqJDXg8WY79KfnZRNO5DgZMCI40vyuRWmXVinwn+lpXGvUpLOOdnCT2WF0CmpzEqAQyaGAv0CdNZopmZz62h6yg57Jl2KdJu0P8rMHtnCqjDtGRbSH8ykLKP/IAM51htfpGsVbKoziarFkoVlDiPfDevQ7VlRNTzNi1o2ktyws0HgRFmSBjJQ4yAloukJJ55g8kBv/1sLUuI9TW+qsXfODvgENgg6BRAMYZt1fKsk4Q2+XGu5/hzPNO8zS7f1gj0DQxIaFqIjkU3P06kWxpuPi9nBvzHMEroPh0jQTWKzOris3dRgtRqM92vfaJYAIbNdowI0rsDF9/B92LJN0cyakq9iT/dozOeFf2MMbXs3NRf4XqjXGoXBCp8tu0wlJLgYSDx7pVRkT+w6wzwvGWKFyrSf0s7JBaX6DhARdqqK5lrwG3GXGYeekcK+kh9nev6DWB7dWOhF/MY2PXgI3NfB0XSe/FFmGR6YPSQbg2XNlIngfCWqx+g8UL437Mt53WV4qF1eLFstcCQmMi3nUHhftgSCqipGQNcpER5QlV0U664rMDKjhoNNz8MDiDjU71PpZbZN1n29zlJ18vkpaiEpdmBNfyV2O+n0XZ6Y3GOMkx1don95ns/xhBFNiE2L+rj0Z81IRUvGtvaXukadqkTARiw0ISDg4rwzJLHQdZ2aabOSmIuEIRwE9Homd7vKBtEalGKJ7rkF/IRgJmYGvpYbwaxuAKRguNCFtlCTQk+jEzGEA+jvyjBM5Hvf5KZCwtQeF/c3rSRr2dZhIntIKJf5ODWmSdPoj7c0iEUE YOaN8PIo 3o/hl64vLbfWwEYotH2qJBS1kXK6MUqWMmg2uWKeONG5J0JMkFU8C5mSZXir1VyKWyAcfebGsbxMUB7q8Bf4cEb2e/o/K3brtZYMRVdZRM8QL7fSDD5CwH5krD4slTKcEOQMrr/llST5TTWXWmg6vByUv5QFSHpZIyuBl4NOgXzNtET2iAYMixQj/YRjSmxcfikgjAtyxHB5N7/OjteflPXubuZydRtxW4Dw5UaMjjr7F5WWHPr+0Rv60LA== 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: PKEY_ALLOW_ALL is meant to represent the pkey register value that allows all accesses (enables all pkeys). However its current naming suggests that the value applies to *one* key only (like PKEY_DISABLE_ACCESS for instance). Rename PKEY_ALLOW_ALL to PKEY_REG_ALLOW_ALL to avoid such misunderstanding. This is consistent with the PKEY_REG_ALLOW_NONE macro introduced by commit 6e182dc9f268 ("selftests/mm: Use generic pkey register manipulation"). Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey-arm64.h | 2 +- tools/testing/selftests/mm/protection_keys.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/pkey-arm64.h b/tools/testing/selftests/mm/pkey-arm64.h index 9897e31f16dd..8e9685e03c44 100644 --- a/tools/testing/selftests/mm/pkey-arm64.h +++ b/tools/testing/selftests/mm/pkey-arm64.h @@ -30,7 +30,7 @@ #define NR_PKEYS 8 #define NR_RESERVED_PKEYS 1 /* pkey-0 */ -#define PKEY_ALLOW_ALL 0x77777777 +#define PKEY_REG_ALLOW_ALL 0x77777777 #define PKEY_REG_ALLOW_NONE 0x0 #define PKEY_BITS_PER_PKEY 4 diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index 3688571e6b39..a4683f2476f2 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -396,7 +396,7 @@ static void signal_handler(int signum, siginfo_t *si, void *vucontext) /* restore access and let the faulting instruction continue */ pkey_access_allow(siginfo_pkey); #elif defined(__aarch64__) - aarch64_write_signal_pkey(uctxt, PKEY_ALLOW_ALL); + aarch64_write_signal_pkey(uctxt, PKEY_REG_ALLOW_ALL); #endif /* arch */ pkey_faults++; dprintf1("<<<<==================================================\n"); @@ -842,7 +842,7 @@ void expected_pkey_fault(int pkey) */ if (__read_pkey_reg() != 0) #elif defined(__aarch64__) - if (__read_pkey_reg() != PKEY_ALLOW_ALL) + if (__read_pkey_reg() != PKEY_REG_ALLOW_ALL) #else if (__read_pkey_reg() != shadow_pkey_reg) #endif /* arch */ From patchwork Mon Dec 9 09:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899196 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 02FB2E7717D for ; Mon, 9 Dec 2024 09:51:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D8BA8D0047; Mon, 9 Dec 2024 04:51:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 05FB58D0029; Mon, 9 Dec 2024 04:51:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1AA88D0047; Mon, 9 Dec 2024 04:51:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B8E8A8D0029 for ; Mon, 9 Dec 2024 04:51:11 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 79D7080272 for ; Mon, 9 Dec 2024 09:51:11 +0000 (UTC) X-FDA: 82874951124.09.0C76E11 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 9868820007 for ; Mon, 9 Dec 2024 09:51:00 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737860; 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=aTWnazt0/O9pDr4pXHBQkROoNxwn7uetSj8bv0zJ0Pc=; b=09t6agozS5aEek3Smtc876dVQWPOkCcec+SvDPTmuChhkJh6Yc4KEJLuP/y4Lw9bz8hIvP 5EdUZstHGA5Nrk92/opaMGrXlX/n0B4Xk6K+SrfveIymAyAMzAcEx19CpNOLaBf6Tv5SLX KF2915TdIdU9K0EQQB6g5c/YtQ75wQI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737860; a=rsa-sha256; cv=none; b=5s4pu08tedd7TqgTL2O5La++4Ufvy3wdWXqyu8gyWx70IX7laCkgHPuqDfVTPkdl1mDvCu N+5AYIt8OAiuUXKmFMdsO19sLV4bxnXrukIvM82+sU6Sn/1kS1lHFand2/c3tD/+7vSOG+ y2EVzUxhINW+CsS/FSk0CYE6eW4JbV8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com 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 3F262113E; Mon, 9 Dec 2024 01:51:37 -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 358DC3F720; Mon, 9 Dec 2024 01:51:07 -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 13/14] selftests/mm: Skip pkey_sighandler_tests if support is missing Date: Mon, 9 Dec 2024 09:50:18 +0000 Message-ID: <20241209095019.1732120-14-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-Stat-Signature: 756oiiq3yfbm3q1n74k68nf1gkoiw3h9 X-Rspamd-Queue-Id: 9868820007 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1733737860-386837 X-HE-Meta: U2FsdGVkX1/vQy+DiGke+Am2MV0iL3xCnLsvF4Hvptqx0UdHnbEnrvV3GlYnBax1BoR9XCln9LXO4JKmKfjCT4l3eh/M+GciH/huisk65FzS3r6MFHrg6NbMv1EiYQ7PMtIGCoyNMxpTCde/fBfp5XUo5TsvCp8KusS2fZWqEe34aaF2wRtdFKfNAsuFg6KGS9tTLZMsl8160JEYQaOXglaCkN6UKfuxAbB+Lz8lK6geLISfe2eIeBFP/bzAyin5gYmNXlDk85+8EMbn+MrbTjYVmfI/acqbN7/nkI32uIZzt1IKI56OWFFV2mhs3UXHfYJYNfhDwAZ8ZlSqqVs/APFc91r8u5qUlUvJAyUlOl+h4ArfX9xjegJcSEA/wyYNn9SpxAaKQLf/z6bzN9FlA5C+vG7pwGazUkd9jkKOvKbbMb8Oejx9JtXpsKFoHK1tg4WJAGb0pdUMCwuORtFcVZ9iIYE19cCXf1v/l4mY0ufUpBi8Kj+9dFGuys+fgLtUKnN4cFy59NzhmvrJ+KqAXv7E7vAyClTuAnlewvgJe/dFduMjK23j97tOZqfqaIaaBWbTLYj4p3K8ooAc1i09O/5L0yYJqXujvi11HZrPBrAlhOdZ1twkykNX7O2inj2j3DcNwZhlajnC8c7XJ+M80OrjrOG8Rbzr3uCQ3MbsEeiLCDJFXTx8myHj6Zg3NN44E0GXRlXlJocVeiXzU8Ye+pwFqGQbPTjHHPXg9mxxCZmEQJeg+RxVQdJdya0zYNHeViE2JrCeR9Pa0QnFsHVxjEhhvEo13Ius9x6UZejrsBTJwhx8DdRR6SzRiAocOoKMyAn5239qG+rv0+dWQPBgbrZrloJOzT3Mvkd1EHWtnXYItMK3vn3LUTbDqS0tSXzEP55XVKpv/KpWl3HlAFif+yL8xqJAFQ3HVY6nlp6m4TjYQQ4XYOAyagI5qYRNFF9wZ+LiHO8jAyk9Qb+nI/p D8o7XGzm FIbS75cWEb3zTcCaktOz6ka7UijE5H7obuOPhsrOBcyyalClHt3Uzw1NbG7eqdyt7BMZcAPl1ENAGpdjS4q20lYHAuI51LlxLGlG22cD59qiUa/ldEocto8h4wB+Vknc40mxEcU88MA3kmSYsv5vCrjpUCmsV7LR126GmtWdolF4ktWTiCS6Cf+GzWSSsk4jqNMAETZ6q8Nm1nro/fadseRkItrTB8z4Co8zebdsxfoYKs9ihDgU63dAv9wgTXCUdVEwjnm+G9k7WFJgVzz/ehkKzp4LR8JlqP1ezN5UDEY5z5kYmK4n36EjIbNqY4yeCvWAF 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: The pkey_sighandler_tests are bound to fail if either the kernel or CPU doesn't support pkeys. Skip the tests if pkeys support is missing. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey_sighandler_tests.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index c73cee192b88..449ec5acec75 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -535,6 +535,9 @@ int main(int argc, char *argv[]) ksft_print_header(); ksft_set_plan(ARRAY_SIZE(pkey_tests)); + if (!is_pkeys_supported()) + ksft_exit_skip("pkeys not supported\n"); + for (i = 0; i < ARRAY_SIZE(pkey_tests); i++) (*pkey_tests[i])(); From patchwork Mon Dec 9 09:50:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899197 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 B1D66E7717D for ; Mon, 9 Dec 2024 09:51:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FBD88D0048; Mon, 9 Dec 2024 04:51:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4818E8D0029; Mon, 9 Dec 2024 04:51:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FBDB8D0048; Mon, 9 Dec 2024 04:51:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 088978D0029 for ; Mon, 9 Dec 2024 04:51:14 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C23FB14028A for ; Mon, 9 Dec 2024 09:51:13 +0000 (UTC) X-FDA: 82874951796.10.D3E2F6A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 9455F4000E for ; Mon, 9 Dec 2024 09:50:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737862; a=rsa-sha256; cv=none; b=0axQa0uKkHBBGHgXlNqj+4t58rZ4FOdTjZJApUuVujS6JU07DvficFGVzPZlgYOgFFDBa8 nSyqZXiOdsbDWYsMXBRDzRNMewc5H3okhwyE4kMPfoVrRRkBDy/XrEtA5r28RsRQJEUTI/ J+pZ2OLhXaLlic0GHcDmb63FxXpDcRA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737862; 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=fD+1ahQubNsrFJcIZy6nYonMd+lwfObdutf43AaVl4o=; b=LAmoCEbw76bK/X4TkafSocfNxwFzBn9sARaFoVewboXIs/u2+Xf7sKBMUSBp7WDmFt8xEk fR5w9nMYRcR1WuTrs/yEgliZFNQ61okVtN55TAitvCTt4iCr1DTQ46jhOTnPFqBJCJDsxw Dj3Bf5AHAUq+5T97mWVvWCaBkCc9/hA= 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 84549113E; Mon, 9 Dec 2024 01:51:39 -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 7ADDE3F720; Mon, 9 Dec 2024 01:51:09 -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 14/14] selftests/mm: Remove X permission from sigaltstack mapping Date: Mon, 9 Dec 2024 09:50:19 +0000 Message-ID: <20241209095019.1732120-15-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9455F4000E X-Stat-Signature: ujk3td45njgbcmb8d3ys857hmfcocn6u X-HE-Tag: 1733737856-288533 X-HE-Meta: U2FsdGVkX18g+oAIxt2v4fQ1C2vPr8iIWIMchb9Idi1kNIbqVg37+BCDk+Gkd2mwchfPzgLgF4xGS1EFZZUBkVqIU2sey3/HcGyX6ZKBsc152hTRsH8I/BrwDgIrzJzfH32zR+ocEnGECxHuWIkEVTKkrA8RrV/qdpQJaNOSRtTht23Rpesk6SZT04Oae8VmTWgF1Fz39DO50mk3yJfSKMLOe5ELak+/5jxZvGeOumETbBt/asOrBtF5nVjaeaDgL1wLf4GjMbbmeQMB197nWJAP+51gRocmptvQdJ/45mhagZq4kLWquxSjwg4fEQFippWHtLQoNc7WGPmYQqDXnAHMbRc9+7dYFTiszHTrPShdUAqqWBM++SctaHvCessa7drHx8zUe0ygdLbCtgUuU5SWG2f4NpXx0lYtBV4xPP0+4uEcpQaPoIBCm2fafGoAwe4nJo2hFQq/xLkSGc8Ri/NB2qJZ/hdejvsWIXJDtsrgrUtPiHbO7z6Up8lTg2XnZcQNz6sZ2AvAk16iEJ7qWoA5BekOxhAxcTrDQQjlStiCL3Sil/JoR5S0Jy/NuNWjWR1jrD+pou7QCIBPehHV5kb28xdcMovNzphIsc5gOo5KLKn47+v7nLqN1WxB2E/gAM0Kycnr+/2MSbXJwADcWcsFymzr+lErk0SNyjBzAiVZubjz7wDX6sGNXPixYGUjUdjS3AJdpw/fy+lBhWYxEMp+0pZohTdicNtgOcTWVX5nVU/wyRKJ2d1bijHVql/HKLwZnKzUFqBYLHIQmmmCMnPafhjuewa9TnXaTFHu0whl62G2X+AmG0inLb4BN64XgqIRVjZSw0hzanYnMr8Utr7CpgG4pGgagxNi97bbNUoTKKlWn7PbzeqOPgZo4kSKP33hJ/yogAewBVGTEuZyZBLcu+4A8qC1h5W27pzTyrEEJe9Cp7jmn/0ICN3/v+JtQtnRluAjoOblz2hRQtp Me3CxefJ lZFzmsdYbd9IjqvMS84pKDyJs2ZUeSbZp6AAhlIdJzk7Z90tr1gkM0NrVPVCKbPa6CcqYX7a4JmPNmz+KWp+ACeqTcV2YAK5KIiJ+dqaPW5mE8cl/vA+WKVgEJuVpe34EMA1eON+cmmoW046gu0QG7AyKRj8jaqvrtBMhxK4ywcGZQr/JwdEvXYtaR+SSaP8rL3wIzCIPUNHjQiywoQgJi4c+ejYc5ZlIBrNTxAkOEh2agUMYl+OmVImRag== 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: There is no reason why the alternate signal stack should be mapped as RWX. Map it as RW instead. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index 449ec5acec75..17bbfcd552c6 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -315,7 +315,7 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void) sys_mprotect_pkey(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ - sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, + sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); sigstack.ss_flags = 0; sigstack.ss_size = STACK_SIZE; @@ -488,7 +488,7 @@ static void test_pkru_sigreturn(void) sys_mprotect_pkey(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ - sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, + sigstack.ss_sp = mmap(0, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); sigstack.ss_flags = 0; sigstack.ss_size = STACK_SIZE;