From patchwork Wed Aug 28 23:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13782171 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 B3452C7114C for ; Wed, 28 Aug 2024 23:29:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F1A46B00A5; Wed, 28 Aug 2024 19:29:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A1176B00A4; Wed, 28 Aug 2024 19:29:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F216B00A5; Wed, 28 Aug 2024 19:29:40 -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 1505C6B00A3 for ; Wed, 28 Aug 2024 19:29:40 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C25528020F for ; Wed, 28 Aug 2024 23:29:39 +0000 (UTC) X-FDA: 82503248478.04.2432FA4 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf24.hostedemail.com (Postfix) with ESMTP id 0BEAE180016 for ; Wed, 28 Aug 2024 23:29:37 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TQCBLNOT; spf=pass (imf24.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724887660; 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=mVmkXPANuj1zmFdxUYAQ0m1q3qhbhMjfYc3dEWQndJg=; b=6DwwSDDpSjTT+skMuAgbSVd/gq8baySO5avcc1LDDxubRJRjA3PiGV47ZZxNxPViNl/Uzf 5fLrFMB5menNWC9OazPNFnriZY0o4rQb+18bwrRyfvDVACRelhBJ9LQ/nYO99Gj+UeleYm aH324696bXzT8fyZleEBoXooZLahMwk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TQCBLNOT; spf=pass (imf24.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724887660; a=rsa-sha256; cv=none; b=owIGggHzm+KfBHJDRyP62zkosd2Ko58A7wNviSDakUG7V7T8s46en1SR553UcuuRisEg4b rLI9pneUmnBxKk+S96ac5iu6WRjmFGeQQIqJRqo1sFNEH21K5J1qcg1IiGBfuiOc8jkoDg gQ61quIPkUDNOV5xvhD4O01awxbD4tg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 6C8E9A4376E; Wed, 28 Aug 2024 23:29:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 509A0C4CEC5; Wed, 28 Aug 2024 23:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724887777; bh=0WRESyvBFvhlHiGA4Y8lOQoOddezzHHj49JAXCWn5As=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TQCBLNOTt4uPoil78DH70AOWVpIT6LIQ5JGnF8pCl9Kwb2+T2aoH8vA75dLA88j4y KzL26gabHDxytCwlUFatG6fR1Zvr5uTqt2pShr3pPCTMn33PxgrgHv/pPqIxtTLFnQ Ey1twIbnnj5qLHrSSrYYGfsUjFldPiC+SUfCZAAFNmNW+3Xa3o4eriYNIwXnPNhtWI 1ohkI3dobfcvnJLKqjUPXbtK1H5vOU58SMjFghxknNoLATb+4juyD5w/c/Ag8Wp2Ci OtqF9pP5xADxmHSkNwnT2wu9pMyM7UgrrXlopqBfP7xPJ5s52DOIQb4ZQoKDa55z6X 6aqd4cZGM2Mdg== From: Mark Brown Date: Thu, 29 Aug 2024 00:27:25 +0100 Subject: [PATCH v12 09/39] arm64/gcs: Provide put_user_gcs() MIME-Version: 1.0 Message-Id: <20240829-arm64-gcs-v12-9-42fec947436a@kernel.org> References: <20240829-arm64-gcs-v12-0-42fec947436a@kernel.org> In-Reply-To: <20240829-arm64-gcs-v12-0-42fec947436a@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 , Yury Khrustalev , Wilco Dijkstra , 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=1159; i=broonie@kernel.org; h=from:subject:message-id; bh=0WRESyvBFvhlHiGA4Y8lOQoOddezzHHj49JAXCWn5As=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmz7J/KST71VyjmixMxH0mLOiq0X9OEBGYvS8Br+Qk rapbHhCJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZs+yfwAKCRAk1otyXVSH0IEyB/ 9dPMuvqOeex4MLAMJJV3WaYG8PgSfjupmm2EgWeN3PodFZUAH1v2ObWF8R8GWSN47b867WTbPrnUK2 E/z43W2Ch+wVpTSLr0+bF7FvoXBo0Zw+4qi29psoG61NIvksaICvPytuz4veHug8g84QxMfdgBrQJB waIKJHxR3e1CluOtD4ERbimgFq6MquNG+8P0BrwkJc8CIWY4jiqKIf2vNmE2qBHtCKZ2jw8/yPZqzU UMi4CggPBy3S2pqqaubqBzuXEUqXzrbZc2hnNo2XHtn6LVzbBO0JtSHb03LM2SRFNANo/InJvS0Net +SJZZSugc6TOvTjh1Xb/ZHbpGii1jW X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0BEAE180016 X-Stat-Signature: ntw4sfsgwsgt5c5hzuf99g9m8ngq74mr X-Rspam-User: X-HE-Tag: 1724887777-592624 X-HE-Meta: U2FsdGVkX1+mOgZCx437Xu3K9VQzHWuI5q7ZgG5A8Rs/oJHGitg4e998r+YDYyFJPUw9eKJUCMXyHRCaFd7emAlAZbx41Xrqgvvx3jBTWKOzbU9cfccnSJ9fvjXq5R6An82HDiRLPiiUyTN+FUrxcEZPTP0L7F3fkSRdPDPzQFOCg/RFuDqRTVDPlOIpMx/84nYGVXExR0fzhzqjWkl3jkylLeQWQMjxIRjhHjw3PrQ8CsnMBY9Qrx0ze0ARIm9xrycibsxVWHevN5oGXHIcIJCnkMmfbHij0sMJTaYgwgZSjuDLl6DvBRTgWBnvG6JbIPcdrhvHiN/Cy+2Akn1xCWkmeDAEcVZAvm5CWofs1RBV2gPpBuJPHCcvdysGMZ3TbV8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CoxaCa2i9dmh7v7CLKxGqCETBet/FFdn0EeyMog7sxZ4EcPwlzZiv0GdE08= 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 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 Reviewed-by: Catalin Marinas Signed-off-by: Mark Brown --- 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 */