Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp159331lqp; Fri, 12 Apr 2024 13:34:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/flLPtQikLiOxpQCLKcuY0aRTsGqK9QVDr4l/PPXGZa5Tl2ObSRbGd6UpbKaNGYcOtZxVZj1Aw7TefHO1G36qUMrraOfPb07Mvc2Q7g== X-Google-Smtp-Source: AGHT+IFE8XcV6z1NKtgLzwiiST+FSjKLiXtbDiaZkmlOjRALtLS1vVpG7Wk33a/p1HV59ugDhHJC X-Received: by 2002:ac8:57d2:0:b0:434:fda2:7694 with SMTP id w18-20020ac857d2000000b00434fda27694mr4960206qta.28.1712954097781; Fri, 12 Apr 2024 13:34:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712954097; cv=pass; d=google.com; s=arc-20160816; b=UHi4bYSClxjoOrvzUNbl1bEeLG0G5xLBspe1Ei1jZhdi6BqY+Pa+QULa6JztpI+mNc +tkqaVmxjcQ/tZW8rbMuPp57UeHf//1yLzzZ4bYHwcoVJfIv5soK90akx/cRMmbANmWy yKQS3e3wcu+e+3YUb+BbVgMUq4ow//RTiHt546MGpZ+JMvZTjCL0/jG7oGCJuE5Yi+T8 1cf8ZnAPDkrHnvi9rc1xaJEgxqTN8z4Hr+r1v5+B+i8qQq0b9k+ZLusgIRV8gr5mtK7U C80xM0NlwyZiP0hIAM94FN8F8PgQg6rrV/Pj2pzJ8+xllcW9DSf5MYf6TTgciyhi7lCq 4OKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oY4nkb56vAnwFBrxRJwfi/83hDDE+J6pWJ1yps5//Zc=; fh=XI2JgQKymeX14fPKCNHbvPM7T8aAfgoX2SkAIuZKddo=; b=Dui9mKxbNNcsoP7Rl9b6+A9B9lUABqEBNjnAalLcLbOl+4czmdOaEh+6x0JKGZ74sw ZvRhm9y82g7qFzE1zPRsJV9urGSgN0iPtj3dvp3QQMUysR7BKjxldXxUZKUW3vdl7OxR ++YTq+Ktu7FvEdJB9g0FX/muBQmmTCh1pVHX/38IQdSjbG8QGpPEyo5Sb9Bt9tSfrVxH puwa/GK6+gPUBFGoTOJxTpDpHLo4LNEB0w82c5APH32Xevb3+h/UMo/Wq6oHvwKGRlGK UQLJ6Laxbp/+m5Gk6Doil6tIVge1v20yJq6NrNWxsddiGCUCeUsp14Nyirdyhq4feDr4 ACUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=z1LGY7lp; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143315-linux.lists.archive=gmail.com@vger.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 y15-20020a05622a120f00b004365842cbdesi4613846qtx.353.2024.04.12.13.34.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 13:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143315-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=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=z1LGY7lp; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143315-linux.lists.archive=gmail.com@vger.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 75FEE1C21428 for ; Fri, 12 Apr 2024 20:34:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96A3727469; Fri, 12 Apr 2024 20:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="z1LGY7lp" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B28E199B8 for ; Fri, 12 Apr 2024 20:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712954088; cv=none; b=Uj+L+FiuNbCTtC6nRy3ku9NxHIBAX3k7eBEWKhg5gdZ6LNzkY+TpWEGi6LvMnEeyAUz/4Mwr9Tbmc3O0C8Gwxt2yVkXkK/a+Y+d5DKlmMRg5R307FE5+C9hpCCkfaEx4VqcMQhRKqKw2p4zjLtHqyXN74ZDCEqxAap4SKm1bvpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712954088; c=relaxed/simple; bh=loMKYNw/xhh/jyJ4cuKkExEImeaqTLizZBny4wQOvD0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KwKBs/2phLVphQ9SuheAcJq1o/PPcwhA5yifB1ScWUhzopHl03VmjABp+rGz1otnmQrBronTsUxPCZ4LIA2DZIQiI+PoFckiXMzpz8saZLvsP6i1gAy7IVSYtXwgQczsV5M5aJ+ITypm5K1EEFkxv/DKeCZrz+34msQsmdK8zT0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=z1LGY7lp; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6ed627829e6so1259689b3a.1 for ; Fri, 12 Apr 2024 13:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712954086; x=1713558886; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=oY4nkb56vAnwFBrxRJwfi/83hDDE+J6pWJ1yps5//Zc=; b=z1LGY7lp1lbNBLEzz7oXJ3ZpZyDXj8VQ0I3GJzP7h2hSXL8cFq8K999IA2ec5nljXj NskTa8/nX8VsHoGcp0S1JYHLna7ekm83puNHIYXaz9uEr/htPu9K5qgFFP5Y0CHXqU64 1aZvBUcaw/Ip+mnRU6sDHc8nFllZWspamvLUrvEgwwEFwXhnt6NYlQrpPqaS/M9D8dCG k9tawtJiIwrSxVDHZ69DyzWvkdhW8RTCO4ocIgVJL9szwx1IHD/jf5ffXTVll5aHGjsf IfZWez4lPRM900RZhzHyn6ZeizsXDXJUOfxK+4c4UZfdhuNI9kBAztpkRCylwhFtEcDk eCRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712954086; x=1713558886; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oY4nkb56vAnwFBrxRJwfi/83hDDE+J6pWJ1yps5//Zc=; b=Q+3LUxcwqR4XZkOZwWc4MH4Sf8MHFOm+1HMPSrYJvFDQtZHQsXtsgsX7QetClTHbOP iUt9u+z9bCaUhDSiAZvd5iCsIXpCOXOBAycZdCGu2/1XPXTPcpWUIZe0oYthakvL7fir FmEnDzi9EZosWzSEgg+qhgPnnrlIBIvW8Q+cLAJ0pAE7eA5iHqiYo2eGMGq8GcctbxRJ wHdnJ418FJL9T/RjNs0ONIt2HahFB0jAqPJnYWPpEtkXm2xohn/rviTfVbQjk5NsZQuT fB0wnFVj4YMpI0Bn8OnNLI/87qkyjGs1iVU2fMz8kxpl20+eDQvtz/Qw7G/cqPKOxrRL s4SQ== X-Forwarded-Encrypted: i=1; AJvYcCWg8aexM/jc6Q2zJ2zMaE/4uxq6fkHpa7v2lxo+owFMRAGKL7zSEbl4nthnUUP235rb+CX49GcWyAZkIqDiDZwYVpesZsukHHlyKAsj X-Gm-Message-State: AOJu0YzKPwPBooWxSyBjCpTR+z/ZDoke7w7JRTVhZqiknrGge5CJ0Zat oSI3cxQCe+moGA1LkPtKYgeH3mC/Y5ueRkJSZTUphDCKLu80CT0pJ/92hxvwBpo= X-Received: by 2002:a05:6a00:9aa:b0:6ed:435f:ec9b with SMTP id u42-20020a056a0009aa00b006ed435fec9bmr4550403pfg.20.1712954086437; Fri, 12 Apr 2024 13:34:46 -0700 (PDT) Received: from ghost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id lr48-20020a056a0073b000b006e724ccdc3esm3270068pfb.55.2024.04.12.13.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 13:34:45 -0700 (PDT) Date: Fri, 12 Apr 2024 13:34:43 -0700 From: Charlie Jenkins To: Conor Dooley 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: 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: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240412-earmark-sanction-810b7222cae5@spud> 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 AM 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 assume 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 devicetrees > > > > > that the commit you're fixing here addresses will have these properties > > > > > and if they did have them, they'd then also be new enough to hopefully > > > > > 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 something > > > > > that we can look at to perform the disable as the cpu compatibles give > > > > > us enough information to make the decision. > > > > > > > > > > I also think that we could just cache the boot CPU's marchid/mvendorid, > > > > > 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. > > > > > > > > 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 same on > > > > all other CPUs? Since we're reporting the marchid/mvendorid/mimpid 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 applying > > > > the boot CPU's value everywhere is if we're ever wrong in the future > > > > (ie that assumption doesn't hold on some machine), we'll only find 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 clean > > > > up. > > > > > > 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 they > > > support the unratified version. > > > > Not quite, > > 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. 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. - Charlie > > > the alternatives are patched before the other cpus are > > booted, so the alternatives will have false positives resulting in > > broken kernels. > > 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 version. > 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. > > 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 fixing > 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.