From patchwork Wed Nov 22 09:42:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464433 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 DCC9EC61D9D for ; Wed, 22 Nov 2023 09:48:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C7676B05D8; Wed, 22 Nov 2023 04:48:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 776B36B05D9; Wed, 22 Nov 2023 04:48:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63EDF6B05DA; Wed, 22 Nov 2023 04:48:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5247E6B05D8 for ; Wed, 22 Nov 2023 04:48:15 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2F9CA1A0839 for ; Wed, 22 Nov 2023 09:48:15 +0000 (UTC) X-FDA: 81485114550.30.28DAAA9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 601C514000E for ; Wed, 22 Nov 2023 09:48:13 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uZVDPcKF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1700646493; 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=GQzGkKqFdDjtW47t1neXVo9WE7wwJKuc9BPZVSbCuv0=; b=7zKi14zO2kELnwjO1Y9BTF6PtOG3z8BEO1pJ2rQkUgfe3b5N4gey4WSvP7ajI7n6ZvKr/P AxkvKShnDiQ0LPofCfSAfDmSnm4KUl1xbbp6dTsxt8RQ5IK095uGyZBnbYbJT+yQpP6I7F TJCN6UlSElOm/RD7GNum9U/VKBS6xAQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uZVDPcKF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1700646493; a=rsa-sha256; cv=none; b=LmfbVGh9CseE0GjZ+r07O2FOV/gn2E4+PgN35QUAeG4z3II7nlj1pmhWGTfNdJD2/SVpSh ZBT/V9lBmTc+pcpsmXtta4siNXFpkJ16wL7LBqjcPTSNuitTzFaTUJWAoSLNABLMLdltI1 szna6bkHxC1lUuNZtr3V24PfRmJatKc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 78B2761CAF; Wed, 22 Nov 2023 09:48:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB795C433C9; Wed, 22 Nov 2023 09:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646492; bh=+DcIGbRVvw60QaNepPSRFBnETXstp9aOb5bVveLOaFg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uZVDPcKFka+wlMJXjfzajobqpM6EaIscRoqp8YtTGuiZLIBclLh/18h+beyzfCCak O611N3cFEGc9ooTue7jvmAjHduLzlohXVD9CMIjCWn79H/TlnFbuXsNc8sX94PgzpD CziDJmtJS4Lxr7Q90BN45O6K7RZDp60OhWbeVYOizHCAv+pOxqIKTxJVflyNZ+J6XH /WFEwQWOydbHD+eyzieR8s/u37khmup0ORNwiLjGPrd5KdyWHwd+12K9tNSjVXsVMU h4yc9Yk3hd0sUoKwmILtXr0+4rKmOlfPSNZJELuR9deSXlQR1au1DbSTFSMH3s0Dw3 UjGBYMzpNCEaQ== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:49 +0000 Subject: [PATCH v7 39/39] kselftest/clone3: Enable GCS in the clone3 selftests MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-39-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=2416; i=broonie@kernel.org; h=from:subject:message-id; bh=+DcIGbRVvw60QaNepPSRFBnETXstp9aOb5bVveLOaFg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXc0Uf5JbJdKOG4lKmXzlRMK5DRWagk6L/dGG+ 23SAtCf39uJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3NFAAKCRAk1otyXVSH 0HKwB/44qmjC2meQurJ74cEJ5LyDpr1HY6Y1uWSWnrnkSyRi8ifcJAyyiipIeWWT2m2p19Mpf+V 5qrOSTOZdbGPeoAgIKaULvFGqHP/ksUE8h92lW7xsOkWWWvpcMBPOCkmhlsIYyaWpVOSMobVII8 PBDQf7mV3cJuvY8YfCMIkBz3Ul6mwtxdu9vNby4YUtXDRU9U3cGAcL6XtW3KntS2xI0+aDTcs7i YX48MJ+hv3H+CYavScUNHVuNSx8y1Q3eta1i1xV3wGLOaAAxBPAvtoCuwkfsLCOAy6jNqbmbBPU 2P7pVrY78UsvDTA8mvMcJrJSnASVS4HY2NdgEMkZbCxKMCbn X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 601C514000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: q9mj8kchu43xqwupfcmnmf6kyukoccau X-HE-Tag: 1700646493-846361 X-HE-Meta: U2FsdGVkX18HPBpuiX7ny0fbprQwRaiRUpLZNOhxRUQ+fHAFz1BRSz760OCW3P08q5hcw5G9TeISxOiT+HGRcXSPUjDDreUVkvj5oAnfDC5bSvIN26W8yKCjtWdF2IB8S45uUNSxN++7W70FLQxnz3vd2MxiwAo17AvZMpEwfZGPnrAt0NYX/jLkVO0Ycat98d3LKFjq2viuWEQb3d3q6QxcEU4CFfNuHaNMKI1NbjslsxKwsrdbHO4KkOtUweGlh7MtCSU8majlMpp9MdEDir7cWwt0CDZ/2rnK7fzu2jFc5xBVc9B8/sTRMl1kFY6e8FdIIH8o9+WgAmJoULF74FGQdLltTNtUyV/cjA4jjCVqt+k8dqfUapVB0Uq10/iYFMJVa9e+HTWnXvYZ0MrS3VGxADO7DwdxbT2I/plWD7S+X323kG+CcngvQn3cIk3IuhiUDFQnPEnlVqcNLfe9sMxZysDOn9pWHgOhX5Y+7xu7KokzjdJ3ygI8gO3MG4lOyue0DLWdyy/Ijt/TS66age0dXwG3e0SBahFxhe2oTWcCh0HsfKN5OewJbt5WKHkvMCzIEDJmycbiB0XZQtKByqfXMwcD93ePRSgylIc2yIwC1F913E3CrPHEKyra1+gswMQGSxAxQ8xlWU6/t/QXYjMmE0PkPIlU2tW4KxZDw9DqsjVxcnh5RyUb9gFfhSjDlOHXDoo8GxSigvQ9meF04VtNr903DU9V7Xk2a0Bgo4lv21d07jpYvntAS7nnmFQGmlIwVOmtO1oRJ0wR4jVht1kqmhH/StQPvr8IbiEJL6Y8qU8GEuh5/+JSzeRQOKUAzDXfJw/3JP5tH2gT8i+vGdCLo4NQitiUH7ZvWo4Bb6I/0W2hORuINlvYuyuPXNQCukwxXtLEgBrksauhLfSMuWbcKzC55b3Ymk3yE07aDn+z7i0qrQemSe0xcY575qjgyy4Km1fB/qcmpF2dt7C jaRwYPfx yKKJ8cIvhUv3JzD8q8Azcxc/bNPzHy8JeBWhzhX8jW142Uy9T+2luHn+1Lh4YakQTz434+Jw7kxwr1LRLOAhICWUlDzyiymyTXIn3018Mvj9ESJ/OFJOn86Y9AxmZs3rHzYgqReT9eTT2zG3TROrsS9uMed2Lp250ZUoXL15XkfiNJDhtzApxG/bX6ybGsHcpJCtZODDr3rQ0WoRCT2SDgu/SQYABj6l6dqyIcsTrC43kL8ZTHbvSs+Z+Dhp0PY8VkEtRSmpu62z6xpmK1UKvng08wplY1x5k4Sc3ZNP3qU+ZvgCsBLqHJZHetyfErCXCG/0f 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 order to allow testing without full userspace support for shadow stacks the clone3() selftests open code enabling them at runtime, hook up arm64 support. Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c index dbe52582573c..6114a33d6ec2 100644 --- a/tools/testing/selftests/clone3/clone3.c +++ b/tools/testing/selftests/clone3/clone3.c @@ -432,6 +432,43 @@ static inline void enable_shadow_stack(void) #endif +#ifdef __aarc64__ +#define PR_SET_SHADOW_STACK_STATUS 72 +# define PR_SHADOW_STACK_ENABLE (1UL << 0) + +#define my_syscall2(num, arg1, arg2) \ +({ \ + register long _num __asm__ ("x8") = (num); \ + register long _arg1 __asm__ ("x0") = (long)(arg1); \ + register long _arg2 __asm__ ("x1") = (long)(arg2); \ + register long _arg3 __asm__ ("x2") = 0; \ + register long _arg4 __asm__ ("x3") = 0; \ + register long _arg5 __asm__ ("x4") = 0; \ + \ + __asm__ volatile ( \ + "svc #0\n" \ + : "=r"(_arg1) \ + : "r"(_arg1), "r"(_arg2), \ + "r"(_arg3), "r"(_arg4), \ + "r"(_arg5), "r"(_num) \ + : "memory", "cc" \ + ); \ + _arg1; \ +}) + +#define ENABLE_SHADOW_STACK +static inline void enable_shadow_stack(void) +{ + int ret; + + ret = my_syscall2(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, + PR_SHADOW_STACK_ENABLE); + if (ret == 0) + shadow_stack_enabled = true; +} + +#endif + #ifndef ENABLE_SHADOW_STACK static void enable_shadow_stack(void) {