Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1786281rdb; Thu, 17 Aug 2023 01:53:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNw2+X54SiDoC9kZlcOxREkmjP6DXknYaVZCfYG5AQblzlmIKAgya6eEElWnc6vAxh1KWc X-Received: by 2002:a17:906:3005:b0:99b:cf0c:2cb1 with SMTP id 5-20020a170906300500b0099bcf0c2cb1mr3484177ejz.66.1692262401813; Thu, 17 Aug 2023 01:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692262401; cv=none; d=google.com; s=arc-20160816; b=dUOPYL68V8gj5H/sx2fpi8DpdDDt999WaV37aBqxRYdZS37pPEs1Xss1va5APDO3aL 8V6E09CFAfjwJFGT3eDQWN2eKYs0qyDcZujpopGEyWXa+qWTx69H4EaRI31wdzwG726p SpgUwvUF68QD2/SWW7oqlu5VxC5vK/nnwXClHvhzBCMalwAA2KIvzRYz07lWiDNvBZtF E9vg+Ch28vtUCpqE9Qtx/iEdFPCrXpGW4mJ2QmcbNfsAehMemNALJp6Y15iwYgYLwxJi I+EkrNfZUSKgEn4HjSMReVL9XpQy8bha9q7ZBQSpgK2ccAkOGS6hAdXoQPVjg3+UJvx0 m1bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jsf7FLyU27m3+toxUnlXiv8YtTxJMlFw4G7r6iMHvJ4=; fh=wS7gH9gJTwVbMI1951Any7fjyeH00wl+n7Iolqr1PYU=; b=adzYDKvM4eV2yWDOgGHAS0P9UkLpvupKO5hfdhGOmDlLyuLzI90RJqx3VT86/Zaj+T gO2qRY2+dg8iXxkhGPQd+Czcx2KKo8Kf9pxLAUuk314d2yuJCH5mTwaNZD1J8jtATv2x Dx0R6JKKB5fSWEl/Y4Lolwzmhg2MPcipuIdn7HsvGtOwbCfPi9MDaMsXEzvSbryQy+3v XL9DJ29/RnMLECMef8rUiyl0rlomV4sdUCuHuz+0/+2BNvZm6q0sfp9v7ENWmrXfqx28 lVcCHKymgJtPkM8HPOkIQi6q2WAv7Jn/e7mS06tKyJwCefci2VXXOhZmCkUj7dc/NSO6 nJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=djQMSkko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170906410d00b0099bd0b5a2b7si12366954ejk.542.2023.08.17.01.52.55; Thu, 17 Aug 2023 01:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=djQMSkko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345445AbjHPSQh (ORCPT + 99 others); Wed, 16 Aug 2023 14:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345439AbjHPSQG (ORCPT ); Wed, 16 Aug 2023 14:16:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F98DE4C; Wed, 16 Aug 2023 11:16:03 -0700 (PDT) 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 33BEE65BC3; Wed, 16 Aug 2023 18:16:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C596DC433C7; Wed, 16 Aug 2023 18:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692209762; bh=TgK016C/w5t6JQKrQP4E8mcD6V8oPi/S+UCWzSu2Rbc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=djQMSkkoGjtLgUNe6JiG+uUbjTG+u7ie7eym1Qc/s0ITrVmBOvMdk78mSJmK4ub/N BH/UchLawIzBNwHe6rSkOxpgF+9ayCmXUe+Jm7bBi6IIIFDF2HmzCsSA8IKIPjtzYy vqUXL/PRWiYVHhJKMQDXe+LpZ7bDavgxVmYjSYwsV4NqVBdnLJnwgUEnP9jySYJcMj UlvkUii28ef0E+WUplhkuFmFDfhE+PqklMByDsCChsqfuljh2qr6ywU/K+qtnnWyZy aaaXhGNFfTCa6SGlKE6Cz/VqFo4RwngUUKGxQ6a30H5DdMlCF9ksxaqQXcnOfoRwXX NWfU0nIwFHXfw== Date: Wed, 16 Aug 2023 19:15:53 +0100 From: Mark Brown To: Catalin Marinas 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: <28a61b5f-db65-427e-8e92-60dd61549da5@sirena.org.uk> References: <20230807-arm64-gcs-v4-0-68cfa37f9069@kernel.org> <20230807-arm64-gcs-v4-18-68cfa37f9069@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w/BKAb+ClmJrMdeD" Content-Disposition: inline In-Reply-To: X-Cookie: Old soldiers never die. Young ones do. X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --w/BKAb+ClmJrMdeD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. > > + /* > > + * 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. --w/BKAb+ClmJrMdeD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmTdElkACgkQJNaLcl1U h9AWogf/YEdfvtUHD2e4VQoupNYTIQwE4lzBKY5h7rikxnt03b6khOwEnmScy/XC 1TB3W5zmAGwyJdWCumepeAk5BTRzsKZWV9cdvP0YvcmTlzMqj/1ueNfpHfEu0NQs Udxb7QLhxyd8wdlIZn+ycumv7YnckO8stcBNRbenMRsLqKpTsXlM3zcsul9zvSPK zWPmyj/57XvYpeEmXgL+2zyLRmGfWEQB97ImfCgO0EkoAxFA6TUugdIAa6g0DWoO hZKEu0+mqQUN0RTXOLAqYQXJLGD2lVzT5G3L8HTPyR2GNZIruqNzD+8ZkhSSMm51 QjFuF+aVfUlZwpNuSsl7bhqHNJmB5w== =8c8E -----END PGP SIGNATURE----- --w/BKAb+ClmJrMdeD--