From patchwork Mon Oct 9 12:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13413504 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 3697EE95A99 for ; Mon, 9 Oct 2023 12:11:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C18F68D005E; Mon, 9 Oct 2023 08:11:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC7C98D0031; Mon, 9 Oct 2023 08:11:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8FA58D005E; Mon, 9 Oct 2023 08:11:02 -0400 (EDT) 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 948748D0031 for ; Mon, 9 Oct 2023 08:11:02 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6DFAE80207 for ; Mon, 9 Oct 2023 12:11:02 +0000 (UTC) X-FDA: 81325807164.11.EF5BF9D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 91A2C80002 for ; Mon, 9 Oct 2023 12:11:00 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qVvakmNa; spf=pass (imf30.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696853460; a=rsa-sha256; cv=none; b=ngKSGpZzRbAcoiehxkA3Tcwlem4egdizfXjMlv7s+RSB6BMyo/RDIgQr1h8g7Y7wRhGcYb uPVqf5vMDdEXYgPt0uayIR/o51RTiuNePljJzPbgTTP54VPUZ+H/tZpX3yfPxjwESHGkKe EhAIf/YwB4lTzvCr1GAizkkWObORfBg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qVvakmNa; spf=pass (imf30.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696853460; 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=Eftc92tzGiQj0aHfUxVATekDiO3a5YAUrxQjTHWGjqk=; b=XZ5qojFJiaSR12fct0PU+wOqdfxVn6l0AJsovPTn5qPfxZY6xcfyuaf2CTu3wSLlImCTgH KgvkOmJVBHyY9KXTJXdLLqpsOMl6DWUISlNkx7GSkXh7wL+v2GmBOXMZzbVk0W+Qzo4UNU 4lLtwnKeq8xbYPrikVMlgxc4kd9mzb4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9DC636111C; Mon, 9 Oct 2023 12:10:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D73C433C8; Mon, 9 Oct 2023 12:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696853459; bh=uElqfQr2KtEKDlB4Anquq4cFfJfq+1aLsyIKGyzwTJE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qVvakmNaQygpJZ0uePjFrJUrtsbzrcfhstnJItES/IVtru3NeGfEp0fGQksQC1DWF tMpQwgQ65nxCY58ThrzthwgXTnIc8aWuBUqCFMiTj0PRBWwCAGGebOZnZveIv2rrvk XPwA2URNcWdhmQLqdteoSpVuvpN42XibMqMLvqmmFtwmicQMYk1NMZEzhlLUUCF/md r+nKxA2Vy/p0f6j0IZcPikta50sb12/VXajcIhynQjhQk6kZDtPyif4nUIRajawG7M QL7Hqud+AA0HT9n5SyxHxQ2wtlbkMENYDlSQpMemYVKshIbyzuaW4W4Hi7tYQlYr6w 5ZdC0OBCkOkoA== From: Mark Brown Date: Mon, 09 Oct 2023 13:08:37 +0100 Subject: [PATCH v6 03/38] mman: Add map_shadow_stack() flags MIME-Version: 1.0 Message-Id: <20231009-arm64-gcs-v6-3-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=1759; i=broonie@kernel.org; h=from:subject:message-id; bh=uElqfQr2KtEKDlB4Anquq4cFfJfq+1aLsyIKGyzwTJE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlI+2TBBNpiyjJLhMTZGrEExOLe9h6uwqTYHZeEaaK XP1+sAuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZSPtkwAKCRAk1otyXVSH0FWxB/ 9zuNP79aRqxAABj4AUSSe96yq38SrHY4j/bVNYrQh9rMPH1RVp0FPIw73yWeMrrO1QkGkFkDYCWOWG mVVT2KLXAeczKvsbiTQwi0+0jWSMTCgW2WiBenv4gjUaI1cZhDOFaFmpbXydGDST/L0tgS3VsKCbRp I3YW//w083fjMYclQWfH7/EPPDxR9SFHIS+mSQJ4xOKlcy/AZVYzDGweA1kVTrbqbY4SMQ166v51Kw K76x1ZQScvlzZggJ+gfra/Pz+awJQu7tTrsrRuUlgkOTvGektRvIgbswUBnuAHryYS5CYGduRUrwHP pAXIQM7vP8oHPKeWRA/VojXac+pwhj X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 91A2C80002 X-Stat-Signature: ikhcikrcibr7narczmucp8h6ixe5p7kz X-Rspam-User: X-HE-Tag: 1696853460-12339 X-HE-Meta: U2FsdGVkX1/C+xVp+Tp/p3Ly2sFFo1jR0GzoQjrHfqg8HqWD/pge9JhrO5M7FsGJTHng3LPEDsEFS+L+szkurb2I1InrcjZPHoWBcPI39yPCyShyeqQ6tr0EfJc5HAENIkNHe8xIjNLXvOg45A/kB2a7XO5YyjNawdg/liLhmDKE4HDNSD/WHpIfMRVdAgHwir1epnQf6TZsCyr3gLE5H/1VuhgVsVlOftCmkEoEi6gXcxFb2AFprldj/n/V9l2Pzz750ygIaCMUi/lY2vzA1CTg2umuDfO5O90RjvhbcNwNlTlsPKBf7bYFBpu/xVunGri8512njQlmXKe9ynzDfapjo1bHbjE7hBJLllxtNLVgDEoKxWblp47dRo9CmGkgOYIcDHaWPFe0YXt/CNB+22Urw2Y/0ALNlmUxyJWT8UeUz1icxc9bm9QjkID9ZnGb6OmVyUXU2uPO6plPlQxiUeXxCmsEFjInZPnMY3YqeWo/FzXcmv170qhPDOC8CQulY5NhfJs7mTWvaYwj2Vp7pIZr2g9LdskyjqbFMYjTfZ5GSLSUzM+nbeuCqIunoVXOGzz6MlvUIxxFo/ciuP5LxMLxKeG6Ru7MjMxWTPaYIiKo7zu2Y7jdT0wEW3DA0fn43SvS6+nLGZlVemVnCAyJHXM7o4Z3qIYDpFOlsPYI6pChzMyhFmGL122E2NBc19i9RaRuKS4IAQt22iTtU5fxynMNzhFWnLwzslgFegxxSScFMmXcRi45okERblqVhXVulKa5sNMrW/R0jLXpzhcOGrfR2hnPusD9FT87LdIW8hGKNO4QyN1/GYq11Bt1FUDxBWdxhVYv6ZCSBOI89wyx0XyrKUuw9AEFdVFyap3VWCR8lzbYwzAgU2UEny9Wkke4SXXtToppIZIcvlzzBxGx9YKgGci7TlNKpp3WFOBZSJJYtVEjxMx4d5r4/740xpbeuNDGxbk3CY7PA9bn9CZ 7aFjU5aH qLwMwB0ic/hq4AVeh4fR4PByK5vqVGipwfsqIP65DeVAXLaAIN54VA5enOAe75RqDKqu8fVKV0Jxb/Z7gQnB59F+6n2dVHsJ3OAgWMH05zPkQns5Nw+3/ksLS/wtE+IPyuvIQf8VD0Bj7bO6WXwsYzG2/TI6XUICQJCUE/oHeVOdY2gKRD6qQ2dHrGYr0ULGlbM4ozNqWc9ewOmk3E96z3G7KiMfkTPG+oZ8SGkT+aMcgMbg9rcBDCkCLoBsgNV8/Hz6LhANlinAQWT0hPowKKIr99LReeRukXz96juhAWUN8KEF+x4nbgVPsENqBcxidmQxE8aqwz0mFDnRuQ+8MmO7OjqKpIbTI0GKZEzc9YLcJw+5p7bBkPVIAi7eGWME2nK6W 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: In preparation for adding arm64 GCS support make the map_shadow_stack() SHADOW_STACK_SET_TOKEN flag generic and add _SET_MARKER. The existing flag indicats that a token usable for stack switch should be added to the top of the newly mapped GCS region while the new flag indicates that a top of stack marker suitable for use by unwinders should be added above that. For arm64 the top of stack marker is all bits 0. Signed-off-by: Mark Brown --- arch/x86/include/uapi/asm/mman.h | 3 --- include/uapi/asm-generic/mman.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h index 46cdc941f958..ac1e6277212b 100644 --- a/arch/x86/include/uapi/asm/mman.h +++ b/arch/x86/include/uapi/asm/mman.h @@ -5,9 +5,6 @@ #define MAP_32BIT 0x40 /* only give out 32bit addresses */ #define MAP_ABOVE4G 0x80 /* only map above 4GB */ -/* Flags for map_shadow_stack(2) */ -#define SHADOW_STACK_SET_TOKEN (1ULL << 0) /* Set up a restore token in the shadow stack */ - #include #endif /* _ASM_X86_MMAN_H */ diff --git a/include/uapi/asm-generic/mman.h b/include/uapi/asm-generic/mman.h index 57e8195d0b53..d6a282687af5 100644 --- a/include/uapi/asm-generic/mman.h +++ b/include/uapi/asm-generic/mman.h @@ -19,4 +19,8 @@ #define MCL_FUTURE 2 /* lock all future mappings */ #define MCL_ONFAULT 4 /* lock all pages that are faulted in */ +#define SHADOW_STACK_SET_TOKEN (1ULL << 0) /* Set up a restore token in the shadow stack */ +#define SHADOW_STACK_SET_MARKER (1ULL << 1) /* Set up a top of stack merker in the shadow stack */ + + #endif /* __ASM_GENERIC_MMAN_H */