Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp221361lqe; Wed, 27 Mar 2024 04:03:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIlVNmzB4eDiiXOEHzfbROvBcteYC8Phg75ySUrmsySYAZkJDqO5foxws7498Q8WNM0G+BBrqFy1XZhRsFy/Z9gP+m5Ermok26qsUqNw== X-Google-Smtp-Source: AGHT+IHhMHC77AtRjjAwIA+0+MZbS3r7PzxcMDUEeEIm8s7S7QiQ6VkzaSMky+50U7hS+ZAxOMox X-Received: by 2002:a05:6870:2a4b:b0:222:a91a:63cd with SMTP id jd11-20020a0568702a4b00b00222a91a63cdmr2497328oab.45.1711537397879; Wed, 27 Mar 2024 04:03:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711537397; cv=pass; d=google.com; s=arc-20160816; b=F6uDY9aTJ+BGORVSczN7uVKkafWT8nN6lTygos9tPMIqk1Fz14FH61+FO2tL5NsrSW ReGUQFCUPGGah4SBcJux1owjZa5TwUeh/4z8BuLys2x0X6G7VTSkwVPncb9+ZeHF5Rls Tk3uun4EIgyH5SblxOW5zNrcSDDVGVHL5W6huy6wEd1NLIR+obeKyhyJkIaBDLrzXXRW EDnyhM4aNTFvzmyOl17Qwi449haZxUinjgV6iHS3LKW2AurRXQ7obAjSKMUnGep+6Rci zjUnHiapgdVJHnEqK8+IRMwk0kt5ZahLkYAkCDIINaE/5DDvkf3+xFgPHBey/1ymPkQq P3rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zs30mPqKUQKp4MOWwNydd6y++GcXJxj8Jaonpe8lEvU=; fh=FEP6ocQMavxoEp/pjer9p+mBzmmJbMKGkgqZ9qNaY88=; b=LU3+o/w0qTgXFQEkMyG0cEHPyULXtdxUVzUFsRiGBjZo7WBzuXe79wnF8Kii7VerkA jrbUqSyh22eAWMHi72dOV2ly5m/skDn6tBtcUVJ7MjiJICuCJpW8utFMlBFsZmP6vdyb 1TPnTa3N+x/z9BKBAQZU5a/hvXR1lwcONQ1FK8BTX4tq4IrWD+2A7MsrDD0Uvlc79cwU 3QscmB4OXLHU/fxBOAcrnGTQiZh7yerE2cDBOQx+bI3QovGoBUZZoZZr+Qe+YsAiX8wH l6Gw7hOFIc3BJPqnBJcEiAtEi2ag1pErbrrqz0N0tGejMF0AJjF8FdrPF0yfbsGsZHRZ 5QCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="C/ZSqiSx"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bx11-20020a05622a090b00b0042f1ee58680si9696724qtb.256.2024.03.27.04.03.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 04:03:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="C/ZSqiSx"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8B3E41C278E5 for ; Wed, 27 Mar 2024 11:03:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A187F52F84; Wed, 27 Mar 2024 11:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C/ZSqiSx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3EA63613D for ; Wed, 27 Mar 2024 11:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711537391; cv=none; b=jsWIQk3TPsLhMTYrsnAVL4jjdcmmkxX8tJXfZcpVdtGEX1TSqgbTOLHPEaw0ONDP9MCohYrSYiPe94JVBX3V0iyhQnfCcOKaYU8/tfxLzk20Ee3qWRntnBP3km0tQAwScVE40dropHd5nkL6pJc95NB+bO6OKMraV/ZjcOt7AjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711537391; c=relaxed/simple; bh=83yN7WR9Xwjvb0jOzuP+sGmgmZGqwFwG4WGgb1Zeu3o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W7jwb7rU2pGZbqiWbCAQHUz10/OeHqyG+CXYjTTYKRcUo2QP6583urMGrkrhV/aCqXIn2IjJOjmk5JnhlMoIOTnV3164dtDPv/PaJcQiEdqWpIUWpBu6NVjOr3K/cOHucEJExRBuLbHoQRqusGUO6Ef9KTO9HLcIMst+GBxBTuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C/ZSqiSx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DEB7C433F1; Wed, 27 Mar 2024 11:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711537391; bh=83yN7WR9Xwjvb0jOzuP+sGmgmZGqwFwG4WGgb1Zeu3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C/ZSqiSxwGB98SmvStchGG0Fo9/Pc2Sf0N7T8VYGNuwtwIO3dTsJZLCyRAH1adOdc R7r9AdpMT5fWuo2qZ5aHU7tDZt3yCH+ZBXpzlcSgjAazNhRZnCRgLdzRdFfn/EgVRb d7pK0UvdXYvheoKKmkn0OiKgd3OnFyOKeJYDqqR30F757CAIQEC/Rhs6kqWPUMn0vl 1uurGhjuSNYQFulfQ2zfxQ7bVxEdZbKqgQxIF0pCd5faKWiCRgbHa09qu3tKdPRqBX YSO5vIndQLR7N7zmvPStdJKrJkgK4tBJEvouVr5R/vjcdWhMzFRVPP+g1hkVcm/JdT hJ292oKkSOKAQ== Date: Wed, 27 Mar 2024 11:03:06 +0000 From: Conor Dooley To: Christoph =?iso-8859-1?Q?M=FCllner?= Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Albert Ou , Philipp Tomsich , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Daniel Henrique Barboza , Heiko Stuebner , Cooper Qu , Zhiwei Liu , Huang Tao , Alistair Francis , Andrew Jones Subject: Re: [PATCH 2/2] riscv: T-Head: Test availability bit before enabling MAEE errata Message-ID: <20240327-imperfect-washbowl-d95e57cef0ef@spud> References: <20240327103130.3651950-1-christoph.muellner@vrull.eu> <20240327103130.3651950-3-christoph.muellner@vrull.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ztnT3OuJ/y9UCOEL" Content-Disposition: inline In-Reply-To: <20240327103130.3651950-3-christoph.muellner@vrull.eu> --ztnT3OuJ/y9UCOEL Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 27, 2024 at 11:31:30AM +0100, Christoph M=FCllner wrote: > T-Head's MAEE mechanism (non-compatible equivalent of RVI's Svpbmt) > is currently assumed for all T-Head harts. However, QEMU recently > decided to drop acceptance of guests that write reserved bits in PTEs. > As MAEE uses reserved bits in PTEs and Linux applies the MAEE errata > for all T-Head harts, this broke the Linux startup on QEMU emulations > of the C906 emulation. >=20 > This patch attempts to address this issue by testing the MAEE bit > in TH_MXSTATUS CSR. As the TH_MXSTATUS CSR is only accessible in M-mode > this patch depends on M-mode firmware that handles this for us > transparently. >=20 > As this patch breaks Linux bootup on all C9xx machines with MAEE, > which don't have M-mode firmware that handles the access to the > TH_MXSTATUS CSR, this patch is marked as RFC. I think this is gonna be unacceptable in its current state given that it causes problems for every other version of the firmware. Breaking real systems for the sake of emulation isn't something we can reasonably do. To make this sort of change acceptable, you're gonna have to add some way to differentiate between systems that do and do not support reading this CSR. I think we either a) need to check the version of the SBI implementation to see if it hits the threshold for supporting this feature, or b) add a specific SBI call for this so that we can differentiate between firmware not supporting the function and the quote-unquote "hardware" not supporting it. I don't really like option a) as it could grow to several different options (each for a different SBI implementation) and support for reading the CSR would need to be unconditional. I have a feeling that I am missing something though, that'd make it doable without introducing a new call. Thanks, Conor. If only we'd made enabling this be controlled by a specific DT property, then disabling it in QEMU would be as simple as not setting that property :( >=20 > Signed-off-by: Christoph M=FCllner > --- > arch/riscv/errata/thead/errata.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) >=20 > diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/e= rrata.c > index 8c8a8a4b0421..dd7bf6c62a35 100644 > --- a/arch/riscv/errata/thead/errata.c > +++ b/arch/riscv/errata/thead/errata.c > @@ -19,6 +19,9 @@ > #include > #include > =20 > +#define CSR_TH_MXSTATUS 0x7c0 > +#define MXSTATUS_MAEE _AC(0x200000, UL) > + > static bool errata_probe_maee(unsigned int stage, > unsigned long arch_id, unsigned long impid) > { > @@ -28,11 +31,14 @@ static bool errata_probe_maee(unsigned int stage, > if (arch_id !=3D 0 || impid !=3D 0) > return false; > =20 > - if (stage =3D=3D RISCV_ALTERNATIVES_EARLY_BOOT || > - stage =3D=3D RISCV_ALTERNATIVES_MODULE) > - return true; > + if (stage !=3D RISCV_ALTERNATIVES_EARLY_BOOT && > + stage !=3D RISCV_ALTERNATIVES_MODULE) > + return false; > =20 > - return false; > + if (!(csr_read(CSR_TH_MXSTATUS) & MXSTATUS_MAEE)) > + return false; > + > + return true; > } > =20 > /* > --=20 > 2.44.0 >=20 --ztnT3OuJ/y9UCOEL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZgP86gAKCRB4tDGHoIJi 0syxAP98Co7XAfFsYfnMnzOgsIfjb+XPHSPmuZTmIeOhn+xvZQEAjP7y2N7JwGPC u0oOkLDxmwBaDDFykp5t1LWG64W/lQ0= =e/Gp -----END PGP SIGNATURE----- --ztnT3OuJ/y9UCOEL--