From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E053FC3DA4A for ; Mon, 19 Aug 2024 11:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LPDMQZiK7kdOcRM0/7UbnSHMIQSuRYWqVU/2hj90wQ0=; b=hhXUF8FpFV/tqVdWEKw1lrHP5C Qv7OIpNPCPrIfg+T9FTO3EckCsW09WG9Qj1BcdzD1Zmt8BYvW4xcFAOyhvJNpewcYS3GHzpM6eXQJ tntSOWRbjNEGCGx7l4VQQxBKTuuA6zoK4t/psO+Z9rQWGheJJ31k7FGeP0wsTFV9Y+JRDmSWOGgeV IL8ppfckT0lnpKkTIfz2POquW3taHsjMu5dWlRz6Vt41bhj0F42vs0QPSVpwVf++XS7+Z7KIxzWeI 6yPHntRLWVSoW7KG37xyQ941ebhtzpjZXRsJQ6BZlnAh0w0E/VzEoX+vM9c4P19e9zt42Y3hel0Ro BNVPOMag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg0qn-00000001Grd-0TNe; Mon, 19 Aug 2024 11:47:05 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg0q5-00000001GiB-2aTG; Mon, 19 Aug 2024 11:46:23 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0420660B9C; Mon, 19 Aug 2024 11:46:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DF1DC32782; Mon, 19 Aug 2024 11:46:15 +0000 (UTC) Date: Mon, 19 Aug 2024 12:46:13 +0100 From: Catalin Marinas To: Mark Brown Cc: 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 , "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 Subject: Re: [PATCH v10 19/40] arm64/gcs: Context switch GCS state for EL0 Message-ID: References: <20240801-arm64-gcs-v10-0-699e2bd2190b@kernel.org> <20240801-arm64-gcs-v10-19-699e2bd2190b@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240801-arm64-gcs-v10-19-699e2bd2190b@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_044621_736525_E9C746CD X-CRM114-Status: GOOD ( 20.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 01, 2024 at 01:06:46PM +0100, Mark Brown wrote: > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 4ae31b7af6c3..5f00cb0da9c3 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c [...] > +static void gcs_thread_switch(struct task_struct *next) > +{ > + if (!system_supports_gcs()) > + return; > + > + gcs_preserve_current_state(); > + > + gcs_set_el0_mode(next); > + write_sysreg_s(next->thread.gcspr_el0, SYS_GCSPR_EL0); > + > + /* > + * Ensure that GCS changes are observable by/from other PEs in > + * case of migration. > + */ > + if (task_gcs_el0_enabled(current) || task_gcs_el0_enabled(next)) > + gcsb_dsync(); Could we do the sysreg writing under this 'if' block? If no app is using GCS (which would be the case for a while), it looks like unnecessary sysreg accesses. What's the GCSB DSYNC supposed to do here? The Arm ARM talks about ordering between GCS memory effects and other memory effects. I haven't looked at the memory model in detail yet (D11.9.1) but AFAICT it has nothing to do with the system registers. We'll need this barrier when ordering is needed between explicit or implicit (e.g. BL) GCS accesses and the explicit classic memory accesses. Paging comes to mind, so maybe flush_dcache_page() would need this barrier. ptrace() is another case if the memory accessed is a GCS page. I can see you added it in other places, I'll have a look as I go through the rest. But I don't think one is needed here. -- Catalin