Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp162575lqp; Fri, 12 Apr 2024 13:43:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNJ2uqwmcCrr+JqcuruojBMI30ctdrvg6nCH4d2wL5AgvaQ9d9/j4Mj2/8Go8u2SzpwpNfKEYrnKOiPbU+WZQ0hcUmSf5RVCvgeYdAhg== X-Google-Smtp-Source: AGHT+IFej8SUnWHZOSn4u8hOxnOwOOnCdNYmC2ZHp3xLENNDjoDytFMdDUGy+CSRT0o3ZnvRZaZg X-Received: by 2002:a25:ad8f:0:b0:dc6:4062:1341 with SMTP id z15-20020a25ad8f000000b00dc640621341mr3173720ybi.16.1712954579755; Fri, 12 Apr 2024 13:42:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712954579; cv=pass; d=google.com; s=arc-20160816; b=AWGnt9N+6U9qOBK7kO2yCV8rxHFrLwXsAD+N6D2En1bP94fu7KjaVI21/iGUkVGnvo eDkyhbQSLECxuxdNlffCyrXwnCMT/j1n4X7bHbovR4dtyTbJtXbj8oDgH9j/ueXuA7FK qzNQtDrWPVDSjCPKMoJwD2Zlzv/zH9GazmKYWpU7IQrkrZvDpvbvwRlaDf9vSyBVBVS0 R3WG6KYnXpb3Hik+ykJJaBo+NMk/DOnWngr6QXRPmHKdBwIUaFRQKBAvDIkZ4upsgGvt P6Fdaw1zccJryWqpGpm9bYKxx8vlMz+sEcbR+iNDmk1HiDVnip3lLsOmLxkNlWRBPlZt jdiA== 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=FaCmkfXZATbbGc1AaFlo/IMENWfiiSjV1ABEmJ4XPIM=; fh=8NQly+n7H0rO7O0Fu88VDyZvZ7qLkkr5LeShuod9PTA=; b=lUijVuMEr2rwYOrRrfPsVF5c21V1FQaYJhQNtp4xqOCIWonGYG/oBcMnqAF6VaduIo iiZOX1Wfi0BzO4uPOICic6CdnZMgQMdV74h07Z2SPHYn78+ql+mDmvpjQ5EG0cG5OKcW FfoWv0krDoN+ze2yhcqJaN84Mbs1HdK4LdB+aWKMCPj56ZFvewT0YvsuaHcQ/5KJvMZS MxxW5YFNG/7iNAyfsMnJpjX3ku7EXY72cZ+q6ZeSFXkcc2Z1ht2nbtwp0AGm8c/Ha7fR uK7otP5M4MQxTHMFSrYim9UIfFOpX4ahKaj3TEIdycAWEO7IrHN1KzNDLaC7WLxFEyrb 2FQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YJqkcLFA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143319-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m10-20020a0cbf0a000000b0069b51757382si3432237qvi.322.2024.04.12.13.42.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 13:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YJqkcLFA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143319-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 4EFA41C21E6C for ; Fri, 12 Apr 2024 20:42:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBEFD3D56F; Fri, 12 Apr 2024 20:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YJqkcLFA" 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 E1DB92E62F; Fri, 12 Apr 2024 20:42:49 +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=1712954570; cv=none; b=u3tYfqsJODCakJyTlvCkHBCPZSWVaKENe/RhdZfgHNC1JB4hOAtRxEn41rjBYzu1P3uVFbZXka4GtjUNEz6BGT/W68Ec6Inv8iBfIK5fIHSjgffVfWYPwClylhoE+zPlShhDzw6Zuu6CkKKVLy6pwKgENl3Y0wqs8FbCmFHWyWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712954570; c=relaxed/simple; bh=FaCmkfXZATbbGc1AaFlo/IMENWfiiSjV1ABEmJ4XPIM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AyihCKVeRLSvchcm1yxBVWLfsW88WZyhMUFh1m0UihMIA1YSO1yTmIt4JrKvXY8Nsh5Ot3yGMR06tP0ivz+UExcrggznjZWlPyclnnqsdpdvmIMIJEz8oTHyq9OxOyqQy1LaGRFJ1FnKxbGt9FnmdcIQjKELgT1fYYY7NcFTJ6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YJqkcLFA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D54F2C113CC; Fri, 12 Apr 2024 20:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712954569; bh=FaCmkfXZATbbGc1AaFlo/IMENWfiiSjV1ABEmJ4XPIM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YJqkcLFAcTsECllx9rhUB7eW6r6kldZQq87sHenDtlvleSY+oc02M7gOBOIq2PiHf pi0V3EJp4UXuUwTQp32d2dR8uv689jDwAk/GBKR9ckn3fydrzu2JhFZfRICo9hbY7Z 8j2dCb7X1tDUdaTe7rD1aOhV5DEFqAwC5NAVBCm+A8I7BtdYO2XNMQ94MFZs/oacFa bBU8X5cJoaqgCKIxEDs5A1tIky/8KiRjIMbI2bOtOjTzUjtt1YcFjJDYhaDyhXv7BA rzEJ317H0UxRsRe9RiWZWwdRI/+knA9alX+gyAQ0xu9mmAfVbenxuAsBbm/17726lS h5NrCjSUio34w== Date: Fri, 12 Apr 2024 21:42:42 +0100 From: Conor Dooley To: Charlie Jenkins Cc: Evan Green , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Jonathan Corbet , Shuah Khan , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 02/19] riscv: cpufeature: Fix thead vector hwcap removal Message-ID: <20240412-scrabble-outback-dca318d44660@spud> References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> <20240411-dev-charlie-support_thead_vector_6_9-v1-2-4af9815ec746@rivosinc.com> <20240412-tuesday-resident-d9d07e75463c@wendy> <20240412-employer-crier-c201704d22e3@spud> <20240412-earmark-sanction-810b7222cae5@spud> 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="x8exgmtxQWZyWHHC" Content-Disposition: inline In-Reply-To: --x8exgmtxQWZyWHHC Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 12, 2024 at 01:34:43PM -0700, Charlie Jenkins wrote: > On Fri, Apr 12, 2024 at 08:26:12PM +0100, Conor Dooley wrote: > > On Fri, Apr 12, 2024 at 11:46:21AM -0700, Charlie Jenkins wrote: > > > On Fri, Apr 12, 2024 at 07:38:04PM +0100, Conor Dooley wrote: > > > > On Fri, Apr 12, 2024 at 10:04:17AM -0700, Evan Green wrote: > > > > > On Fri, Apr 12, 2024 at 3:26=E2=80=AFAM Conor Dooley wrote: > > > > > > > > > > > > On Thu, Apr 11, 2024 at 09:11:08PM -0700, Charlie Jenkins wrote: > > > > > > > The riscv_cpuinfo struct that contains mvendorid and marchid = is not > > > > > > > populated until all harts are booted which happens after the = DT parsing. > > > > > > > Use the vendorid/archid values from the DT if available or as= sume all > > > > > > > harts have the same values as the boot hart as a fallback. > > > > > > > > > > > > > > Fixes: d82f32202e0d ("RISC-V: Ignore V from the riscv,isa DT = property on older T-Head CPUs") > > > > > > > > > > > > If this is our only use case for getting the mvendorid/marchid = stuff > > > > > > from dt, then I don't think we should add it. None of the devic= etrees > > > > > > that the commit you're fixing here addresses will have these pr= operties > > > > > > and if they did have them, they'd then also be new enough to ho= pefully > > > > > > not have "v" either - the issue is they're using whatever crap = the > > > > > > vendor shipped. > > > > > > If we're gonna get the information from DT, we already have som= ething > > > > > > that we can look at to perform the disable as the cpu compatibl= es give > > > > > > us enough information to make the decision. > > > > > > > > > > > > I also think that we could just cache the boot CPU's marchid/mv= endorid, > > > > > > since we already have to look at it in riscv_fill_cpu_mfr_info(= ), avoid > > > > > > repeating these ecalls on all systems. > > > > > > > > > > > > Perhaps for now we could just look at the boot CPU alone? To my > > > > > > knowledge the systems that this targets all have homogeneous > > > > > > marchid/mvendorid values of 0x0. > > > > >=20 > > > > > It's possible I'm misinterpreting, but is the suggestion to apply= the > > > > > marchid/mvendorid we find on the boot CPU and assume it's the sam= e on > > > > > all other CPUs? Since we're reporting the marchid/mvendorid/mimpi= d to > > > > > usermode in a per-hart way, it would be better IMO if we really do > > > > > query marchid/mvendorid/mimpid on each hart. The problem with app= lying > > > > > the boot CPU's value everywhere is if we're ever wrong in the fut= ure > > > > > (ie that assumption doesn't hold on some machine), we'll only fin= d out > > > > > about it after the fact. Since we reported the wrong information = to > > > > > usermode via hwprobe, it'll be an ugly userspace ABI issue to cle= an > > > > > up. > > > >=20 > > > > You're misinterpreting, we do get the values on all individually as > > > > they're brought online. This is only used by the code that throws a= bone > > > > to people with crappy vendor dtbs that put "v" in riscv,isa when th= ey > > > > support the unratified version. > > >=20 > > > Not quite, > >=20 > > Remember that this patch stands in isolation and the justification given > > in your commit message does not mention anything other than fixing my > > broken patch. >=20 > Fixing the patch in the simplest sense would be to eagerly get the > mvendorid/marchid without using the cached version. But this assumes > that all harts have the same mvendorid/marchid. This is not something > that I am strongly attached to. If it truly is detrimental to Linux to > allow a user a way to specify different vendorids for different harts > then I will remove that code. I think that the simple fix is all that we need to do here, perhaps updating the comment to point out how naive we are being. ` > >=20 > > > the alternatives are patched before the other cpus are > > > booted, so the alternatives will have false positives resulting in > > > broken kernels. > >=20 > > Over-eagerly disabling vector isn't going to break any kernels and > > really should not break a behaving userspace either. > > Under-eagerly disabling it (in a way that this approach could solve) is > > only going to happen on a system where the boot hart has non-zero values > > and claims support for v but a non-boot hart has zero values and > > claims support for v but actually doesn't implement the ratified versio= n. > > If the boot hart doesn't support v, then we currently disable the > > extension as only homogeneous stuff is supported by Linux. If the boot > > hart claims support for "v" but doesn't actually implement the ratified > > version neither the intent of my original patch nor this fix for it are > > going to help avoid a broken kernel. > >=20 > > I think we do have a problem if the boot cpu having some erratum leads > > to the kernel being patched in a way that does not work for the other > > CPUs on the system, but I don't think this series addresses that sort of > > issue at all as you'd be adding code to the pi section if you were fixi= ng > > it. I also don't think we should be making pre-emptive changes to the > > errata patching code either to solve that sort of problem, until an SoC > > shows up where things don't work. > > Cheers, > > Conor. >=20 >=20 --x8exgmtxQWZyWHHC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZhmcwgAKCRB4tDGHoIJi 0oTAAQDno++1nLt6Q8uGl7ojf9Chi1JQVMjrCW3M6+YErlW3mgEA93Ys+zCKhrrD IDx65h0ho73Nloy8xmMLtheykAzE0go= =90eE -----END PGP SIGNATURE----- --x8exgmtxQWZyWHHC--