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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FB2EEE49A3 for ; Tue, 22 Aug 2023 16:35:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E378A280046; Tue, 22 Aug 2023 12:35:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC0F894001B; Tue, 22 Aug 2023 12:35:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3A4F280046; Tue, 22 Aug 2023 12:35:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AE79B94001B for ; Tue, 22 Aug 2023 12:35:04 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8796A1C9190 for ; Tue, 22 Aug 2023 16:35:04 +0000 (UTC) X-FDA: 81152290128.08.4026982 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id E018C80021 for ; Tue, 22 Aug 2023 16:35:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692722103; 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: in-reply-to:in-reply-to:references:references; bh=/G35tYc7D4V44xXi6ioiRoWZUAImfNf/V2FBOoV+wlw=; b=j6jJqUTCRsYYTvXzX0/bWWTgkX4LlkDp4EjXqmuzJpYo5oOJVl9rOA2FujUD9z0OCExzUT WJSWg9bzXfoTzNUaAISJaxBE6mLPJS16C0ThaWvemchAYsbvsnSZXvWitNS8uncE0fbUGq d0D8vo6pwz6OJYtDL2esgBPb19kQsF4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692722103; a=rsa-sha256; cv=none; b=dRFyAVj0Rba8eTtNPc0MHMF3+/84QH8pmRTEOzXhanaFjQICmd/yjktqKXLsL3t43NQqHG P81VQwpPP08nQ9C8KsIsgUdNMukJfeSv9wUnvsHpvn8YYQV+BWIsfVvbhdy8BXKjRTXZCv aTu4jv1SHyR7EQLgu4rwYgLB/RNAcjM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) 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 0920160689; Tue, 22 Aug 2023 16:35:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2203DC433C9; Tue, 22 Aug 2023 16:34:47 +0000 (UTC) Date: Tue, 22 Aug 2023 17:34:38 +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 , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , 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 v4 18/36] arm64/gcs: Context switch GCS state for EL0 Message-ID: References: <20230807-arm64-gcs-v4-0-68cfa37f9069@kernel.org> <20230807-arm64-gcs-v4-18-68cfa37f9069@kernel.org> <28a61b5f-db65-427e-8e92-60dd61549da5@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28a61b5f-db65-427e-8e92-60dd61549da5@sirena.org.uk> X-Stat-Signature: jj5csxok1gor7owft36mig6cj8t5rmhb X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E018C80021 X-Rspam-User: X-HE-Tag: 1692722102-671329 X-HE-Meta: U2FsdGVkX1/NltCP2TiId3EYtT65ucg6z2R392F8tu5CldlHD11evNbyhfgu9wkoBaop9eQZJC1QpHCFshqRDDDnJH0Jv5zjcCmHKZLtGxQ8zWGltbUfctvEYKgTVIVqTx7CdzRl2laTBP8098Gcmfm7mBq/wq2QHNW8Ic21QHXOu+KNSaRHW72rMfiTB6MsVRoMw083LAFyTwtXiy7vXiLsy8I/Y6UQAWgVLoDCXIB02xrjMtlIZEGJDLRzUviJeB8fwitJg4u8RPaMPD3tBZ0NRgkAk8AJscBio1Mo0lYLIZgZTpX9wZdfmCUsUW4GZBGSrxBbkN+jMdWen6NRu1rBvPt/fc+XVmNFnxlOUrE8n4TDNi2k7HQLFcOl6yAMZoYMFTJQj2Sgu1bOyjjWeEn5Km0mq65aA4THhUop0MMpxSmBei8e1pzG1S9sjLfgM7f8gK0TfDFFUREu432BQe4m36HzKZ3IuCOBjDkSgutR10hBut71pldaRysL6ZEA9sahd3C3LueDYXXOHg6ofmrLLzCykKB2wMWMY2/OMvpHZhVc/sE+nRTFrDQGF9oajw2VFxghOBLBwObZ3ZXhJGPvu+vCnnXtPnZrOSFYSzoNXpyrtRIlWJNFNIhnu6pWeAx/pko++fDwIfvVovyrzI6529Ujf207sOUH32oqiHdVB4LpB4xUNDS5pEf+VVBJWFdIqhb4jCK0Mx0Vce75+zD/O8QewoJeTZYJp3BEWszAS23bJQqegJkhxKxWXbItp75u+Ym1VIHdlTMRYHzVgJ7Bl2rkrTT6xOLJHXlIfEj1JRPCqTNJ7bYJHDqabBZaMrfKFatogLpbOHRLE0XH0tJpxB7hJs/7M4lDZAc23CdnT7GW6Pb0uPDCMlbZ5PjiPWcFL/jKAcSlymQjNvVtUwY2588MNuV5yJlDAQe8xpIXo83kkUEW/tTU6TPizI+pA4v9dDl317W1kNF6Bdt 22JvQub/ pqaOrWjO7AIj1YzbsWjtIgbdW3dehgcvBUWra8z8tTPcxdJ6/FlCxdoNoyheG1mhEpXoOwOFrpCVheCmqoKI9bMxMsUzvsNRJnvatv2Mc+Td0P77MWR4n8+pa3jZ02WAFpDa9SHco6NKhvPj/byJOpqoumWt5Y34fCMxNJ9+gYb6YSiPIY6XSjraIXwKQklx4nEui2yoDE7bHZ/zUnnh/TqqQgW7wUdAIFUg5Vv95bEX1pHmv0DoyNK0UCeCeoJRHGX5paxap6H6CJzGg6nlm8Q0ei5PLS/7P5FoHBh6pkqjfxDLxn8Ivzs50qOAOAzdX06URunR3jpqP528Lx1Y7ldEQI2GUrdyXskudI6mCoGqJP+kyNO52CW/QywsAfne5NhV32jRBB1JJlT7mr7ffezJUuhs+HQd6MCG+VqbUB/QbZQ298wCmzjF0ulgHvNbWyNSi1ZYCH4WOfpibdP4qHEgn+EkiW5AmO5xtWCqahJR9wRo= 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: On Wed, Aug 16, 2023 at 07:15:53PM +0100, Mark Brown wrote: > On Fri, Aug 11, 2023 at 04:32:10PM +0100, Catalin Marinas wrote: > > On Mon, Aug 07, 2023 at 11:00:23PM +0100, Mark Brown wrote: > > > > + gcs_free(current); > > > + current->thread.gcs_el0_mode = 0; > > > + write_sysreg_s(0, SYS_GCSCRE0_EL1); > > > + write_sysreg_s(0, SYS_GCSPR_EL0); > > > + } > > > +} > > > Do we need and isb() or there's one on this path? If it's only EL0 > > making use of this register, we should be fine with the ERET before > > returning to user. Not sure whether the kernel uses this, GCSSTTR > > doesn't need it. > > They're only used by EL0, at EL1 we do read GCSPR for signal handling > but AIUI that shouldn't be any more of an issue than it is for the > TPIDRs which we don't have a barrier for. It's possible I'm > misunderstanding though. We should be alright without since we'll eventually have an ERET to 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(); > > > What's this barrier for? The spec (at least the version I have) only > > talks about accesses, nothing to do with the registers that we context > > switch here. > > Right, it's for the GCS memory rather than the registers. I'm fairly > sure it's excessive but but was erring on the side of caution until I > have convinced myself that the interactions between GCS barriers and > regular barriers were doing the right thing, until we have physical > implementations to contend with I'd guess the practical impact will be > minimal. Well, I'd say either we are clear about why it's (not) needed or we ask the architects to clarify the spec. I haven't checked your latest series but in principle I don't like adding barriers just because we are not sure they are needed (and I don't think having hardware eventually changes this). -- Catalin