From patchwork Mon Aug 7 22:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13345132 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 E2237C001DE for ; Mon, 7 Aug 2023 22:02:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 830E96B0075; Mon, 7 Aug 2023 18:02:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B9E38D0003; Mon, 7 Aug 2023 18:02:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60CC08D0001; Mon, 7 Aug 2023 18:02:37 -0400 (EDT) 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 4C2E66B0075 for ; Mon, 7 Aug 2023 18:02:37 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 10B2780BDF for ; Mon, 7 Aug 2023 22:02:37 +0000 (UTC) X-FDA: 81098683554.27.9E3A955 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id D2E2718001E for ; Mon, 7 Aug 2023 22:02:34 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="db1Dx/sx"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 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=1691445755; 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=NBG0tU7kX2ozstMwYzf3BLRb/FaAIwac2wIDi+654YY=; b=ponf2cQHIGIBG1PspepwllqzhAGXKCK3br4aJ5BjKw2JjT/Ecx9v6w+W5aiASsWN6RGCSN +++ZJxlUcWZEh/grIsWehgh/ozlibQiGzd6D5ASxAclwoFeSxETkGvr6yeX9TTYmS2jor2 MJ06q614sBX++/eefj8Oo1j0qjZ8OHg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="db1Dx/sx"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691445755; a=rsa-sha256; cv=none; b=GlmuUnqyRrMtLADJZ05lXgfwU7wbXfduZO9o04blyeYn3kaShM/MRGZzgTeMD8ztndXIKr 92z+wEq1W6RFrGQcO86W5DpXGOPAKH++nHUx/rl4OlfAhDdFZaxxYDKtmA05n3EJNv/PZa NkNRR/eJZRM4l0ZqzaFB1oox7SLBAes= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D898D6229C; Mon, 7 Aug 2023 22:02:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C5C7C433C9; Mon, 7 Aug 2023 22:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691445753; bh=38AeaFL37vV9MyUQ5JVKuM1gVCMvtkdVnDbNL3TTQpU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=db1Dx/sxvi2GeSAf3rMhKXkcdbmJDIbfGUllMMOe7trw5TGd+vI308J3L4cvkXQIy A5eOMbMBeV+Iy6DXGLgZPV2F+yerFVZYxAxPyGfOBYF1anXcMVZRwrdJqAwLAvpbXc YDsN6zKyGjydncigvfYWIOjoqQ1hCoR5Gi43v8eOSsHPg/aqEgfOPiOgs1WJaLMRb1 9BvC/IsPYBbZuRF2oYfHysw7ZJkNDBsrQP5yK/Cs4ueUWvjxWcwBpuCkbMS40bOKci sHSrh8RghAfAnm3dUDKaiUdqcray+L0SvleZYqxC83BUSBcJhJ+dAsfdeeIjAER83K gdG039mOCCB/A== From: Mark Brown Date: Mon, 07 Aug 2023 23:00:15 +0100 Subject: [PATCH v4 10/36] mm: Define VM_SHADOW_STACK for arm64 when we support GCS MIME-Version: 1.0 Message-Id: <20230807-arm64-gcs-v4-10-68cfa37f9069@kernel.org> References: <20230807-arm64-gcs-v4-0-68cfa37f9069@kernel.org> In-Reply-To: <20230807-arm64-gcs-v4-0-68cfa37f9069@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 , 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-034f2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2027; i=broonie@kernel.org; h=from:subject:message-id; bh=38AeaFL37vV9MyUQ5JVKuM1gVCMvtkdVnDbNL3TTQpU=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBk0WmfHaDrJuk1F8BZkrWtkiZfyI8pNxlLvkhZH0Bl wPbm6M2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZNFpnwAKCRAk1otyXVSH0KzOB/ 9Z7ayW1CxNIiEst1DkkfZk1750XtkJW5QHNR8NSJRtowY7IRMCt/HPlKhkUlwoJoOyEqw3wHyEl4sr rhjQWNFCJHDmgCM0xKPUfgrUIUYMqtv7thpDIo4VkVaOE0EIgiVWFpTTaGMzDv1QKouCPw9QV+Jj1G stKQEubuFBvpvQLYb7DKL8KHCeQ8GSLbYJMvJeQOa5n2uFdCYPkRws2FWxsnioGmwjj5GsvOrbzWgK og0YmpMW5ApYcyyP3Sab9jWA8qRAKY+6tJJDIVQvnDM2u+9cXapRklfDOYo49HIPvX2JDVyL/RM7SS hQ/pTlu9f3Mx39vSgZh/yIdSidNcTp X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D2E2718001E X-Stat-Signature: ny5hs8oxamzcn9wp4qo3ogj9oq3omrmy X-HE-Tag: 1691445754-396629 X-HE-Meta: U2FsdGVkX1+wnkJlQJQ9gHxQeo0CFB5yBbKI+bS8Fw5iY1IxoqC2Ok58XW/WXBewFeLcYHu4w8+1kIV7SJyORn4xkKINQREnxMgMf6VSc7gqO8Rl4Vmsmow2isdPA5dGFZUpqIg7s0kCJjr06t1naeiP2zD6XCOWJmAa3ZcQx9kEVOcPtx6r0xo0XMHOcFW+BswMO6A+iNxs7ZCmf1ot4aIRtx/x2BX79UzeUi1dOuZUDhHi9xKItlwPLCHnd0sD891SqdcNao4dRVs6vu9JL+qIXkzIT9W7DdxyFOWLokclAdfGXMBVgwuOHdSZ8ozxclaMdN8rlmvVsKLrDuTJi5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Nfc1WzZNt6U2f9HTLtrSz2KeVE7CmtY7dR8zw5gYwp2lA== 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 6ccb57089a06..086a0408a4d7 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -566,7 +566,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 cfab855fe7e9..e8c50848bb16 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -711,6 +711,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 43fe625b85aa..3f939ae212e5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -372,7 +372,17 @@ extern unsigned int kobjsize(const void *objp); * having a PAGE_SIZE guard gap. */ # 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