From patchwork Thu Aug 1 12:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13750387 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 987C3C3DA4A for ; Thu, 1 Aug 2024 12:58:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D8746B00A3; Thu, 1 Aug 2024 08:58:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 260DF6B00A4; Thu, 1 Aug 2024 08:58:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DC356B00A5; Thu, 1 Aug 2024 08:58:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DF8EA6B00A3 for ; Thu, 1 Aug 2024 08:58:17 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9240E140D5F for ; Thu, 1 Aug 2024 12:58:17 +0000 (UTC) X-FDA: 82403679834.11.51DD4CF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id B12BB4002C for ; Thu, 1 Aug 2024 12:58:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MbNqHBPc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1722517090; a=rsa-sha256; cv=none; b=Ed5MFUhSFT/Jy1tLtsh/1+t0wMrfjgAXypj2V7/RYaLDKiZ9xDzbNcYpz+CL0OBQn4ALxd MFlbPhbDM8ejb9pqK48G1NXXx4EIA9RxM0aGQdjIhuxkDRerqKxKm+skMmaC9YwckwJ3r5 jBmoKkcXaCDfKiQuoDQuSt3SF7XQQJc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MbNqHBPc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1722517090; 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=+fN4ByY0FzRDwLIySX1hIe9Ll/YoCNC7ejriYTNI6D4=; b=MVi5CQ4XZQ32fgM2XC4JBmyDq6ZmnGIPTy1Q1fdPd2MV3VIGtau4JPcSotv3mBy4+T4PGz WO2Zy5TOuFeaqyFQW772K3P/dSSD/zFjBPtwWxfb/d/565kfHx4nOVvUrOxNoCnIVIHjbG ynbDjCmGgkgyXT4zpuZp+qOP2wGQdtk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D640862890; Thu, 1 Aug 2024 12:58:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4743BC4AF12; Thu, 1 Aug 2024 12:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722517094; bh=9zyM2kDwaHrPoIdC+tOITu/EBfLF+6/APyyopskSW+Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MbNqHBPcT9Y5beIJ6gploRPX48lF/ic8+DFzi6qdc6cvt1vT0gJAFXuZWU/kINSbG w01rYdOQQA70NsmuDwunpJubsh8i49z3114zgqs38oC03JE2Bqoc6n80qPrvENvVII 81drmw9RC0wAULSAgtpeMwsJVVFhmHjeXiwAARS7LEA7/G0/xLGStM6i1X36yW9kla DOX+sdvAgON5kBgQ4fl7b16mFYaxAlkwxQdWUoOUlKpWlx2i9A9Jh1XksQdoAltZZH gr93pgYFmS5Q3Kyna7upwfm/6x7XCQYA0Sya8gOelUhPJsMBBrgnSlvAZwD8zwzTBc y0OUMFpqw4uNA== From: Mark Brown Date: Thu, 01 Aug 2024 13:06:35 +0100 Subject: [PATCH v10 08/40] arm64/gcs: Provide put_user_gcs() MIME-Version: 1.0 Message-Id: <20240801-arm64-gcs-v10-8-699e2bd2190b@kernel.org> References: <20240801-arm64-gcs-v10-0-699e2bd2190b@kernel.org> In-Reply-To: <20240801-arm64-gcs-v10-0-699e2bd2190b@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.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1103; i=broonie@kernel.org; h=from:subject:message-id; bh=9zyM2kDwaHrPoIdC+tOITu/EBfLF+6/APyyopskSW+Q=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmq4YMRl/JJcB0rkEcqgIQ8gNudAtrXaRRngscnrbl bPqr4syJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZquGDAAKCRAk1otyXVSH0FzhB/ 9vnbFMIfpN3H8ylPPtfhBn++BSFNylLU467N/+QYoDoXnkw48vtuHXvlXdbhmG/pVEekaIYqr4GbWj zTbVXnZdpLmf7S0M6QwCO4+jX59+0EOzOzIMR/69gC1VgZ4ZKDB5QA+Rx/l35VUF7O02mso6fO+HG0 2qbZzy/7tnkXVbPiyYZnF+OYGE+wK4xseNeRUDCnMYSKpPokJkZ1M86zvEhAkA9L9+nCGNYpPWot+T 3vcDQ8wwL6TUiu6/gDqeVp38IKPlTX3LZXVQecVANGqtSEzyzf+TT/qE0Fq7ArvcD9PXt2GrcIARrn lTxU0WZ6Qu9SZe+Heyb4/hIEo5nDr5 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Queue-Id: B12BB4002C X-Rspamd-Server: rspam01 X-Stat-Signature: 9uft6y99pquzqcn5x4msniomioycgor3 X-HE-Tag: 1722517095-472839 X-HE-Meta: U2FsdGVkX19wHZMZMET3kTqWqhFF5eSzgEPA903HzdJ20/nBvaP6XvYYDHWN/0e3wZlfCrnvC/KLzNUWB5Z/5kQk1TdsHPyJyRZAfze1oE8UZl+Q4biVWmml1nWaAIXzGZ0TkN61cwNyDNomkmafTcpmY3Stqgje/zKiB/qJFE5kDBTPVsG+Hib02fY4+Zug9zDo+pqSVIbcIygcmYqKoDvPHxEvKv2kQZWvFL0f3bQJQ32OwETmyilbjcJV6RV47dxu5Sorgcp/IuPa9Xi1b+BQoFebMSbKmWXXCPKGCHUJx3NLCHcLtIE6EXXlaWSsqKrnhXMOho2CpCW4w/PhoLctUmkPArewBIB8BzTIiDdda5h/+ehy9nvystYNQ05Fm9MKewz6xhN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vack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order for EL1 to write to an EL0 GCS it must use the GCSSTTR instruction rather than a normal STTR. Provide a put_user_gcs() which does this. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/uaccess.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 6aba10e38d1c..ecdd47cf1d01 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -522,6 +522,24 @@ static inline int gcssttr(unsigned long __user *addr, unsigned long val) return err; } +static inline void put_user_gcs(unsigned long val, unsigned long __user *addr, + int *err) +{ + int ret; + + if (!access_ok((char __user *)addr, sizeof(u64))) { + *err = -EFAULT; + return; + } + + uaccess_ttbr0_enable(); + ret = gcssttr(addr, val); + if (ret != 0) + *err = ret; + uaccess_ttbr0_disable(); +} + + #endif /* CONFIG_ARM64_GCS */ #endif /* __ASM_UACCESS_H */