From patchwork Sat Feb 3 12:25:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13544061 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 8B6B7C4828F for ; Sat, 3 Feb 2024 12:27:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E46BC6B0075; Sat, 3 Feb 2024 07:27:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD00A6B0078; Sat, 3 Feb 2024 07:27:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C98C36B007D; Sat, 3 Feb 2024 07:27:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B298D6B0075 for ; Sat, 3 Feb 2024 07:27:52 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 447431A060C for ; Sat, 3 Feb 2024 12:27:52 +0000 (UTC) X-FDA: 81750419184.29.5B04BC5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 7BACD180003 for ; Sat, 3 Feb 2024 12:27:50 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=s313Wgbk; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1706963270; 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=hdXOarCqFqVX/k43QEhQzwOpxc68LgeY9Gs+nb1gPQbItG0W5jaAapxqBy/6pHkU2PV2zK +a4zqzSacWzR3kleGb+GKoIVznG9v7YWcrjw96KYOhchtCYLj+VgFIZXcbWYK02mUCuFbV SQSR0VtYR18b21kv6ARf9tgi7gris0w= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=s313Wgbk; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1706963270; a=rsa-sha256; cv=none; b=kTdzutGlPZtZb4hIwpjgxYSG+VOP0tfcGeBAgqe5kUVnDP0xi9MjoUjb6jOLIKVnzLVP9h dWg5YGJ0Kfl8A1cwxXMjacopU3Dt35/vOML3emYAXdM0GLbMOZSNHpzMzuu16unpHEpgmc KYg+RAfp+kECrSeCXniN/DZh0ojG1uY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A28A860A13; Sat, 3 Feb 2024 12:27:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76937C433F1; Sat, 3 Feb 2024 12:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706963269; bh=uElqfQr2KtEKDlB4Anquq4cFfJfq+1aLsyIKGyzwTJE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=s313WgbkOz6vbnCBve0R1yHwDF1pK5mK+UYPA+OD99GziD3jcKqQKnySBTBGi4duj vqr/SmLkHLF4Lk3ruhNzm4cJmmH3yq67ODVpGPJa204lWf5JGzspt5wcs+jVeTqQ3S xhGc67JCzmdfCFdtsQj0eD1MNq802vjS85i8oJ77UsbyUsgJU3LC/razYzQhP82fOZ yUEt8OsHLWgjE5yCQS9U678Dqz4m0U/3+3XD3cpVQmlStDup2yznD4F1i3uy552aa2 ph8TrgcsHHnR/DdeZgxHiKuE4/CWD9hXMRVY4GM5fwosCA8s0HuS3SOZeZGavv+/d9 AJIcyVewnHvvA== From: Mark Brown Date: Sat, 03 Feb 2024 12:25:29 +0000 Subject: [PATCH v8 03/38] mman: Add map_shadow_stack() flags MIME-Version: 1.0 Message-Id: <20240203-arm64-gcs-v8-3-c9fec77673ef@kernel.org> References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> In-Reply-To: <20240203-arm64-gcs-v8-0-c9fec77673ef@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-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=1759; i=broonie@kernel.org; h=from:subject:message-id; bh=uElqfQr2KtEKDlB4Anquq4cFfJfq+1aLsyIKGyzwTJE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlvjDTUIBdLAQcWP64eMtOa1tBhyxd3vT1/dabcKsI J03ruPGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZb4w0wAKCRAk1otyXVSH0H1sB/ 48Yjm/fTfaRFnrNWPL9rLUxz1LhV7ouhYI4uPWpceW/ximquDLxZHEc/zFA3kWQprsk3kgF3Ek+H4h sJ6pKh0M9pJjZAaoKYLHUs725T3HFZXBH+EY+nMbrwxH0LDhcfEZLPfhdYFuRJJf43IjfuPzYjQF44 RFh4W9ZcVujZWePceJLCoClhHmUjxLuT2mjx+h0DBhjLu7LU6hT0wiXmkntjXRiS99AUMr2o7qNyms aaPTUAlLc0njj8DVRSzXsIP/EhochXn1l2v8kaUwkKB6RZSxGLBAWOqK9emNUOuONlL5xtKPyqXGqA OIJpJdP//0DLv8SNxwE5R86ch2Uq66 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Stat-Signature: uqhm7s3qdrozhu3h7ka6e613zkdh7sji X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7BACD180003 X-HE-Tag: 1706963270-961286 X-HE-Meta: U2FsdGVkX1/NTDxp37pUqXaFbf8O4jjkEUbRp4Vcj5kfs2z979dAFXP30UXc3m7ZfdYLYUSJEWGhaDcrZmd9Absc5EDN9nudakS3AjmQk6qkqS0YK1ZzJ5gMzW9P4jLgYzfsXyC+WeJNkZSm257ZR1kj3+DF5SklMDK6xpsC4CUFuysYs4eugvhjZWznQmF0X5UFHUHi/qItFDvjezY3YpVrfhQ/ncNS9O9WcxuMwz8KwOFAvu3fHCUbMsseSuuq07TVRfDD1R+RoB+GGpIiN22Begt0+JrXIiRzVkJH3hqFxtctDV5NzHC//dJtNfd42yqVHW64juE26DPD+1FMCnlLEbV7D6ZRgSE0q5DMsWHVjbbuOYPB5KXYV0dLVPpUXEPTkiY226ZR1oM4qdzC1LGTPrXTHJxjzGDEwf6u9aUe1pDDreKzENOEshID3PJuXRiINvALgZheNiZIWjLk9fK3jL19EnrzAfsHiqMlaAgpMaRwmjQGIy8rRNGxz/TH5x39W48s+mX4H7C1axOQtV4fghL8UBW8sjeFWg+byrns3NzkbtKIV77ZSFOhsE9sY4t6SWLGiTLfdGpLx2JLu5pmOKld/YewZCAQSwAcMy5Djj3BOjI9vatjLEzM/MdJbM+g8HArf3sxKjJEMeyKwWqfv84lEf+93HO3jOUzKhLJMpHgakBf8i06/jJh6qqAUazdYescMr5AqnIJJQZs4oU39akiEl25hJ+wOxaHeX4ZwFsofQ6N6spr2Bwk3XPeJ5DDy267728JhCuMBTkJjFFTDAskiomHsZss9LAEcIDO6a/VExjmVrORUqfjk2hLZvt/ZfqED99Mg54FEeuIzSb/7JCNFlcaBPFbjHyySY53JCd/sh9tz7FtDmedq9aaVWS7eDaqSSiw7mi14iNg3DDihyungq5nt0P0XKDpQXQqv6W6l9LZTZkCyI4/dy24Kzgh+xd6u2b5bm74WEO RNAW9syK 6dZWg+l2mqYk9VmpaggIYSAsugxuFBG+QlZ26KPn82T2vBA9IGFFcWRw07SbyBj2IJ7jNWWl9Zzp5vZiLi/5uJADGkQY7mCB92ouCIzFfJXZfttpTK3Hz+7cvHILRbYWjW9PXNmDkMOkv5RKyr2SZk+qzwsrYRr63p21pdTLCFkqa+9y4/sBF5DIBbayFAKmrpw6K7NZTMRBqI18EFqEO6HFiYfspuKtKeypAPesUkAr1q/sRJPgq5tazamONbu/jcMWZLw1OjQ8axgXgqjvLZ+m2Zt5CTOgtmU1EqPPDtVYoK+uSY8a89GU48hD9hrRBA0tbu4btu2pOXY2xqJNlonz89WkoJLNtR/r9FtDAMavSwGNahJ1iZ0BKlQ== 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 */