Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2144531rbb; Tue, 27 Feb 2024 12:01:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUg9fUTRVbcHMzFhZSNg/ekfLbXzVb+iLxsjj0QgI/ZQXyZm0rRzNC+OVhR3Cfm3WB8gVWdReNezxiUopkSJZ/U1atPe2GnzaqFhi4pw== X-Google-Smtp-Source: AGHT+IHwu0DmO9+Vb8FKPNRNao98qk6Srm7ytcm3qpStQoXwzaJOOPoOJwtB4YReJTEoB7C/Rt5m X-Received: by 2002:ac8:57c3:0:b0:42d:cfbe:33cf with SMTP id w3-20020ac857c3000000b0042dcfbe33cfmr13605647qta.60.1709064114345; Tue, 27 Feb 2024 12:01:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709064114; cv=pass; d=google.com; s=arc-20160816; b=cK3GIIjKxRzYxvCz0y76agkyIeQ9LjV39wZLVHLd6XWSVln+2msU2AXpWbMQcgGo2m ySZBWb4DEwJRIrUJDkWP8+lRWthdrCF1sBhTqpApAJqY7QSJ3MTwMixewSiqDbYH6Ctv 0mCrGhjcrO60CjlA/wcxLGUSFPIR3LU+lxoijMY60uk0D3OTcOH3xVWdak6RN5prpkpx 8eT83DLIH5oWui29rNrHWbcCrrRM02voFCqhGalqSACenmLuQ1nLCPF5lXOyV4r7dZuf ELaxmTKgSw4tycmioqBca9Ar5jC9RJXUj96sZy1jxSJc+QMF1HOSITLNsBeG7spdvAcg 5J9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=JCoSqCHOuyJdrEXgcSRyyHnAhXtrU9sHKBBcP3u4W04=; fh=FqMlie4bCqEEl0A02/9H7vL7DuvyQoUGvAaAbaMunbQ=; b=NEgUWCCotnjjDknVO6f3zWTKFfPXou3MauuPoxS3mNtshLvLsSETFprM3Y6a8sxzVq RCcL2+uT7ycPQJTl5JwLvFuNfbRYl5PqO3jyK8C8kGRbSbemCExBDKz3fPTjxvoVqa7E Y9iiH6kC7qlS6L5WVmc9Vxkxk0f0bZ7Xwy/EKZPYONWtyGZ16vnpmKb4i+cCSRBEBNqw 3NmE7PonpCjtH4Wf0GR82k0XzwQmEzoF8zRT4eiHakMPi1xmyNcXZrYGFTwrCL27DIh0 ELoFEvzPQVAH5JPtadBg4latRYkwUUvgV+cSdmKMr0S7MxnCo1Wec5IMo8Kh+DQDD6HL 5hkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=DSnYKMAH; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-83963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j22-20020ac85516000000b0042e26e03beasi8008931qtq.441.2024.02.27.12.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:01:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83963-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=@sifive.com header.s=google header.b=DSnYKMAH; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-83963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com 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 1F3641C20BB1 for ; Tue, 27 Feb 2024 20:01:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4686B14A08B; Tue, 27 Feb 2024 20:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="DSnYKMAH" Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 B3FF514AD07 for ; Tue, 27 Feb 2024 20:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709064098; cv=none; b=QHZNlNkcrL1GxqgReBJtv1tDDlQ7Js3vrwHEl8uKwReP2T/DacVQxTKc+Jem00qO6whv5R3+Q2c20azDO0pCjkZH3M3IXwUNOKPi1vGrHO4DWv27FL/2DkZ3po9GVO5rU3xA+Mtq2+BnDU+IBHxIY7E8UPcqY5kF8ZkJC3rw0lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709064098; c=relaxed/simple; bh=gLyw//m6G9pBImmWZWYlwzKQS/S2+z6YvepUOugVK9s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aw/eCs4d5Xx9RHRJoYnJAk+QezP2K5AUD9LbPhMod1unG4JgLkZB9GNrUJwJrlCnPynK0tR5BShEmzbGlvFE6V4BhCdqhbe5cYCBzMUv3+wYAFueE/lr4E6Ghx98NcK7i8hahL76wxMaHPR2Vjzjz83217XJnrpA09amaKhhDSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=DSnYKMAH; arc=none smtp.client-ip=209.85.166.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-7c788332976so151229439f.3 for ; Tue, 27 Feb 2024 12:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709064096; x=1709668896; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JCoSqCHOuyJdrEXgcSRyyHnAhXtrU9sHKBBcP3u4W04=; b=DSnYKMAHlaMCu9vajPvhP+L1Uwzx2jYVlT5KxViIHh8kwCZeEgZHdhdFFhrZ9HOorQ VbBkqG5t7u4K8IpPYEY2ph9ALnnyBPun3JnyrVtT/t3+wP2bHuh/gIFlR5z7e/QUZnMO WQKMgsGIw2ii9XUIfJcvv/mYrMtbHu7zDpN/07zP0dRDLryup/Q3LGIU2fFJkYnGDYXj 5cd2KsGa/IygzuV6gQvoE0osETFputy3pDM4MkQBJiVq7uxZd6WtzgbDakK2KjD4MjLM Aj1Zk51h2GQpnmJHNhP4JTuWzycEQNqUOBTWX2k0fztLMXMuATam+ZSJ4d/mx7FMqwEo D+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709064096; x=1709668896; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JCoSqCHOuyJdrEXgcSRyyHnAhXtrU9sHKBBcP3u4W04=; b=HZ45Wv8NRkpFU+HYQWjs4c5x+iwCaB5qJqwAkD3A4dbWWQW532vut/RfTFdPEz1W1R S68fW3JytS7HPkk+trZLWxIfIUxdyO3qZp5r649ukiK3ruT4LJWGq5pX53O1kdYZT3nA e7Ez0bIYbT7Yp4eQue0h5lzrtIEmx04IbWElEpv340p3QoceVwo48KgQIdivPvWIN91T WBmaToGJm2EOYZ6qTrX7uC1hFOZpyedE71mrfZSckyVnyaSsGRPYSb4VW5BmyXMa3QI6 8NYF7PhmHY8m8HdrSNuSRybefjWLO3egAAStLzpO/T1wowed1/2W/wjIQd0nQAYAtURk ys3Q== X-Forwarded-Encrypted: i=1; AJvYcCXKkNYgYtO96EFmOZ5TZxVgtvYnG/+pTywZBYB3wpBi5F5pIRk/HvYn2iLnY3LrTHyVy7cNe2KGhL0+8NmpW9jpf9/mVNF5coUWWimA X-Gm-Message-State: AOJu0Yw48TBhSGDSXEVDcun8uqnI3TYX+oWu7Cjp+2q3cP+QwHHi3Gni lArHqL0WU8yup0+LFsp4yVt2jojtJ/rFl65PfFdriHh7uDoZxns0s3IXBGsveyo= X-Received: by 2002:a6b:3f8a:0:b0:7c7:97a0:d2f4 with SMTP id m132-20020a6b3f8a000000b007c797a0d2f4mr11694640ioa.9.1709064095809; Tue, 27 Feb 2024 12:01:35 -0800 (PST) Received: from [100.64.0.1] ([170.85.6.200]) by smtp.gmail.com with ESMTPSA id y90-20020a029563000000b004740d29b120sm1936267jah.111.2024.02.27.12.01.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 12:01:35 -0800 (PST) Message-ID: <33f16905-baab-47e8-a92f-d2543b69d704@sifive.com> Date: Tue, 27 Feb 2024 14:01:34 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -fixes v3 1/2] riscv: Fix enabling cbo.zero when running in M-mode Content-Language: en-US To: Alexandre Ghiti Cc: Palmer Dabbelt , linux-kernel@vger.kernel.org, Conor Dooley , linux-riscv@lists.infradead.org, Stefan O'Rear , stable@vger.kernel.org, Andrew Jones References: <20240214090206.195754-1-samuel.holland@sifive.com> <20240214090206.195754-2-samuel.holland@sifive.com> <20240214-661604d82db4ef137540b762@orel> <579c9f3f-8c28-4e4e-88ce-9f266597b7bd@ghiti.fr> From: Samuel Holland In-Reply-To: <579c9f3f-8c28-4e4e-88ce-9f266597b7bd@ghiti.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Alex, On 2024-02-27 1:48 PM, Alexandre Ghiti wrote: > Hi Samuel, > > On 14/02/2024 10:28, Andrew Jones wrote: >> On Wed, Feb 14, 2024 at 01:01:56AM -0800, Samuel Holland wrote: >>> When the kernel is running in M-mode, the CBZE bit must be set in the >>> menvcfg CSR, not in senvcfg. >>> >>> Cc: >>> Fixes: 43c16d51a19b ("RISC-V: Enable cbo.zero in usermode") >>> Reviewed-by: Andrew Jones >>> Signed-off-by: Samuel Holland >>> --- >>> >>> (no changes since v1) >>> >>>   arch/riscv/include/asm/csr.h   | 2 ++ >>>   arch/riscv/kernel/cpufeature.c | 2 +- >>>   2 files changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h >>> index 510014051f5d..2468c55933cd 100644 >>> --- a/arch/riscv/include/asm/csr.h >>> +++ b/arch/riscv/include/asm/csr.h >>> @@ -424,6 +424,7 @@ >>>   # define CSR_STATUS    CSR_MSTATUS >>>   # define CSR_IE        CSR_MIE >>>   # define CSR_TVEC    CSR_MTVEC >>> +# define CSR_ENVCFG    CSR_MENVCFG >>>   # define CSR_SCRATCH    CSR_MSCRATCH >>>   # define CSR_EPC    CSR_MEPC >>>   # define CSR_CAUSE    CSR_MCAUSE >>> @@ -448,6 +449,7 @@ >>>   # define CSR_STATUS    CSR_SSTATUS >>>   # define CSR_IE        CSR_SIE >>>   # define CSR_TVEC    CSR_STVEC >>> +# define CSR_ENVCFG    CSR_SENVCFG >>>   # define CSR_SCRATCH    CSR_SSCRATCH >>>   # define CSR_EPC    CSR_SEPC >>>   # define CSR_CAUSE    CSR_SCAUSE >>> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c >>> index 89920f84d0a3..c5b13f7dd482 100644 >>> --- a/arch/riscv/kernel/cpufeature.c >>> +++ b/arch/riscv/kernel/cpufeature.c >>> @@ -950,7 +950,7 @@ arch_initcall(check_unaligned_access_all_cpus); >>>   void riscv_user_isa_enable(void) >>>   { >>>       if (riscv_cpu_has_extension_unlikely(smp_processor_id(), >>> RISCV_ISA_EXT_ZICBOZ)) >>> -        csr_set(CSR_SENVCFG, ENVCFG_CBZE); >>> +        csr_set(CSR_ENVCFG, ENVCFG_CBZE); >>>   } >>>     #ifdef CONFIG_RISCV_ALTERNATIVE >>> --  >>> 2.43.0 >>> >> After our back and forth on how we determine the existence of the *envcfg >> CSRs, I wonder if we shouldn't put a comment above this >> riscv_user_isa_enable() function capturing the [current] decision. >> >> Something like >> >>   /* >>    * While the [ms]envcfg CSRs weren't defined until priv spec 1.12, >>    * they're assumed to be present when an extension is present which >>    * specifies [ms]envcfg bit(s). Hence, we don't do any additional >>    * priv spec version checks or CSR probes here. >>    */ > > > I was about to read the whole discussion in v2 to understand the v3...thank you > Drew :) I think it really makes sense to add this comment, do you intend to do > so Samuel? Yes, I am about to send a v4 with the changes from the previous discussion, including a RISCV_ISA_EXT_XLINUXENVCFG bit specifically for the presence of the [ms]envcfg CSR and a comment like the above. Regards, Samuel