From patchwork Thu Aug 1 12:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13750382 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 8A17AC3DA4A for ; Thu, 1 Aug 2024 12:57:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 066C96B0082; Thu, 1 Aug 2024 08:57:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0175C6B009C; Thu, 1 Aug 2024 08:57:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6F206B009D; Thu, 1 Aug 2024 08:57:44 -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 CA0D16B009B for ; Thu, 1 Aug 2024 08:57:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5C77B160D4D for ; Thu, 1 Aug 2024 12:57:43 +0000 (UTC) X-FDA: 82403678406.11.0BC6942 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 7B8F8160012 for ; Thu, 1 Aug 2024 12:57:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k9EWh0gX; spf=pass (imf08.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=1722517005; 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=70cjjLOtabb/rzl2w02OHZeRiB/3csN9WFGlBeL2SM8=; b=lvV5lrUkxQr5NDsXlYEEif+h0CKqzOGOhy1qtgmZAuKH+sG0vbz8DcVs+rgRWsPp6UWsLM wcQ8XCiihxZpMfm6hztSJVZvY7KHOIERy+RZ7QmMF1F9Lzp82ZHc3Vp0h/E8xRL4XI/IeL 6TjDnx+OPV7oUzL+NBYa7fhOX7yNErI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722517005; a=rsa-sha256; cv=none; b=RM5ITnVQXkROPg72rFxkakSZuYZw5+dvLaoxORAQm27cQhgSchXU2vgPgbKLLRm0bbUXk5 27V/E3CCluqAbzdwvxXMzRbby8LTtdna/P6Cx9pqit7gdJQV6Ztc10gUGF/xDX3ile+AW7 ZeVZ8h71piV46eHnsxdvWLhGGUxv1QI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k9EWh0gX; spf=pass (imf08.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AB80E62767; Thu, 1 Aug 2024 12:57:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EC12C32786; Thu, 1 Aug 2024 12:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722517060; bh=2jWl08+8re+Jbyu9WlYwMAOos2oJrw5SQjRGnUXuA4U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k9EWh0gXg6rjx7kV1lB1Gmt38FbXgl6/I7ewuvHjZKZKsi0Ra/eNEDb4+nkaWeebY 5fo+KHzl2gVZT5y4QEi94AFCr3yy8q0Y3qfsKo4MUU8ZvEpLuaXTE+gJP1/QJAFy6b ZFESzXLHeTvuf0gbP+smJF5PdWb79uTbdLNbHoM7qIVEW52ay89XQq3Sh1JchzEOGn vJeZOlSSSY5GbPB2qtoVLFB9VX16JELscHgpRYVwyYdxXfoIRQv+2ArLna84PZ0pA/ DxpPvqcJ3zRpN1CX47iKOu5nvE+8eTswjAlK6Uc34hqiDr+Esbw3xgOrUR21qH2t9A 3O+OwqSvPl7qg== From: Mark Brown Date: Thu, 01 Aug 2024 13:06:30 +0100 Subject: [PATCH v10 03/40] mman: Add map_shadow_stack() flags MIME-Version: 1.0 Message-Id: <20240801-arm64-gcs-v10-3-699e2bd2190b@kernel.org> References: <20240801-arm64-gcs-v10-0-699e2bd2190b@kernel.org> In-Reply-To: <20240801-arm64-gcs-v10-0-699e2bd2190b@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 , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , 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.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1825; i=broonie@kernel.org; h=from:subject:message-id; bh=2jWl08+8re+Jbyu9WlYwMAOos2oJrw5SQjRGnUXuA4U=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmq4YID0+m+ZzdQpJGH0gtPDP+bAsXULUCyyq8/y2t MduEdEmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZquGCAAKCRAk1otyXVSH0Ot1B/ 4jaebyV1tIrvOIYxQh5wDbypCmbpdfYnw84eR5kyJZqQIRjZ+dK0lQJngqeHe4n89q7hMI4OUDMfSr Otel0Z609ebmO09EfOX6sKZzZ2/uru4+YnSoeGjvRZZsYsr1B+7FWG3o5mVY91e4Sdd+6ukU+qHmzS axuQgqxevf/x3L67X0UZGMdmC5B8jQ2x6Gu99RAzuYELIUE2nPQ1wCneKnvlyC+FPrLbjWdkIDKVN8 wmGHe42BNZh62DU3scRZYxWf6RdwGbFcR9PlKRfpI7Ocuez5/KqBYFTD1YXpI3HGD35BhAYcpFTswG yKHazykP6dg1NzH0pTMC7LYphwlbfE X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 7B8F8160012 X-Stat-Signature: 59a6g3s1j86forenk1fbt68t66ax7dh5 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722517061-309785 X-HE-Meta: U2FsdGVkX1//D/T2NDQqaojthssB8hK5n3c81SnEKArwh2RpYiJtF0PBHnuIIpZH90CroVPJZqTY1DWnT9p/YKO9wApI+vFwNiol5shYpWFlyg36k+oPhTi3xKJLoURY3jtKmZX8IBEc9Qd2y93bhDAKkd5UdobyQsj9Da3+YCmH72j+dFm0zV9nLJXMy5Qa/G6lf2ThIAF4scGMiPehCq365iP9zz0I5u55Er969mhdVnyHyjHpSAS63VBQzrdlOBNrIe96PF+mTezdZcDfSxudKUztGM2gVQu2gBfbc7ATOEt/YKTHOI3+g1XHc+RAHol9bK/FiGXif7OceplcjywbarNjqqRCjSFB5hS6w8cEqVqkH4qN+dTJI/VmTeu6763/u3BdwFI8S9P1vcGmSL1ewaQoeQGvNc7+gsoTv/AzjV1fWCt/PD0hReCylKIgwW/AY/S7KmPfMT/gzQZjeWOaPQn/X1Yd5tMOCdFARqFmttLgsNhmtHKf8xo933aX1BGfyOAlC51ZHE0lCtW40jOefCqBcJUMum2ewteZeu8yH3QvRYMOIn/Pa6HunpRY+gEhqfpDytbm1zG68ia13qXz3//4hvp4CTSvANh77QYTnllYler7ubR5xAqvB1xcT5O7QeKC7/EcbSdA7qLSBjp3DioilvX7VOEHkEedX8jUVSqY6A9caMdfWTISza4LlbcLs+XDMrCu2Py8C2O97ym0eLhFvYplZO7ESa2F2FiUp8swMqhglt6h0/Nx6q+UWLWUlyuFhRcoFhhL3TZjfCZlxW4gFBAxwMcHwYzc4oPNOu2bRgvL5q+IMoTldyncFRHEM5qvag6ake3Psvx/yInmYPQw5kSB5c9kTpovSUsxxrjPWmvByx5z48QDlTHTSqlJOvx4hbFiyELQP6m2ld7zprS0bpNflj4A385h/oHw3Wj1NELKfUpIiywxZ/pjFlReY9QRN4vmIkvbKUQ 85ua9AVZ b56ewxhm52xu584E+yxso40njRH9puhBojZcqsNL3cEJJVxqLZYDHkMSKWdAtrH8+dqwmZa/niWeTwLP1tTkstS82Xq+zxvP6kv+glMjEKN9c3qoKx1fWG+Cb7vxu0Wv6xthMyRnFAEUilsqMrPEQ8FahXZHpHK0TKeFM08lcu1EMUgVWfAA5oFu2ZJuY3bvqpbLXDmICWxdx+A56p226XNhlxwc0X7ikepxXLL/qY3tdJgcohhA04ZWOMVS2qRRQQhrl/gIBf62CVVMFHhhV0PQuYOfXcKA5wBBUlabKfyWcL3mZXhttrCXwpWq0iliiXMvUqpSjdYt0wKlY3jpXaNJf2aqvpzuvgPksLRjlhRV/OSz3r5Cw9OpecpwDXlnEiTnedTUizwe3q1u2kB3sClWCTtfmW4YPJJkj0QRaVaCsxM8= 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: 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. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown Reviewed-by: Catalin Marinas --- 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 */