Message ID | 20230724-arm64-gcs-v2-7-dc2c1d44c2eb@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 6BFA3C0015E for <linux-mm@archiver.kernel.org>; Mon, 24 Jul 2023 12:47:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0B5A6B0080; Mon, 24 Jul 2023 08:47:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE00E6B0074; Mon, 24 Jul 2023 08:47:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C80D96B0082; Mon, 24 Jul 2023 08:47:46 -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 BADFA6B0080 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 08:47:46 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 99DCC80A33 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 12:47:46 +0000 (UTC) X-FDA: 81046482132.13.439CEFA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id C495D100011 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 12:47:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Jc4/plLJ"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1690202864; 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=mJroho1o7mQ4v5IpLO3pGU+gSm8jYAJUrZ5Tuta6VfI=; b=GufuhwPLIIWS6g4shadERirdVZgPtgxk93xiy9LWyWKMBM3PdJOb96PojLp5yFtHCdGI1C ILkFa/q2zO3gIy9sgF99dA/QatsjEL3IDfBiQZBHf05PgQYxG0BTDEtVL7fq0DqRMDm95m sXPXBAeEiIqOd0a2daAFbf7O73pOJko= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Jc4/plLJ"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1690202864; a=rsa-sha256; cv=none; b=ojGKaKLDEEFoFcEtJ6tWmI7Zf0use7DZKkjVorwC3HEBAkvk/+kQLWkefJrskT/ggDxk0t avTr5j4009iY+w1nLCOMys16MoDEJAIM89EplGLlBhxvetOFrASlTknS+dM4+GzumWW4Me KYZhZwNZueDVq/HZ+L7u6yZUnQ9iy2A= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 07D5E61155; Mon, 24 Jul 2023 12:47:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CDFAC433C9; Mon, 24 Jul 2023 12:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690202863; bh=BppDdcqjtJzUfuzafP5lgvHCeya4NknqM0BAXJ7ap7w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Jc4/plLJv7KYhQYVKckcQWOhhYiujYOQTa41utc9aW4Cpr99u0i4Rk90wl8V28aqY 4vB0Ip/vhexWo/OnchyZc/oJQDlGKty8KiYoskIPPFsirPZ/W7ArTF+IfcY3BV+QhF lLqGWKC3cLAyPfIpmGz/0P5RjeQHmc/NKaTEjz289ovvafHa9DRC4p1aQojxO+It6y 1u5IPnbo+1Ir+8+5FoOK0iuccBV7tCljK/ncbi1C5j6ooQa6A8lMqn41g1Kx7t5clW 1rOiiESlmTRz6HUfJS3lZFKUbgO8NSo+bILf/ipUUnrDraHP1HMxMjGggwGxb5Ch/C QV/1AO/rbKb3w== From: Mark Brown <broonie@kernel.org> Date: Mon, 24 Jul 2023 13:45:54 +0100 Subject: [PATCH v2 07/35] arm64/gcs: Provide copy_to_user_gcs() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230724-arm64-gcs-v2-7-dc2c1d44c2eb@kernel.org> References: <20230724-arm64-gcs-v2-0-dc2c1d44c2eb@kernel.org> In-Reply-To: <20230724-arm64-gcs-v2-0-dc2c1d44c2eb@kernel.org> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Andrew Morton <akpm@linux-foundation.org>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Arnd Bergmann <arnd@arndb.de>, Oleg Nesterov <oleg@redhat.com>, Eric Biederman <ebiederm@xmission.com>, Kees Cook <keescook@chromium.org>, Shuah Khan <shuah@kernel.org>, "Rick P. Edgecombe" <rick.p.edgecombe@intel.com>, Deepak Gupta <debug@rivosinc.com>, Ard Biesheuvel <ardb@kernel.org>, Szabolcs Nagy <Szabolcs.Nagy@arm.com> Cc: "H.J. Lu" <hjl.tools@gmail.com>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, 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 <broonie@kernel.org> X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1292; i=broonie@kernel.org; h=from:subject:message-id; bh=BppDdcqjtJzUfuzafP5lgvHCeya4NknqM0BAXJ7ap7w=; b=owGbwMvMwMWocq27KDak/QLjabUkhpR9Rd195ox7IqUD6pIltzCHNsX+jjS5e0s2dtPkAMYPWaKN wa6djMYsDIxcDLJiiixrn2WsSg+X2Dr/0fxXMINYmUCmMHBxCsBEvp7kYGitcf/AXWglHldUWygtdT y4cWNmh7OzfP6Dhoff5QUK7Oc1yH2Y9u6HB+exNJ0bOVxV1/V+XXeX2z7NclNxZ+S1l6waK1cWqktx eXx+d05N0J+n80exesCnPwKtpWzLnDx10j5zuF+3KZ/fnH8g7K/h8yTB5/uWJSgKWIR2sCiXbX/IP/ VKUtKzA5o9cxj2hF0IfrfWc9Oq327mhTxPMo/f1naICZtmk8wqe6Z4qZjGlO8t+3+IrpsWcPSV/ltJ ze/3jmqK6P9fP6lCevXZhMfTH9/un3Ts454nqlq9kVoSLvmfjGWTFq4Jy3Z+tsuP/8iKDdV2NV8v9T 5x9fwXo2wYINbppXcvcPbjA9eiAQ== X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C495D100011 X-Stat-Signature: 6k7r77xgz6eenc9c83q4wxowrcjk31ji X-Rspam-User: X-HE-Tag: 1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TrTaZk+3wxemSc6eWlLHzz9kSNCEIqDvXWDfi5AJuWnIe4zdbDK6wmkKAoWR5Ord1OMTBAf3RM6+rNRpR3Pag0NQgxUW24g6jVfpqO3Ndb5As7NuBaXeynJUc1U8zcMe+IlreQoxOjnCxXjup4UCgidK62+z08kNqtIzQp0bmpl+QHp/5hjvmulw2g29/cqxeXpppHHWnfzMsQcJQbTKxLZ5Db4zmiUsF7lsEzOPzx8+HCX5hQ87K/o/PLf2y1yJUztDIYbACNlyufUB8zuP9nhnMTCdERNyZXeOB8y7K9TPEMi+7//FgyDaI78II7DnLsEmhOe+6H99oZnYm8IOUaWPtV7iE4aSwtWRhSx15eIdcQMGS5L1MAz0xNBiU7JaN+mtBNTDxi6LxoUNWSZnG+WOmL1E9vRg== 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: <linux-mm.kvack.org> |
Series |
arm64/gcs: Provide support for GCS in userspace
|
expand
|
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 22e10e79f56a..24aa804e95a7 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -445,6 +445,26 @@ static inline int gcssttr(unsigned long __user *addr, unsigned long val) return err; } +static inline int copy_to_user_gcs(unsigned long __user *addr, + unsigned long *val, + int count) +{ + int ret = -EFAULT; + int i; + + if (access_ok((char __user *)addr, count * sizeof(u64))) { + uaccess_ttbr0_enable(); + for (i = 0; i < count; i++) { + ret = gcssttr(addr++, *val++); + if (ret != 0) + break; + } + uaccess_ttbr0_disable(); + } + + return ret; +} + #endif /* CONFIG_ARM64_GCS */ #endif /* __ASM_UACCESS_H */
In order for EL1 to write to an EL0 GCS it must use the GCSSTTR instruction rather than a normal STTR. Provide a copy_to_user_gcs() which does this. Since it is not possible to store anything other than a 64 bit value the interface is presented in terms of 64 bit values, using unsigned long rather than u64 due to sparse. Signed-off-by: Mark Brown <broonie@kernel.org> --- arch/arm64/include/asm/uaccess.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)