From patchwork Tue Jun 25 14:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13711325 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 CF74BC30659 for ; Tue, 25 Jun 2024 15:01:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D1596B0092; Tue, 25 Jun 2024 11:01:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57E826B0093; Tue, 25 Jun 2024 11:01:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D1826B0095; Tue, 25 Jun 2024 11:01:15 -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 1548E6B0092 for ; Tue, 25 Jun 2024 11:01:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 19A4E1A020F for ; Tue, 25 Jun 2024 15:01:09 +0000 (UTC) X-FDA: 82269723900.20.CB51C3C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 55D7B180063 for ; Tue, 25 Jun 2024 15:01:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mzTxWTli; spf=pass (imf24.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 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=1719327652; 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=PkyG32fYNDFE+WaZ0QxIKV6JPQcLTSruniJZ6u0hXtDH85c9eLYIvYGLBld7oVYpNwuise yjx+JhXkgLO56NEud+6yLwuBZm4stNZdApCqagCpaxIL80xb8jx6cNgpbXc8gbNXhJNCCy X2+xWubH9l5YMBDq9LeQ/OHb98WrJ9s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719327652; a=rsa-sha256; cv=none; b=DIlan9ylmsoRUmrG3ydd9ET6JX/FHo8QJztBiL+nZsHlJN36y5oYgQpfVCFbN7D1C1wdaC PMXiojIS8iayvyEG2CMmLPo03Swkcei/rXrd80r73Y6xjPlpCsrQccHXQMroMnonKh7FB2 QH+PsYjdxR5DogPLJQM4TfJILXGectM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mzTxWTli; spf=pass (imf24.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id 4AF51CE1ACB; Tue, 25 Jun 2024 15:01:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F182C32786; Tue, 25 Jun 2024 15:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719327661; bh=2jWl08+8re+Jbyu9WlYwMAOos2oJrw5SQjRGnUXuA4U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mzTxWTliTuTTk2JUY2LHGWlCpOYNhYQnbqbOaFCe1eKW3ChL80lwGsA7v15pLtIRr /CY5sah9wnG+/M/txc13UoiuTO17cga0aTsKBhWydbMUTpqWTnXbQDAs1a0SfXHdLl qoVcTGQynXNZq/6dMkLB1GEjLpGe+SlvF97AnPT4nal9BAJupDUdL6g1YvtgvjwhMw U7N5JBpsOck0pb6hjzSqcgOGUvjanbOjMt0n1yZOv7628rSels/zwtth3YaW1p5bfT c78+EMP6WFoUlDyn7SE6zLhy3h7EzsZ6bHr8FIMO+0yD80LEqzwuQEWN6u9EWokxPR RHWBkVwDixtzw== From: Mark Brown Date: Tue, 25 Jun 2024 15:57:31 +0100 Subject: [PATCH v9 03/39] mman: Add map_shadow_stack() flags MIME-Version: 1.0 Message-Id: <20240625-arm64-gcs-v9-3-0f634469b8f0@kernel.org> References: <20240625-arm64-gcs-v9-0-0f634469b8f0@kernel.org> In-Reply-To: <20240625-arm64-gcs-v9-0-0f634469b8f0@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.14-dev-d4707 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/pANAwAKASTWi3JdVIfQAcsmYgBmett0AYMvTd4M+mUQzuB+sU2VGcUcJh2k6ep8k/Oa xyt8GD+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZnrbdAAKCRAk1otyXVSH0Le7B/ 4p0K3blNBx+osPkkQaCF9XLApSwBKl8n26fdMeAmlfh9bwsWryKXKzkHHLO75WHM/ERBc/0i0yBbEz zKduRjPO+mSToFcQa1HgNifE5HXJ2OsSGNnQq71vZtOnDHVzxP+UwGe431j5UV5/6dHUMIj9lfY0g+ 6MJKhHwJ43INBah+hkUj4yNnSmM/eK4Ujfo3CuMqn6aBRXjQlxqsRH1KoLQR0q0d1YBUN6/pV2jCCx BTzIJ/gM/FsVYtegicohXfVWCnHv41lXYJL7HVDBny0rtyvj+u6H7erniqjPqueHr2ZBKmWeO293xS kwYER8Ltdo/507ycRN89NL9U18KQ/V X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Stat-Signature: jcbkiofbxoeg83azg66x5g8ysuq7jz4w X-Rspamd-Queue-Id: 55D7B180063 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719327665-841936 X-HE-Meta: U2FsdGVkX189PuF/z1/QcGW3n+FRGBCqdCYC6/4qGQBLyCGOgGBV7g40Il4qAFFTWVWUlO+AP8oHGVkltttOkcrPiCL1gkJebzxy5+VwNMSMiczqM+k2VNoiFU6pMr4l0DW6mTPI58lwt2UIBnZ0Pnk//X1r+SCsqSF5h6j6tekrq/NDa+4DMLVFPrSOih2v5CIo0muCJmgi2MO2q1NVHKG9CDB41Dewljv9ebQCuoVqvvXj6Gwb2Kc+rZVJGw1m9Jlgx72UfPfw0OMsyAj3097dAaf8lk23kKh+PM5UUGKKCWyS9m8/OlflqsLveK5yEGF1YyqREzCSSozZ7aIytmYjghrt+Dvzy9gdlXjZrYZeyCwOST14obxHlWMbewGWjkPbPP6L5WDsuoL7sG0cmKrNXM1215RaPll+70/y97KWwgy4dGyQnFqtRjZJ0wR4jDfZXKNBdIVC4lAdXHr1C7i3O+I43829s3mq2JxnamLXm3e1ejHdf//38Pho6FL3BNLjJ7daKe5phnlHqEGBEu9dLF86zoog4vwr8dPhfSSseNAoTxRabCtMpWIGGgA+cShx/p7plln4rR08lCABd2ZsiNfqnQtzrAee8FlHDl04XDXAxeRMK2RNc63sL0nwO8g9Gq6a2Xv1WGTdlYKQ7AXcBoFqQinmAhb38NNTRLpQpKmGbmMOQ/dLO4vDJbDeN96LYYgPXM14VKXoZd1ZoqSq4kAKCziBWBPaxE0srMAvcA1wcW2ySJ3Psa2jupDou1X2Iehu4TNWzjKEIieBIVBeS8Nc4QfilA61Uub82GhMeDrnqO1/J2GyihEaSBDh+SNrkTL8mb3nwha+WZNt+XQkqayD9Pauelqh/eZurc6yppUy8upY1iK52KaWmvDAE4tX35dPUDPgzfFPudBn9kGjpzkQ2c8P0+0oUMyKc33ou1FWQ4zS2J20rUz/ZSD391xfbaJZONZWHRUQPGU GfykKZ4r l7acsgsc101aDcAj56pK+0sKl/YDXn9gXsRwZJzdY48K3omIcyCSIJDUd5jQW1jP2rIjagzoPdeYliMm0SRCL1VLDD4zS5wWFEJxxFTdKR1iMRJN9DSdnKkT+e6ozm0EbCOk2fcBKiCV3GkDAYJlZv8yh6bTfYjo514zV+02iTc6Ule/+eQwES0cHMeXVVDijMv7fkaAEK71QpJPRnVbi892FOQXTXxETq+2zbLH6bwi5WixIGfe5S1ccaOAAd2a7CkhlP5HI7KBIeN54yFwyr1X2FBtOYzSJpu6oZ3He/PXPeOH+wu44NJqZhHnUpNCwE/8cYWO8JycTW19nKxEpgkfaoz5G8rofuW+JdllMc+idzpyX3JXrMHBbzw8IAPYiPlMyQEFEzS+WM4EnR8pruRC7lWZ+PxYklZSIm58Rqtf5AEY= 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 --- 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 */