From patchwork Wed Nov 22 09:42:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464397 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 292BBC61D9D for ; Wed, 22 Nov 2023 09:43:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBAC46B0590; Wed, 22 Nov 2023 04:43:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6BAF6B0591; Wed, 22 Nov 2023 04:43:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A59086B0592; Wed, 22 Nov 2023 04:43:20 -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 9554E6B0590 for ; Wed, 22 Nov 2023 04:43:20 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6BA828052F for ; Wed, 22 Nov 2023 09:43:20 +0000 (UTC) X-FDA: 81485102160.23.EE82A66 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id DCC9C40016 for ; Wed, 22 Nov 2023 09:43:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VS4V1mmE; spf=pass (imf11.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 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=1700646198; 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=pNe3T1oxurIRBMv7xR3XahEt98MWmkplNge008iSYbQ=; b=mkZiVvjYUGrkYDcJ8Z1I5gvhSnaYP8bKR1TOfkXguGep84L86z0qzoFMtX/u+MRAXb9Bgv 40ohYSdR3FSKrU8h0WmGd1F+PA6vjqkxZg/Zefg/+F7VH0+jMvk6Z5fcYosudpqqDQO0wg Qjz9UISNDm4oPhCEFDbThacamgZtrGo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700646198; a=rsa-sha256; cv=none; b=GEVjK5ZAcKoqX792fx4YWIMG88fSaaGxDUXvs4EI3QV8dmwi5/Q1SezFQaPeeXm1UOWajQ UdMGj8gG5R54jOlVKNO4howlzyxIKCc5Apq/dLmJaC3Orw64d/4Me4RFpphGfbbzSHXmK6 jaMV7LL8YJt3Yighz1e++P7vtlB7mBc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VS4V1mmE; spf=pass (imf11.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 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 ams.source.kernel.org (Postfix) with ESMTP id 999C5B8117B; Wed, 22 Nov 2023 09:43:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB115C433C7; Wed, 22 Nov 2023 09:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646195; bh=EkyJ2sjNqguwXqxmxIIfJqgpolmeU80tDQ1mr2D5TfQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VS4V1mmE0ZeLoutxYILjpbDNn60e5Tw0OcoSbTasgmO/VejZ//vSk5A4xO+WKFwqr Vt+kO1vC6TXvQBTVbFHHuAp1E9yemr98c7HwHxCb8pBTuq2ba5qEzAzV28dH5jUvlU zMV7HFvQUN1V1bnbNkCq15iyICNQRqCvaWVMvZx4cPo7LnC/W6QUANmM/9t8FXhwrZ eQ+p2PRpxpv2DgKFpKGxSozrGbwpYTwkR7GsL9szoTE6zP6Poc7ZZozJj+u3Frk+Ot uAG2FJIIdF6HfISncjYll7FQ2wapnt8Bc+ndxxZBDEI5t7GlqrUHlXf3Jwmo1mtA3k w60pzdRod63Lw== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:13 +0000 Subject: [PATCH v7 03/39] mman: Add map_shadow_stack() flags MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-3-201c483bd775@kernel.org> References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-0-201c483bd775@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 , Thiago Jung Bauermann , 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=EkyJ2sjNqguwXqxmxIIfJqgpolmeU80tDQ1mr2D5TfQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXcz5ctjongA13l+3s8rDr6lCcYzCiV/EZ+w01 Sjq0p1+agmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3M+QAKCRAk1otyXVSH 0BmeB/0fdILWv3xnmoh3iIUnb+EGSP88bn3NvTdnqSR6EOCHL4XrJPUgwQteJL4EkrLBwM7IXDO phEWSI0/nmWusNr3v9UW6kZ1NmYF+253MWc4v54TjgzG9k4mafDzYYfcZzuGeMZK6JCCAWkGLr0 wv9DrCEa/2jyyNb5n2y+K8nYdNHuJuRrS+1Upl0ZSZ1w9M1JxGUsJgLvnPmoIDgcox7Wg6uxeHf BzbRTK0693utYKeBvr3gTPU/c80PO0X47jTSfpB+WRA2FLQW9FCrDBwc3Z6WFvN2+z7guWL/86q nFREV+64zb5OuzopYwcn7fjb3cADnfSnvSBqlAmHmHfk5T6+ X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: DCC9C40016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: kx4hrps958uikty3odyuiakjhbhh5ejw X-HE-Tag: 1700646197-729808 X-HE-Meta: U2FsdGVkX1+VuFer3jaYHBqepNuFhoTa1fQhed6WkxCA6qZ4uCZg3BMN/z2yPdr5PIETI/drFLhDwRm+rUHXdPd2budnRaSmsMZL68KeaWH3aIYP3GH72XS0qfwAL3epmumSj4vpLo6lhuBsXTxshm9fvy+AhO2wAd60ii1b4G79ZwltPeeQTnwrkwA/Uz5WoD+zJaMrUCs5hcADQk07ZhEoQnu1H3wuRMainkJIAZI/A3XRVMy+SBgiML7dbt4/p5eO+qF6ukQt/00dINJMf80xv/SuioNL1d7ttWhXIIBdf9LtlMhR7kexqKGZilt3WODGuSgX+J5V8nlo7u5kKXS7wT/+siaqHnzalLr4SLIRHBOsi2QB97PsSTqOX1KY5lPq8DesCstU0l692r6AEqQMFmJ9NHo6lK83Uw5sEyM3ITBH0iSZunyTSb6Lm7+4fRaaBVU7YDRBKkwJgpj/NTIfMhZe+vxAqqxXQ8Lj4P0vFQhIYNVZj5vtFMda1B5yZVUq8DIqBKFOninwKTdyGHur7ah8vSjzWgT1rP0tHoGHTMtn263e6D4YkU876mkOOtDpJTE54JSoqXmkvogx7nY1TDQrNDkJMKAzPOhJ54XTroZx0WFiSQ42Hd06y1diRyXWnHrIPweZDBI+6VgZEuZKwaQSNReVgQv/NaETB0+MtrpQ+qI9OfAM7OikuTFXBuUkkdXMNAPFJW/jtUkMSc2RkIeKif//oou/4KWSeyhj+i9Bqc5O3lLIurGhvEiP9V7JrK6WNaELxqu1Zvw8mQnyMr9noZNbDYy6BUR/Elyp+Npup23eMPMqalwotXiTOmLNFnTrL4cH9m6cIqxTVv7tL7wM0I+OPGp1+aBCFWn9Byw2Zqy+wQSTSdbHGp2O7WT6XEYx+6Zh68TyqglMG6LMY0/QMeDajam/AqYfV9nR5rDwcbQeoy/cH61HQm3NLnkRN3oDEJkHD3XHNrB TiGk9AqF z8hyJNhcZn+FJ9ZH88IxcA5gcwf76TTOPgMMsiwB+z99+mRNa5LVUVGLtTjNlSSH/OFvCfrtl8RbakSrlyTm4Y6lYbw0ToZA2e0QrjpOmmC+wfI1Cx23k7gf9H4Z02ilRNwMrenWxm/nIHaA4uF65AdTGZK+0Vmv2RcPNtoebOefuW8yJY+LTw7CQewodx4L2nQoiZVVFHD4mPJHKlBKt8HFl+BGr1jLsTXXwBxu25/hu7mpJXm5rdWTNI3xIfKr0/FaEbWlo2et+gX1UxZFuLrxgIxPlGc7IGBrATEEITFF6wNyWeeYSYQL/4Byx6UM+BDzZc8loLioGl3WnEiKPCmp6ZYIs8fZ39RynnT1gF9fOOuo= 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. 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 */