From patchwork Tue Jun 25 14:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13711460 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 0446CC3064D for ; Tue, 25 Jun 2024 15:05:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 842616B00BC; Tue, 25 Jun 2024 11:05:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CB436B00CC; Tue, 25 Jun 2024 11:05:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F7BD6B00CD; Tue, 25 Jun 2024 11:05:05 -0400 (EDT) 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 38ECC6B00BC for ; Tue, 25 Jun 2024 11:05:05 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C9B8816018D for ; Tue, 25 Jun 2024 15:05:04 +0000 (UTC) X-FDA: 82269733728.27.750D6F0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 19BA7C01CE for ; Tue, 25 Jun 2024 15:04:12 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tavxR+nK; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719327842; a=rsa-sha256; cv=none; b=UEO0Eqsvs+0sZ6Hf5IGDmIq0Xc7bl8sIjNd39FDR+ryrQJeSWXwtdbvIww9MIlm/HeUt7h ej/ay4haJdTwrL9R09KMl1BQY9AolVXg05bAVJ8ygSL13/9802pDTezLdSoAwo455chI2o 9YHbPFSCV7oPZVHkmdSbwy13ui+RB1Q= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tavxR+nK; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 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=1719327842; 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=IfgKesjS90GRp51P7JpwI8TFVKD8QBnSEkCAxrkao8Q=; b=8BB1kCtj3Z83wyl3ogxt13YxgC04tyyVYmUufCxVZ+HamfbM5ZSH5s6RblVnZx+gPX6w5n 0Wzf7aDCEDxe3CLAq5YzkZY/hUHn1f1ihL8WUf52q8tEKCeZpYax+G16raozBzPekWYn76 Tv24hrSBTtXQCEsP3cgvrf6Fm4UM7nc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 25913CE1B7D; Tue, 25 Jun 2024 15:04:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1362BC32781; Tue, 25 Jun 2024 15:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719327849; bh=b9Gx7QUiEPIAdR9RNFo057BasR3/TeEIE9B40jmDJ/c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tavxR+nKLIiH02ssJeoEROBXmOsCstTILDhWkKXxGu60OsgiMLuDIKVo0pL6GtCmE igPSP6RIQSQWfikzRMGnE1Kg/67CHxNork4mRYKI3D96sfMbYWvsSFQl3IOmRa/Sf4 mRBbETLNbBhApzSodjPWF64W2dhM+zeIMkgpyuJ/OGB/QVYcC8rdr+Gm2ZH2a9dTQO +ie8cUyHrEBDEw9rUgJ52SuTROV/Atv37rarClR6qcQhAf0oPjoMDxiJZAhnY63WRF 10koRgwnGojMJHrP7lJKHTgsKkLjfX59wpBQd7C+FiFvMud/7otZgv4IbZEzQvVpJG zIHRIuySEFbYA== From: Mark Brown Date: Tue, 25 Jun 2024 15:57:57 +0100 Subject: [PATCH v9 29/39] selftests/clone3: Enable arm64 shadow stack testing MIME-Version: 1.0 Message-Id: <20240625-arm64-gcs-v9-29-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=1471; i=broonie@kernel.org; h=from:subject:message-id; bh=b9Gx7QUiEPIAdR9RNFo057BasR3/TeEIE9B40jmDJ/c=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmetuJPYum8zU2drU0QkG0Oevd9R7hfLQlztVXJmOP AMNcKOSJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZnrbiQAKCRAk1otyXVSH0BxTB/ 9RAJG8vNMCnKeW0ZaJ2eAuj74/NV9s5bUsk5CVhSS9OmMa/aJ+gGWY94HaF0LO0M1jlnry4Je6LXUz N04y86o4L+9c3XkvE+GTl1jJ/1Gkna5RVE2LXbIbT8mRZiwGQSJdDveYSoa2Bj37DHov5V1RP25uMZ wGWAuPensfQp/ZFhSyZUpW4mSTgmdApUyOm6005OB6HsSqlcTKdRwjD6o7DEhh+iNAcTBm4+UR8ROm 936rXsxL2yXXYX24fQXH0f8hiOJNgnDfmeHYMdbPZxh/xgFapx45UVH2J4t9am/rGr4blvsGhgPbUV BEAqQPu/bmkwHrSC+EwrYkGwBWaNjY X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 19BA7C01CE X-Stat-Signature: r6fkdyoeaatqkterizwjup18pkrpecqu X-Rspam-User: X-HE-Tag: 1719327852-330669 X-HE-Meta: U2FsdGVkX18Sxoo2PBU4150IY6z3Lz4u0GYzoVwDY1saBK7cqXhG1XIdI7Enx9Bm36P0EqSof3CxRzA3uv2uvSV7go+VGrKsEMj7kERsozDadFnhkJtM6+DReE+4YTdDcwXOWLFEsavn5IvBPZxR1ynDjfE72VQFp4QrR1xBP7yOhOgUSIrQehJrJoGy9xwiGR2vfNCMblQSeDI9GmehT6jQ6/g7/o038b9Q1oqwzhC7cIoT3joHE7iSCGKsL4/hWPFDrwhOlEV2T6c6jAgRpdUSMIogKRv5+K28NkhJZ/DwfnPjiOjI+ZG1EjHNq+Z4VEQchXa+4CHwNyi2qjgTf2rVNfZoKJyFO69K5A73lfPXMTM9Fm2nLhyM0uA2hhnZkTwiM1TkN4qLacOqsnd8ZbmuYhvZcBslSxqbpZCTWscdt7Vj+tq6JEK43XUjQjCW4sszWBprHp/vViYUKYZbJjfaIUWg+QR2D4siq9BxZCOYdre8GzZ1phDeHxg6fllpvWfSrk0Ng4EnJG/IjwJlg7zCsJ+tCBX24NbsfoXkNQiifMH5P9lzCG8QKsGYm02gAOCEmFlhv9B6XvAbcRlFIcGkQRycddQcwhxhYDw9SO3cphZD9VT9Xp6lbpekS4kIImzVipInRNPk8V0iT+I2suZDtkvLmpUtU/F0zxZiUEcIfdpD5oGc3ZMUT/VuEC8dCfo8tHk96zRcqdx2Mb8RJnOfRSjIM3z3eQvCsFA4aNMszYJoVQENbg5++MqtedoAJ1Ku0ZFT7m0M82eFFUJSz8TgiIqlokTqQdX3XRO/zuO5fFwbgb+JAyIjeYfNhTPHyZi6A5YEnS5p/UNhOwHSoA7RfIWCRPS0mFiV3TdnPwvxt+MqvtFsvvHi/iQor4NGksrKLMgVO01+JjYbscDLe9VPaYcdXTScD74uMvEdOucf3igO9YDOT9NE7kwJJV8V+nzrgouqRyD4J9MUE43 ydM7CfGG j/fVSl0wdYXlPuCEqNQQkAt3i3xq6cePPMtj1kCl5fYbs8Um/f2j9WZkDuCL/skuWOobZGlABokLNkmnPMQ/KJ5ZN0oTSLJTfYN8pBAsxJNZmja2C1n9wObEtZJyx2nUj8LI6YWqe5Qdqo9F2zzxCN0qvC2NP3A6WotbrqlSIEMOX/cOHAQRFHfXgy4po3uXgKRYURGde5Z3pBS7NVGSikt9Axv0lFnG1gEjPZEA7URQ8ADcfMsqgxzrty7XYMhoheT+Q1BjAEtbTvOfvm2QMdm/Azzf+OCYS8qZ1ohrPmJeb9BGD9/yd7ffwf+QnECasXQ9p 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 test shadow stack support in clone3() the clone3() selftests need to have a fully inline clone3() call, provide one for arm64. Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3_selftests.h | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h index 38d82934668a..e32915085333 100644 --- a/tools/testing/selftests/clone3/clone3_selftests.h +++ b/tools/testing/selftests/clone3/clone3_selftests.h @@ -69,6 +69,32 @@ static pid_t __always_inline sys_clone3(struct __clone_args *args, size_t size) return ret; } +#elif defined(__aarch64__) +static pid_t __always_inline sys_clone3(struct __clone_args *args, size_t size) +{ + register long _num __asm__ ("x8") = __NR_clone3; + register long _args __asm__ ("x0") = (long)(args); + register long _size __asm__ ("x1") = (long)(size); + register long arg2 __asm__ ("x2") = 0; + register long arg3 __asm__ ("x3") = 0; + register long arg4 __asm__ ("x4") = 0; + + __asm__ volatile ( + "svc #0\n" + : "=r"(_args) + : "r"(_args), "r"(_size), + "r"(_num), "r"(arg2), + "r"(arg3), "r"(arg4) + : "memory", "cc" + ); + + if ((int)_args < 0) { + errno = -((int)_args); + return -1; + } + + return _args; +} #else static pid_t sys_clone3(struct __clone_args *args, size_t size) {