From patchwork Mon Dec 9 09:50:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899183 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 0FA94E77173 for ; Mon, 9 Dec 2024 09:50:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 827BF8D002F; Mon, 9 Dec 2024 04:50:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B0BF8D0029; Mon, 9 Dec 2024 04:50:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6519E8D002F; Mon, 9 Dec 2024 04:50:42 -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 45E3B8D0029 for ; Mon, 9 Dec 2024 04:50:42 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 00DDF8027F for ; Mon, 9 Dec 2024 09:50:41 +0000 (UTC) X-FDA: 82874950452.30.EF77F81 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 0EBA02000F for ; Mon, 9 Dec 2024 09:50:30 +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=1733737819; 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:references; bh=NKrCjYYWE/lsChaQNLrFncA/X5ni23Gn191uerwli9M=; b=yxR2/cDFWkNFzrI8ExQ02BcHlaXaCAX3aOjsu0EYoH0tX2AtNnEQuVPQw+EhFPMyLJ2/Lw CHDT7UAkI2UQei63cS0D2lHJep64VjTGy9LtsWYHeRh5KZCB/zK3tIepMvWmi+YVuFZqP5 teyu1Dp/nTN8wUoLORV3cUxwHsOZpEU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737819; a=rsa-sha256; cv=none; b=lsVdaYqSZPUqB4bS/mYgNeNhIKQwtIc437N3hhqbE2fEPBVKhoIFCY0QWNlSceCwlu9Pvj uYKJ144aLQU8KcJI3naCD+R0Mf2DoZNys/1TQ6KPahglVscR7rwLO/IYv4ioRMsZay9qrU T1NSvXApnBA7vLGxnv9a29UYaNzQXN4= 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 69759113E; Mon, 9 Dec 2024 01:51:07 -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 5EAAF3F720; Mon, 9 Dec 2024 01:50:37 -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 00/14] pkeys kselftests improvements Date: Mon, 9 Dec 2024 09:50:05 +0000 Message-ID: <20241209095019.1732120-1-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: 0EBA02000F X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: ogj7fmo493oing6zana8e7t7sjxdzd3e X-HE-Tag: 1733737830-514333 X-HE-Meta: U2FsdGVkX18QdLK6cQthgePe5vExqzLOKEI1RtDzOflOmvkIrXUQNsbwP7uMqUdAmhkijAxXoBh+ZU+GRgZakmgmLXFYylB9Ego83vt3HGxMeRBGE5wDCZeT6aKJhIK+yQcpIhZXpA9LepdkSj5jdRlq/o7dq6UIIvB5LekpXk8VqEKx/q7/tUSlBXygLNJjVVMOLfCbLxaCivMEMSQFxLzRLmD0EHiOEFeZ7h2rPokdntmUd8tNqfpuX+F/eV8BrW9/3iHVBrDp2Deod5lF0Na3NzmH8+haAfcK1zj+jFX3Eb6Hx2nthaa1Ui/IrKl8htG9osaieZm6fGVrD3bdauM/KA/6OyFroz7NlCXZv8itIZU1rFfpvWZ2ddnjAtBm0mgWhozQH3C8lLV0G65pTd9QWxLe5iyCZR/A5b9HHGTrOI/e5p9jHr2HIXksjwQnf7ds9WTovnBVsoriLEDe7Qi88nX2uJv5aveGRMB+IfQWjcNLMgyi7ZzWArAXkha006U5HeOa12LFLzNW5CF0pm7Aj+5VyCIGag+lo6YQvLoxGW9cZcCssyoXVYQ2wyQI7ejbX+nlaXmZH8CZCkuHwt6k7pmU4YdHlOjn6NLb9WXPxnhSVNdDj8tdQ0OzMr0evmaquPa2uSmWne/loV8uG1faScoUWz/JYj80TyTURfeVX5qcqKHFrKin35VEu1iGhOhQawOkd2pJZCO3JhrU5Ig2EucxnA5Nysjt7oWcYGXkG3UO7stUu3UkWwQjGabigFJwcrdcpXrOqWxRqyuq0AhkRftz9DhpgYkB6ZQGiDMDL5X8i54cZNNsH5ks/tUMBCs4ffNrjzBHrrqfRkOwEp95OPGa9Zp5wICav5tC3bHepXuhRxHfPKG+SG5ewSKEEBrKdafIFDRiFJCNIQ/XsqJm+nG0+1CCVwai7wxrHH5H/soas4GvLC07II3q8MN/efROSzTaCs1fRYOkHim cNqsc2vm gY3LN1x+enHx4H5ArIfgBROTGiTYIr4LStP1Urzhhk1IJlTcvZVcpKviLMmLpFhOE3w9f7IcWcS/AAhLISM9RK4iuYS8xPIQfvdNZd5CttATBxE4QFqXLMLMoJIV6aWX4M7vy2lAkHkitkKaVzTTwK/gCDv49txgyjwaQ87kPTXi6VfayNxQs0NdXB1eleWgRZ29jGEBijUQCHpA7R3eCwpB7aFxdCpW53RbnSv4SVzDG9xAurtqHDlSScrSwSAvohYo2RZt42U2XJBbTCfFe2Lgn8rcFfzab8Xs6SMV1pufwnTpefi4u2RKy+znPB2dkc42s8c3soty3Z0B2mao1Ofe6bv7PfrrhWgHMdMzAOb7wj4SkWoS4L5w2THKQIF+N1FQi/0VRyttIyja6jal4DgPRniwhPykgCO2JBv05JcMz05QPYfD7o/Sm8A== 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: This series brings various cleanups and fixes for the mm (mostly pkeys) kselftests. The original goal was to make the pkeys tests work out of the box and without build warning - it turned out to be more involved than expected. The most important change is enabling -O2 when building all mm kselftests (patch 5). This is actually needed for the pkeys tests to run successfully (see gcc command line at the top of protection_keys.c and pkey_sighandler_tests.c), and seems to have no negative impact on the other tests. It certainly can't hurt performance! The following patches address a few obvious issues in the pkeys tests (unused code, bad scope for functions/variables, etc.) and finally make a couple of small improvements. There is one ugliness that this series does not fix: some functions in pkey-.h call functions that are actually defined in protection_keys.c. For instance, expect_fault_on_read_execonly_key() in pkey-x86.h calls expected_pkey_fault(). This means that other test programs that use pkey-helpers.h (namely pkey_sighandler_tests) would fail to link if they called such functions defined in pkey-.h. Fixing this would require a more comprehensive reorganisation of the pkey-* headers, which doesn't seem worth it (patch 9 adds a comment to pkey-helpers.h to clarify the situation). Some more details on the patches: - Patch 1 is an unrelated fix that was revealed by inspecting a warning. It seems fairly harmless though, so I thought I'd just post it as part of this series. - Patch 2-5 fix various warnings that come up by building the mm tests at -O2 and finally enable -O2. - Patch 6-12 are various cleanups for the pkeys tests. Patch 11 in particular enables is_pkeys_supported() to be called from outside protection_keys.c (patch 13 relies on this). - Patch 13-14 are small improvements to pkey_sighandler_tests.c. Many thanks to Ryan Roberts for checking that the mm tests still run fine on arm64 with those patches applied. I've also checked that the pkeys tests run fine on arm64 and x86. - Kevin --- Cc: akpm@linux-foundation.org Cc: aruna.ramakrishna@oracle.com Cc: catalin.marinas@arm.com Cc: dave.hansen@linux.intel.com Cc: joey.gouly@arm.com Cc: keith.lucas@oracle.com Cc: ryan.roberts@arm.com Cc: shuah@kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kselftest@vger.kernel.org Cc: x86@kernel.org --- Kevin Brodsky (14): selftests/mm: Fix condition in uffd_move_test_common() selftests/mm: Fix -Wmaybe-uninitialized warnings selftests/mm: Fix strncpy() length selftests/mm: Fix -Warray-bounds warnings in pkey_sighandler_tests selftests/mm: Build with -O2 selftests/mm: Remove unused pkey helpers selftests/mm: Define types using typedef in pkey-helpers.h selftests/mm: Ensure pkey-*.h define inline functions only selftests/mm: Remove empty pkey helper definition selftests/mm: Ensure non-global pkey symbols are marked static selftests/mm: Use sys_pkey helpers consistently selftests/mm: Rename pkey register macro selftests/mm: Skip pkey_sighandler_tests if support is missing selftests/mm: Remove X permission from sigaltstack mapping tools/testing/selftests/mm/Makefile | 6 +- tools/testing/selftests/mm/ksm_tests.c | 2 +- tools/testing/selftests/mm/mremap_test.c | 2 +- tools/testing/selftests/mm/pkey-arm64.h | 6 +- tools/testing/selftests/mm/pkey-helpers.h | 61 ++--- tools/testing/selftests/mm/pkey-powerpc.h | 4 +- tools/testing/selftests/mm/pkey-x86.h | 6 +- .../selftests/mm/pkey_sighandler_tests.c | 32 +-- tools/testing/selftests/mm/pkey_util.c | 40 ++++ tools/testing/selftests/mm/protection_keys.c | 212 +++++++----------- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/uffd-unit-tests.c | 4 +- .../testing/selftests/mm/write_to_hugetlbfs.c | 2 +- 13 files changed, 163 insertions(+), 216 deletions(-) create mode 100644 tools/testing/selftests/mm/pkey_util.c