From patchwork Mon Dec 9 09:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13899159 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 CF73EE77173 for ; Mon, 9 Dec 2024 09:47:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58F8F6B03F2; Mon, 9 Dec 2024 04:47:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53D5A6B03F3; Mon, 9 Dec 2024 04:47:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 454D86B03F4; Mon, 9 Dec 2024 04:47:44 -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 28C4A6B03F2 for ; Mon, 9 Dec 2024 04:47:44 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C618F120366 for ; Mon, 9 Dec 2024 09:47:43 +0000 (UTC) X-FDA: 82874942766.27.08368E9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 8DB3616000E for ; Mon, 9 Dec 2024 09:47:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737643; a=rsa-sha256; cv=none; b=ipppzBEZxbwj51CMAfE0FAf4OI+Mg5OwtIV8IGQSE7SewEZ1BpO9ldhjwtVPRg4YhymALA qEi+AwEmS+hV/VVXnClsY2IMfiie60wW5lkVfsiRWVMQvzp1AILGDSwzzSTLPc1owoBNfo 1vo8265JUARkv7tNZTiYwvL0sqVuEZQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737643; 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=ni769i74TSTMc2HCIR8rv+ryIDdcPChPeu1Bt8O/pdw=; b=NZXpbK2gH7Zha5UMAWFEjv1uNvjftgbWr1rp63k0NwNFVXNQK04sJ5B27u9ihLA4wtTGbU IbJHq+f7tCAb0R436oOOcmZXMJNo4TrGj+rsuOXLBiErwhdfA2j4RhGT2w+rIe7Jwv2JjC lIPzAChFtjb1Qz0RscBpq3iEe81BhF0= 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 25E9A143D; Mon, 9 Dec 2024 01:48:09 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.35.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5B7D3F720; Mon, 9 Dec 2024 01:47:38 -0800 (PST) From: Yury Khrustalev To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Kevin Brodsky , Joey Gouly , Dave Hansen , Sandipan Das , Michael Ellerman , Catalin Marinas , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, nd@arm.com, Yury Khrustalev Subject: [RESEND v4 1/3] mm/pkey: Add PKEY_UNRESTRICTED macro Date: Mon, 9 Dec 2024 09:47:17 +0000 Message-Id: <20241209094719.2431126-2-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241209094719.2431126-1-yury.khrustalev@arm.com> References: <20241209094719.2431126-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8DB3616000E X-Stat-Signature: 6mgcjftgb4ceipd17hpii3xdgo1wo5wk X-Rspam-User: X-HE-Tag: 1733737648-824339 X-HE-Meta: U2FsdGVkX18V6osnP4pKs2wxponkc2YBg2TnwSL1yVsS4gl/PRTDjgyNkRoJ95Rp/k33fDsYLrLSTHYUEsln0/OCPN1EhJZJxj9Uy+DYvPxynGw2v3GtY6DiAcu1JSNp/jspoOGG7vZBswVQPtP/6LVZk7wttMCyEIlGijjKRofelxhQzCJgEK9JMJdm2uSS4oOHTuvwfmIy7JUwnrk1U+dI/dY9PfTzRBNOjFs3hPelFnASBIz5WXRoWmc4yHsDo8KEIpWT9P/+bf+n9IJwoU0UoPI5EdtupRCAr9GfMcHGoCqwvJy6qwSREc8t1mPhHe/sAwo+16mJjkZacuEHPEZ8q1PcBQbw3lh9rUIn2WSnmsjcrxGD9OowF5Pzm4IBviNlCNjdcRI70CVgEIC/OCpmOtGOek38xjDXw2mA5O5H4bPFqJq9/xN4nDMD1Th1STBv+qj6mq/MJJdvj4H6fq4JXx5X5KOmpWB3l7T6s9RJFb6RnRF9vgYmIC5+MYD8Onzygto1D7MLxz5NU1yJq7UlbXMKzKa8q9Rp1njeTvnN0lZB9vHea8KrTmtJFH3YAevTXNbqdln78Ty1Wfbu0cs5akpOR7gXoMlEMD7qoMLiu6RkLnrAejWLIbZuOEra4iUKhGcdLfsG4d8u46VCxOEkrggTJXlrx7tKXGmFMoev1YeniPWW0c6w9Tk2UCdbBpxORp3OOlg7xx9D7hUKdeCg8Lof7GHrdQ+W0I9SqgTTCz8Erx5Dhm+xOJq8SDicK3EnZxuWI683xkSX6ApB8TNGg++AOk2NRRtUdtugtrca6bmecBAZP7iTwamGtIM00NFVywgdehXiIyGWEDNkK6VR+XtJNAAsf/NqlEgyTIbQaGUFYx90z/EdVJwy2RpiVXRbaRodk2jTpcWpE9JKkb8XOlwgLHfQSPOT5GRQQ6U/VmLpozQ7XyS8HtSOVPxxCGlHbri4A069slKmy7h YJ391veR WAYD6hhr7ptqWuKntffcVu1e1lOc7mkPVjrTnlj+rK6eYEX0L+oH1mecmVVb9WL0HbrI2IVJSnzhhS3a6nRqWe/8rE7NgRy+Csd15GNlGRI1ueZn6UYjkhWWfgFkJhwEexUyDQKuLHwLKQkXP6AFmlafjGNs6U+nH6dbonRH2JWV/WeiDiizqfe+I8KWOGbJlaKmIoPlIDiF4nxNDVzVohpYPO4EKo9ty1w5c4B1kQ0GUfhQoH4IRco1B67DwV6kj4POQopsQYrehqozJsn/qRY2y97IU1xv/DyTs8fQ9NYLxYMkAWBlwDw/j2cUXggfy1h7vutA4aj1B+EtKFYS0mdi0xGkhls7BtCNb 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: Memory protection keys (pkeys) uapi has two macros for pkeys restrictions: - PKEY_DISABLE_ACCESS 0x1 - PKEY_DISABLE_WRITE 0x2 with implicit literal value of 0x0 that means "unrestricted". Code that works with pkeys has to use this literal value when implying that a pkey imposes no restrictions. This may reduce readability because 0 can be written in various ways (e.g. 0x0 or 0) and also because 0 in the context of pkeys can be mistaken for "no permissions" (akin PROT_NONE) while it actually means "no restrictions". This is important because pkeys are oftentimes used near mprotect() that uses PROT_ macros. This patch adds PKEY_UNRESTRICTED macro defined as 0x0. Signed-off-by: Yury Khrustalev Acked-by: Dave Hansen --- include/uapi/asm-generic/mman-common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 1ea2c4c33b86..ef1c27fa3c57 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -85,6 +85,7 @@ /* compatibility flags */ #define MAP_FILE 0 +#define PKEY_UNRESTRICTED 0x0 #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ From patchwork Mon Dec 9 09:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13899160 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 36BC0E77173 for ; Mon, 9 Dec 2024 09:47:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A47446B03AF; Mon, 9 Dec 2024 04:47:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 983096B03F5; Mon, 9 Dec 2024 04:47:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B16D6B039D; Mon, 9 Dec 2024 04:47:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5DAD36B03F4 for ; Mon, 9 Dec 2024 04:47:53 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E32821203E7 for ; Mon, 9 Dec 2024 09:47:52 +0000 (UTC) X-FDA: 82874943186.06.7F39C0A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 3A99F100011 for ; Mon, 9 Dec 2024 09:47:12 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737652; a=rsa-sha256; cv=none; b=JPueD06q6Kvy6AYX/fSVrc/1K0LoEvuvgeAe17n5rDtVNSQsBqLCbEokdgPN8IT7/UCZ9n 5HjezPiv/Xd2Jjt7WDSPWNc2Cm31hFt2fCC+10X4F6SdptmXujRiFHKeFBerXJPQGbL/+h MnJU2liEa6BPqWz+tkT4juxFnWqb5XY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@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=1733737652; 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=+b1vwyUt9X+x+fq4vNsQWkXSJqfTlOBMiVr4yBA8vrE=; b=zBdZ7TW7rOvOUgy0muonD9HuL0A+UgDrhVNrwc8JUHmV9GELwhad6CqFZkMrsw2TZLQ1BM s1Phgo0Ebo6Z9HAJQw1TBrWQzXud1J4l5S0qY0rr111wjpk/2nIS7hwVcN8t80QYUY11qW tPrYDirV8s8kA3LDBI9+oZSNLH5TDvk= 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 9EF0A1650; Mon, 9 Dec 2024 01:48:18 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.35.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7538B3F720; Mon, 9 Dec 2024 01:47:48 -0800 (PST) From: Yury Khrustalev To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Kevin Brodsky , Joey Gouly , Dave Hansen , Sandipan Das , Michael Ellerman , Catalin Marinas , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, nd@arm.com, Yury Khrustalev Subject: [RESEND v4 2/3] selftests/mm: Use PKEY_UNRESTRICTED macro Date: Mon, 9 Dec 2024 09:47:18 +0000 Message-Id: <20241209094719.2431126-3-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241209094719.2431126-1-yury.khrustalev@arm.com> References: <20241209094719.2431126-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3A99F100011 X-Stat-Signature: xatwhkddzpsimxehuqafkak5oymmg67z X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733737632-476603 X-HE-Meta: U2FsdGVkX19DK99jo7xm9euNk+mzZo4kuDDnimHszJcf+Hc82D9pVRF40RC0VnoLX8ip1aLQq//OgrcE+m/CJRCsGddLo2uZdr8Y/CEdVO5ekjgoX5v/hZfo+eVs6cRKljssN0d6sdfDNn5vPtSu6SbsxpjIbmd9TBKM7guvmyeBQNC24zWova95E7xldpOXybxrXm3JD/SkJgTHDX8nnickOktGwZtE8dGZX25J5rMu/QU1Omg0dgqucNqJSujJmDks/vZAW4nI34d2Tu1YsfnwrVnhKaLcemDFomAQJzQuzOtpLHQosnmGQ/dEncr5StJSjWFMqp+TNKxD+ySwwIvBrcPNDIpXAkbf3wp/WfiuGe6dIcnr3f40yg6DGLVcYl3JfNyPrzaeSSlFkkxl8fHhdI9LFrFOl3VqXBb6xQjJqS7VYgNkX/Iqn4KRguEK7Rf8MfreQE5DcHpTAcHqrCYOMrroaqDnf87YokpPA9LowfrSvgybhijtVBt691zcJdvIoZ9CjjbpSNnehNdg+5S8Kb8x9nK6d8LTogHmGfaJgLlI1SsPN0l97WSs7vRvCZFDCGEbJGnY1aMIvldFPD7jFw9YiSM8TKppZQFDNZ1f1wF8T6p3CKnt/kiZ8HtuerI1FG7PcyoRjF7x+UcY9picu9eox/tE6I2DR7o9WXlGpnNtt4BvqbKd05iRIumW26yrU+EaldHutwGvrM09tJWnIE6T+OiUa1UTz8aJtn89pvyXhSfF1prQ5DZBNvKRhVfiDTxPzRkEk0FeK7EAtiynz6TIvv60FEVMTB8+AYZzIfEcbf5SDj2eveaVBvcVGB44JAluSGsITxbYfO9ldIBnTj48bReqTqJXPqK4rFaGFjitllWDfOtK8mBn8+HkXFjVN8PBaMogreeAikvIS/eJSX8ZjzD6BWoFYvZ4p4C3pnH+pEMqTUYOCQlfZ/4OQPwVujzB/JxUwo72fAI S8iHZWEU WfuBcyrVsnlWRQ+tFDGMhqmjlTKdf4SVQ1rd/W51/pjPy8llOldrSQeALG22MOqKeLJx0Gr7ajpbHxUWngU+lq6JI7OCR9V07J8kCVFHWf2nq20zkRPCfAEKiJG111F4JZ9zBalOJ6QKg/QIdMFeSnoqTdLbY9wx4r2iEy2TDnLjSkaiuuBy7Jfs0mSPn2muhEA7Ndq8P1PR/RIQleK3S0yQxPYT2Nzp1nlpt0gXGkgMItoDy47abfpF/1x1eLqUOKeQSnYCVlu4J9dtAY+al5i7pSrdkvu5GQd0/c+/D0wzRyToaIU5cPaBeteDrDUYDXJ56WSR1KdWcrhp3K086HOtOaBJEhJFA+H4p 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: Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions are used in mm selftests for memory protection keys. Signed-off-by: Yury Khrustalev Suggested-by: Joey Gouly Acked-by: Dave Hansen --- tools/testing/selftests/mm/mseal_test.c | 6 +++--- tools/testing/selftests/mm/pkey-helpers.h | 3 ++- tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++-- tools/testing/selftests/mm/protection_keys.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index 01675c412b2a..30ea37e8ecf8 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -218,7 +218,7 @@ bool seal_support(void) bool pkey_supported(void) { #if defined(__i386__) || defined(__x86_64__) /* arch */ - int pkey = sys_pkey_alloc(0, 0); + int pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); if (pkey > 0) return true; @@ -1671,7 +1671,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) setup_single_address_rw(size, &ptr); FAIL_TEST_IF_FALSE(ptr != (void *)-1); - pkey = sys_pkey_alloc(0, 0); + pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_TEST_IF_FALSE(pkey > 0); ret = sys_mprotect_pkey((void *)ptr, size, PROT_READ | PROT_WRITE, pkey); @@ -1683,7 +1683,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) } /* sealing doesn't take effect if PKRU allow write. */ - set_pkey(pkey, 0); + set_pkey(pkey, PKEY_UNRESTRICTED); ret = sys_madvise(ptr, size, MADV_DONTNEED); FAIL_TEST_IF_FALSE(!ret); diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index f7cfe163b0ff..10fa3ca9b05b 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "../kselftest.h" @@ -224,7 +225,7 @@ static inline u32 *siginfo_get_pkey_ptr(siginfo_t *si) static inline int kernel_has_pkeys(void) { /* try allocating a key and see if it succeeds */ - int ret = sys_pkey_alloc(0, 0); + int ret = sys_pkey_alloc(0, PKEY_UNRESTRICTED); if (ret <= 0) { return 0; } diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index c593a426341c..2015ed7e0928 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -314,7 +314,7 @@ 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 = pkey_alloc(0, PKEY_UNRESTRICTED); pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ @@ -487,7 +487,7 @@ static void test_pkru_sigreturn(void) __write_pkey_reg(pkey_reg); /* Protect the stack with MPK 2 */ - pkey = pkey_alloc(0, 0); + pkey = pkey_alloc(0, PKEY_UNRESTRICTED); pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index 4990f7ab4cb7..cca7435a7bc5 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -491,7 +491,7 @@ int sys_pkey_alloc(unsigned long flags, unsigned long init_val) int alloc_pkey(void) { int ret; - unsigned long init_val = 0x0; + unsigned long init_val = PKEY_UNRESTRICTED; dprintf1("%s()::%d, pkey_reg: 0x%016llx shadow: %016llx\n", __func__, __LINE__, __read_pkey_reg(), shadow_pkey_reg); From patchwork Mon Dec 9 09:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13899161 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 56220E77173 for ; Mon, 9 Dec 2024 09:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E18B36B03F5; Mon, 9 Dec 2024 04:48:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC8AC8D0029; Mon, 9 Dec 2024 04:48:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDFBD6B03F8; Mon, 9 Dec 2024 04:48:02 -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 B060C6B03F5 for ; Mon, 9 Dec 2024 04:48:02 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 66023AD6B9 for ; Mon, 9 Dec 2024 09:48:02 +0000 (UTC) X-FDA: 82874943606.25.C3C54A6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 2E40D180007 for ; Mon, 9 Dec 2024 09:47:58 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737661; a=rsa-sha256; cv=none; b=SdudSeyDMB/5fiRf9mp7zcsDPkuOpDp8j+rKctIH8keNH+UvA7/XuAG5trfLfCp6aEQfOG /qQx5DJ/2H/z4PUeHOBGQfOr1UmjyrC3IqqIcSWI7ZKCaslrujQpr+cjiZILAYmpQGxokN kE9yfeMMMvq2AOCyk7jiRtmDPGpYQcQ= 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 yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737661; 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=NoSyfg0H2xdXV8bVJGF6NwXUo5Fiq0F8nFCklb+ts3Y=; b=WcETE6SmMxxclGES8u1YfN+zaLeVWY4k7I8IG4Y8pLBsEQtNOcIxZpK4WyXMpmcS8cu+yz aneEwDu/sLs6r6pMOFBrETde3sUcmFQmTCyzbJbYos3c54hMuviUCZWQlU9eyEEqREjpo/ YMHsnostheSW2Pdifmiv/3T77jU/VZY= 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 1C580175D; Mon, 9 Dec 2024 01:48:28 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.35.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E97E13F720; Mon, 9 Dec 2024 01:47:57 -0800 (PST) From: Yury Khrustalev To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Kevin Brodsky , Joey Gouly , Dave Hansen , Sandipan Das , Michael Ellerman , Catalin Marinas , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, nd@arm.com, Yury Khrustalev Subject: [RESEND v4 3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro Date: Mon, 9 Dec 2024 09:47:19 +0000 Message-Id: <20241209094719.2431126-4-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241209094719.2431126-1-yury.khrustalev@arm.com> References: <20241209094719.2431126-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2E40D180007 X-Stat-Signature: 1wxobstdknygbwrsuym3zcmes3pusa3j X-Rspam-User: X-HE-Tag: 1733737678-755592 X-HE-Meta: U2FsdGVkX18lDby0MeGpjnVfginFEVWKbTZ38WmGwImijmm/tJ6cXyzOAKkC+tSJ7vheotggj3HIqh8UNUk3xUnhkpHuTxKcknQhOhULKyd7YvGveH7B8usF0UzbJfINwb2yDtxY9G/aXON8JLojmRURTGfzD2/cGVr1Aha1xWFXbbpS/D2F0VUV+sAIArbO5YVLmxgrTHTOE/IdwkTgUIhutSslcm7n99+fMJwgvHqbcnqUgumvrlHcOFFRZMzUlVgkbJ1tSpfGoxBS2E9PsjHLEQY2QWLa8EbjNrMd/E6oAiJebDkhFopBS0QvlRcwIkZtSPedcAGzbuktBhsvKL5lYxSvzzG+K0Z859FYZ7mh5w5rpSp80cUKjV9Haj8GK0+G9pqyPo/M3kl754x4ksOBKAqwaFiJycDF+ZQcih0T0ntdfIw3KH95FxHfKaxgvp8oCL9aZAW1ANKyBDyonTPdQb09vELZ8waykj5MP8qyOpgNoeDjlqndMwqH3pzlj4NhcjtKXzzpQdmiaTHQEf+SJhR+7yaT1L9WzH4QdYFHm9V1Atuf3/pWP5nChpF8wVAKxBzksQckcovG17JYLfHNCxrLu5MSFZY+0Jq4sYyPRfvdLgTRqO7csWu3ej2+NP03A1uzg6HJHYHHjYmcFe3zPNUU5S4SgNefUgtjpTWe//cX1dn2XvQnWwE7SxvCFqXQjhCzuxpxINU0ySqJ6YsEUAqnAv3gP4NYTXVqrf1tI19plFgKx1tBZk/SDO5iqeznYY5U77P3a7Mgu0xBk+QGg00v0lyEMKr3Ri9vB39FN1kBnEHMjnfMWEQrDZhPZoWi8e2LWJAOuY4peQB+LFqqZdpKChhoWi756hXUbpWjA+pcdFp6DtebqB67XdAbcvl5U2mPSaWaSDRk9qs/vLrLDiX1jcxnr9mztGae2gGXWRAkyiQJkNq+GFybeev7TRJgzs9h/Uqmi0aBCD2 0hcFh96O jbKNeU6BcVfuRE0E8vpYe8UgPiH6DatHHYIodq00g80Iz9f5rDibe3A+O9QvBt8uABcG6mSrb8SmAR/kr4GcvMEukjV8hnc67zx9Ws0eeCTpDRdUKIqJQynrmbks/04q3xV7ZdyCmW1oakVPt4X3teNg4h2ukBy+yjSkJnDHWxJIK+xPqIdoDdZWdPlT8R2Q9hZOc1F4t+isRRHM9G1BUD0Xop+tKYiyAbhPoZndhKE9d/JwX33kEtwc5qYWNZKnk5I7PpNHeTYglJ/I8wyH5TvGvndJW6oGNb0Kfc5MpxLFUJJxFMFvuyUJDi5dHaNy8yI7kE8VeT7tZJDI= 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: Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions are used in mm selftests for memory protection keys for ppc target. Signed-off-by: Yury Khrustalev Suggested-by: Kevin Brodsky Reviewed-by: Kevin Brodsky --- Note that I couldn't build these tests so I would appreciate if someone could check this patch. Thank you! --- tools/testing/selftests/powerpc/include/pkeys.h | 2 +- tools/testing/selftests/powerpc/mm/pkey_exec_prot.c | 2 +- tools/testing/selftests/powerpc/mm/pkey_siginfo.c | 2 +- tools/testing/selftests/powerpc/ptrace/core-pkey.c | 6 +++--- tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/pkeys.h b/tools/testing/selftests/powerpc/include/pkeys.h index 51729d9a7111..430cb4bd7472 100644 --- a/tools/testing/selftests/powerpc/include/pkeys.h +++ b/tools/testing/selftests/powerpc/include/pkeys.h @@ -85,7 +85,7 @@ int pkeys_unsupported(void) SKIP_IF(!hash_mmu); /* Check if the system call is supported */ - pkey = sys_pkey_alloc(0, 0); + pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); SKIP_IF(pkey < 0); sys_pkey_free(pkey); diff --git a/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c b/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c index 0af4f02669a1..29b91b7456eb 100644 --- a/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c +++ b/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c @@ -72,7 +72,7 @@ static void segv_handler(int signum, siginfo_t *sinfo, void *ctx) switch (fault_type) { case PKEY_DISABLE_ACCESS: - pkey_set_rights(fault_pkey, 0); + pkey_set_rights(fault_pkey, PKEY_UNRESTRICTED); break; case PKEY_DISABLE_EXECUTE: /* diff --git a/tools/testing/selftests/powerpc/mm/pkey_siginfo.c b/tools/testing/selftests/powerpc/mm/pkey_siginfo.c index 2db76e56d4cb..e89a164c686b 100644 --- a/tools/testing/selftests/powerpc/mm/pkey_siginfo.c +++ b/tools/testing/selftests/powerpc/mm/pkey_siginfo.c @@ -83,7 +83,7 @@ static void segv_handler(int signum, siginfo_t *sinfo, void *ctx) mprotect(pgstart, pgsize, PROT_EXEC)) _exit(1); else - pkey_set_rights(pkey, 0); + pkey_set_rights(pkey, PKEY_UNRESTRICTED); fault_count++; } diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c b/tools/testing/selftests/powerpc/ptrace/core-pkey.c index f6da4cb30cd6..64c985445cb7 100644 --- a/tools/testing/selftests/powerpc/ptrace/core-pkey.c +++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c @@ -124,16 +124,16 @@ static int child(struct shared_info *info) /* Get some pkeys so that we can change their bits in the AMR. */ pkey1 = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE); if (pkey1 < 0) { - pkey1 = sys_pkey_alloc(0, 0); + pkey1 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey1 < 0); disable_execute = false; } - pkey2 = sys_pkey_alloc(0, 0); + pkey2 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey2 < 0); - pkey3 = sys_pkey_alloc(0, 0); + pkey3 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey3 < 0); info->amr |= 3ul << pkeyshift(pkey1) | 2ul << pkeyshift(pkey2); diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c index d89474377f11..37794f82ed66 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c @@ -81,16 +81,16 @@ static int child(struct shared_info *info) /* Get some pkeys so that we can change their bits in the AMR. */ pkey1 = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE); if (pkey1 < 0) { - pkey1 = sys_pkey_alloc(0, 0); + pkey1 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey1 < 0, &info->child_sync); disable_execute = false; } - pkey2 = sys_pkey_alloc(0, 0); + pkey2 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey2 < 0, &info->child_sync); - pkey3 = sys_pkey_alloc(0, 0); + pkey3 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey3 < 0, &info->child_sync); info->amr1 |= 3ul << pkeyshift(pkey1);