From patchwork Mon Oct 9 12:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13413513 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 B309CE95A8E for ; Mon, 9 Oct 2023 12:12:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5134E6B010F; Mon, 9 Oct 2023 08:12:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C3E56B0110; Mon, 9 Oct 2023 08:12:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B29A6B0111; Mon, 9 Oct 2023 08:12:06 -0400 (EDT) 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 2BF8C6B010F for ; Mon, 9 Oct 2023 08:12:06 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EB144B48CC for ; Mon, 9 Oct 2023 12:12:05 +0000 (UTC) X-FDA: 81325809810.12.F81558A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id 7B5D640005 for ; Mon, 9 Oct 2023 12:12:03 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ENONym6L; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696853524; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p+wqVi0mTjianUtT6+zisfY7F5xVo8/h+3xtMlXnM7o=; b=eG8G+pEDNKTk8UgA6GuByeEUXIH9V+KbPmpu6ecOX8zcHWrG5Lz9eEOTMem0OGwBL0tmPM r/TpCQW/mU5Y22XtLCWAFg/X19chLmHgbKghic+v0zosNvX9OqKGhJgCkZg7bac9r07h1K CXpaQ2Qjhyt6qy69tAEpI01sG4fod8o= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ENONym6L; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696853524; a=rsa-sha256; cv=none; b=nXpxmS5PydULngRf+v6odM0nZMb3H7qyVhdVW734H3zlKwLHgJuzKDkciZCNqgB9/tYjgU cQayyzfhdHfmdPuJY/ap9CpR3buVNV7wsAnullBBNKpdiLQOzeR6ylon6aWkfs6Nx7cRKE V7/i7oP1R/CNLW1Fz7gw0LC7yPo33SI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 64BADCE138F; Mon, 9 Oct 2023 12:12:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0416C433AD; Mon, 9 Oct 2023 12:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696853519; bh=zDATCw7GkV4as2xIWJbM5lO/ptaSO6aC4Ay36HJrvVc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ENONym6LxarYigzay1mcU79+hI/vAoV9b0fyw/J2UUuwzThWjoEsUpd5lkbA5Z4K9 P0/CV25CwF+cAdlJvnqs4FLOJ71AZpQHGjzgeYsO08ImaCjN2qlN1BUP8PHqIGKOXQ WpPk61fewqYUGFsssDoC9aSSwPZyJhjkUCFZlDhQ8yPqKCJZLKOpL6emCCp5a+Nt0F UiBPnweFH4fMygG0qDGzAA40oBFFjm3hJQIPQuWZaVzH01aIpiymcfVqNdS7u0T4Vv UG1ntzuihR5n3QwqjmpsnuK/iB+fLmz4UFUxHP9y0RRrp66Z2ME/lzF5xhqIOyc6/T Qq+H9HwSESlGQ== From: Mark Brown Date: Mon, 09 Oct 2023 13:08:46 +0100 Subject: [PATCH v6 12/38] mm: Define VM_SHADOW_STACK for arm64 when we support GCS MIME-Version: 1.0 Message-Id: <20231009-arm64-gcs-v6-12-78e55deaa4dd@kernel.org> References: <20231009-arm64-gcs-v6-0-78e55deaa4dd@kernel.org> In-Reply-To: <20231009-arm64-gcs-v6-0-78e55deaa4dd@kernel.org> To: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Brown X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2033; i=broonie@kernel.org; h=from:subject:message-id; bh=zDATCw7GkV4as2xIWJbM5lO/ptaSO6aC4Ay36HJrvVc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlI+2ay7Z6vBAn0o2n8KbXYYUHM/hfs9dGuBEwzhip d4LBRGmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZSPtmgAKCRAk1otyXVSH0EiSB/ 9SbJ/RyLl4aYRdiZA9qvebhW2OnXSpQIYBFctQA1wlLoaPha9i/Ik0Vcc88mJxHtw1nMccHURGYhSU WCzpcB67v4hwl5zXoXemcvWBisselh+LDaTccm9Q3IeHsVH9qWHfOrV7GNYlzp2ZOhI1oOhalEzIxm FQ38pEJXorEZIfUyQJmBFQ7eBGdhU3kGlrCmBmdSrsXwJmRVdUFxY1e8w6BWvLbvQ3SZip6TI34YQA 743qUcrWXijdl+JN19YmwtPdHkYckOX7l6DVS9xao5FEkQAk1Ig2lKNDNuMLRbaDa3OP1kFcEAd+/7 Cm1jQ37tmyw8VT8okrsaLiHFvroO5P X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 7B5D640005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gzrzzsgkirqtypiiff6inmsbs9mupdh4 X-HE-Tag: 1696853523-460582 X-HE-Meta: U2FsdGVkX1/UPWPrJ0XEVkcThazoAzthR0rXw/FPlCfURIxPIJ/pVRkEOUeI/iKtea3mqbo0KZPZrjDAbA0i0yO/A1M93gLID/z7mvNNlYtgpcbhifwbVkUa8elHyPlqnEauOAESFD7dZrTDmTlucsRpFebz+NUsJX6g1GcRcQaMciZHGi16n8a+DY1H/jsew5tLrqc7v2qu2y96Rg+RjVw46dMSdqXCUj83nSMRg27Q98xKVOGnyUOXGqB1DbpziG8cTYAK8O+MgZ22Egiy2GMjmvjJb25shNdOvzgpUAkeyFaI2dpA7YCAXYk7fQbBNhjnYgo8+4ko0kcQQjLSoSLVS5GWipmZnvtmWv3nzabiK+AsYyQKwnl9AvG7aS0X3tWnHvRs9U4hWF216NG2+k+MgYogb4fLwWNnwQvKc83x1Nj8qoTD2PZiAh2A4sacutE3+SN8pibYLmnU97gqaWep/sZ9r/WWz3MI97hZl0Kv1lkuC4wxyfGoodBnh5vSozC7ZohovqGHv3qO0KC6ykDQbRiK/MPWIRRCs5aMkVl0BKuOqH5VhO5OezxesHyq8eebwn/r40tN+5qbzxi7hWlYRj2bzAYwEcH10VG6+aVfwv6hEWNm4vx+YSjxt2IPQI/HuPENhirgm5CHi5XBZaxoMLgtdAXWrj5hx+LlGmajx3c4OlKhXGph6j+5Rx/1GJvYqQaCkA0j+xrxivs5VNfisHm/68BvWWxyK4iomnfcemZej0n7O0qTZ9tQhqj2ugmSYCAgYMfIWCLmb0WDVkNsmpGDF5+0ZRUSGb+VGNjaZ0w6CS8vXym700z8TsjLVEbBtTbbMnvPb/lG8RjnngpG4aatKtRGKJhxcLqqFe2a0j+k67AFtxYvDJqO4gcoG5tPptI9WRYC68IxBR3wqMbCngx5/28hWaUdx34QBoqniOqkR9Nhhyi3bYV802t30i1m1NxfGZX5e9na4x+ Pq9O7jjb evBquN4lxJ6BMjehsaJpmx3iI98/VPlxhT4kDU0yhoLWXo7ZxM+FK5NeD8qyQFP+HfbuFQFyvIc5szlOYikwrDGpaC5NT6qcW1PkO0uhrhTBEYuzTF4OU+vi9cT3ka8sTIW4YWFdJaDW09jtdqpJVwUjWjw2cLTIcxBLZ5jtskVML4J7WUCS5NL+849p8AYZLfra/EmqFOIXB21PuU1PQHICEoD1tlxP1qXEr9J6OOm8IVIa0ospa6c2xDM5Wncv9lbXYmbYMLtVzdfDrLcwAmQHggrzp0hvQggFkgp5/63z88DsVbTI1wRxc8N79fvxVykQrmK8Zta/1Ca6hRK3erLNJEZppVC0BeSup7U0swVUukZMP/Jf0HkkK/Q== 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: Use VM_HIGH_ARCH_5 for guarded control stack pages. Signed-off-by: Mark Brown --- Documentation/filesystems/proc.rst | 2 +- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 2b59cff8be17..9f61f34afc4c 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -570,7 +570,7 @@ encoded manner. The codes are the following: mt arm64 MTE allocation tags are enabled um userfaultfd missing tracking uw userfaultfd wr-protect tracking - ss shadow stack page + ss shadow/guarded control stack page == ======================================= Note that there is no guarantee that every flag and associated mnemonic will diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 3dd5be96691b..c0fb4e8b3bbc 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -699,6 +699,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ #ifdef CONFIG_X86_USER_SHADOW_STACK [ilog2(VM_SHADOW_STACK)] = "ss", +#endif +#ifdef CONFIG_ARM64_GCS + [ilog2(VM_SHADOW_STACK)] = "ss", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 1f0d93151a36..9649a1942dda 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -352,7 +352,17 @@ extern unsigned int kobjsize(const void *objp); * for more details on the guard size. */ # define VM_SHADOW_STACK VM_HIGH_ARCH_5 -#else +#endif + +#if defined(CONFIG_ARM64_GCS) +/* + * arm64's Guarded Control Stack implements similar functionality and + * has similar constraints to shadow stacks. + */ +# define VM_SHADOW_STACK VM_HIGH_ARCH_5 +#endif + +#ifndef VM_SHADOW_STACK # define VM_SHADOW_STACK VM_NONE #endif