Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp78016rdh; Tue, 13 Feb 2024 09:54:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVfcZ8OShYqIN6EQ37U7Hgyxu+s+dxh5d2mO+aJpo88P8Dli/8+GA7O+xY8417/aGWOhRgdt5lIJbeoboJk5Cak0SqXWGnf4mDs+4F+KA== X-Google-Smtp-Source: AGHT+IHOTaJSuJt0OAQZobtRXlK+dNHXY3EvRBNqVlOtS5eN/tYBCkNQipiw4ZabYvOs904JO+BW X-Received: by 2002:a17:906:3718:b0:a3d:1edf:f9bb with SMTP id d24-20020a170906371800b00a3d1edff9bbmr68570ejc.1.1707846845934; Tue, 13 Feb 2024 09:54:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707846845; cv=pass; d=google.com; s=arc-20160816; b=zBE11dbtrw6EdboIl60oDoFFiY5+DXwsCmRBlOyW+to0Zgf0mXj/Ee7T9fAT6YqLyh 8rqpV5SsiEHxtZ+tUrZxQJYawS9ai1bhwGixt3BGHm1VNYk0wJqrGx9Wwm16F6kaaizC f7WYx4/ZvwuEojQV16n4sS3vLWzAUV4HRD+JMysTOenVAdakA03wJ67xuLOiRs/f0e6q fFhYmoXr/oAz+yeYY7yy+6nFY20eSbkcVXj36P6BK0odvBlQj4w73r1ugWjS/w1IACw7 FN/m6rsOGVDDVVZNlUZQjMORhL7w2kTTJBk4cttYhA3QsZtTUyDb4Gq0PBvf0uqmGqaU rXjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=8mleJuj679ygYILvbygRdHtWVUTucGcTJaSJeTlmfSc=; fh=FdQzKdyGCvYH8L4KXdvDyTZ64JWDnG0YfmNM+AxS7S4=; b=TY4Evly6rw/vbpQlFxVh1T5RkgceFTSb5mMqaqQov+cX1VDoCz227cApFtgY2JoB0L Mm1hn5YmmNAhzWFOyoaByMEr0Go351MYsfkclKMN3I+R1s0+B3x3GfZE8ljLJNIfdNM2 RQWOVJpDMyF++mfzZ9lfyxcBfOICLiD6+nKtu7g1dUd9QztiSQWhiScIdtOVBbAyritr jHYsrWFO0EyB/lj/bqt3VbERzOuepIvJrKPX47teI45RJwLlDeWAJFYuuCosOh80irIR 8qKtH2ZvZt7siZBK0zdIuDRykHO4+pY48ZIY0W1ALmD+mpZRNsnTpeJnrE3CWG4DrX4x HsPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fastmail.com header.s=fm3 header.b=0Y7ohKHl; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H1eVfOT8; arc=pass (i=1 spf=pass spfdomain=fastmail.com dkim=pass dkdomain=fastmail.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=fastmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64017-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.com X-Forwarded-Encrypted: i=2; AJvYcCVPdzI+Q6ESot8KUiYleByX8NKr+iyKuCY7GTFFY1AL1kUwRxbakQasxSH/Z5HSFXczkSxQYWJ0P6mvEsllx8hg4Fat6prFrj3axWtFSQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o6-20020a170906358600b00a3820b34ad1si1476941ejb.389.2024.02.13.09.54.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 09:54:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64017-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@fastmail.com header.s=fm3 header.b=0Y7ohKHl; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H1eVfOT8; arc=pass (i=1 spf=pass spfdomain=fastmail.com dkim=pass dkdomain=fastmail.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=fastmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64017-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9F5301F24A43 for ; Tue, 13 Feb 2024 17:54:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20380605C5; Tue, 13 Feb 2024 17:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fastmail.com header.i=@fastmail.com header.b="0Y7ohKHl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="H1eVfOT8" Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (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 53052605A6; Tue, 13 Feb 2024 17:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707846819; cv=none; b=Y3ZRSjmGxKhG9LV9jDM6tRPvGXgnw0qgndM0iRtjmZPer9NoSr5KPi6XveIGu79c2Ngu0mKMV8YaUa/db8p25PPkIFjTi0/ot2r+VbepLvaPxkvcwAXh8bW5h0OGS8qXxS3aM8avnxPLg6OidqiLZ66yEwB5PgcZ4gBVkU/pvuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707846819; c=relaxed/simple; bh=bIx87ZWq9KbmlT/JzqFTsMtpo1cfuGEVBiegMksFiPg=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=QhnXJkydkXkUDdl+l8gTHrQ6wbaH6SLF2CR6J1GWhlbsMqXX4VJheKTRS8B0msCiJQsn52pSL1ioTxc9WIYos5VbN5/4RorHSdWjbK2lMTuPtghDcf1nqg4c8sJsnHo5RYjhbUJiS6ePfQTJAkmgf06sibBRpUdEZKSMSFNik6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com; spf=pass smtp.mailfrom=fastmail.com; dkim=pass (2048-bit key) header.d=fastmail.com header.i=@fastmail.com header.b=0Y7ohKHl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=H1eVfOT8; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.com Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 3EDDB1380117; Tue, 13 Feb 2024 12:53:36 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute3.internal (MEProxy); Tue, 13 Feb 2024 12:53:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1707846816; x=1707933216; bh=8mleJuj679 ygYILvbygRdHtWVUTucGcTJaSJeTlmfSc=; b=0Y7ohKHlcN0B2CiZQYA9AC5ENc Zv/8+O8gMIzzih9c+jerfLp5GbyaTjP8s1mZ7qfRnYtEWhsJ2mRLplEd8Dnt9zJd G6Y6zRK/e7u5hIzQ2P37ptDWM51obLZ9ipfY+VSSf5sYdwY5pccTAFhGfhWQS6JA iqp/KdeuECcXeIVKyR7KrMMOAVIZADFrsMG/tg8F1APG5g4uycEHXAwU9utt+TUJ 3NwaLPY6CYuRtkmxDu9oFFe3DxTBIvftD0K55zl0L8DGuhzleWqkO+yOMJw8IiLq SO4+IDUsC2zEecFEdbg7CmZQfmX4bOAk6d1shiMs+gRZT9kDWTEvn7pr+3/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1707846816; x=1707933216; bh=8mleJuj679ygYILvbygRdHtWVUTu cGcTJaSJeTlmfSc=; b=H1eVfOT89hwGomwg92IfjH45ZXEHrY7WWx3vPo4QQ+9a e7ibPHKThKuzxp/ouyDdMN7zjowHIIH/96bFRvqGqPXKWW0HbXc4jyynVufsEjxs dRUMN31OUnMkWhqDCNjWs/Cx+ZwkMdGjHIju2hmenKe25L3zk3pkv3aG+xpQvNXQ yYEL2dzpHrxQZtufAB4KMnOlKBamDeHrDzgjH7VwWFNPqecQt4MxzTzAkj9LPG6w MYnwswea+qYSy9GMGKCKbH7IwMzRkCgraMhmA41oqG6Gt5NqiIOGWd5UiSgPTQuI dgXevKTg9HMPnhHR2jp2WP11dHU6ez9/vO3+XyNaFA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehgddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedfufht vghfrghnucfqkdftvggrrhdfuceoshhorhgvrghrsehfrghsthhmrghilhdrtghomheqne cuggftrfgrthhtvghrnhepjeeuheegtdeuteeghfehjeejiefghfeifeejheduvdeugedt hfehvefggefgkedtnecuffhomhgrihhnpehinhhfrhgruggvrggurdhorhhgnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhorhgvrghrsehf rghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i84414492:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F154A1700096; Tue, 13 Feb 2024 12:53:35 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <937f0593-0bc8-4df3-aa0e-9059acfd7636@app.fastmail.com> In-Reply-To: <20240213-86af3b49821630b5bdd76c0a@orel> References: <20240213033744.4069020-1-samuel.holland@sifive.com> <20240213033744.4069020-5-samuel.holland@sifive.com> <20240213-86af3b49821630b5bdd76c0a@orel> Date: Tue, 13 Feb 2024 12:53:15 -0500 From: "Stefan O'Rear" To: "Andrew Jones" , "Samuel Holland" Cc: "Palmer Dabbelt" , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH -fixes v2 4/4] riscv: Save/restore envcfg CSR during CPU suspend Content-Type: text/plain On Tue, Feb 13, 2024, at 9:49 AM, Andrew Jones wrote: > On Mon, Feb 12, 2024 at 07:37:35PM -0800, Samuel Holland wrote: >> The value of the [ms]envcfg CSR is lost when entering a nonretentive >> idle state, so the CSR must be rewritten when resuming the CPU. >> >> Cc: # v6.7+ >> Fixes: 43c16d51a19b ("RISC-V: Enable cbo.zero in usermode") >> Signed-off-by: Samuel Holland >> --- >> >> Changes in v2: >> - Check for privileged ISA v1.12 instead of the specific CSR >> - Use riscv_has_extension_likely() instead of new ALTERNATIVE()s >> >> arch/riscv/include/asm/suspend.h | 1 + >> arch/riscv/kernel/suspend.c | 4 ++++ >> 2 files changed, 5 insertions(+) >> >> diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h >> index 02f87867389a..491296a335d0 100644 >> --- a/arch/riscv/include/asm/suspend.h >> +++ b/arch/riscv/include/asm/suspend.h >> @@ -14,6 +14,7 @@ struct suspend_context { >> struct pt_regs regs; >> /* Saved and restored by high-level functions */ >> unsigned long scratch; >> + unsigned long envcfg; >> unsigned long tvec; >> unsigned long ie; >> #ifdef CONFIG_MMU >> diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c >> index 239509367e42..be03615486ed 100644 >> --- a/arch/riscv/kernel/suspend.c >> +++ b/arch/riscv/kernel/suspend.c >> @@ -15,6 +15,8 @@ >> void suspend_save_csrs(struct suspend_context *context) >> { >> context->scratch = csr_read(CSR_SCRATCH); >> + if (riscv_has_extension_likely(RISCV_ISA_EXT_Sx1p12)) >> + context->envcfg = csr_read(CSR_ENVCFG); >> context->tvec = csr_read(CSR_TVEC); >> context->ie = csr_read(CSR_IE); >> >> @@ -36,6 +38,8 @@ void suspend_save_csrs(struct suspend_context *context) >> void suspend_restore_csrs(struct suspend_context *context) >> { >> csr_write(CSR_SCRATCH, context->scratch); >> + if (riscv_has_extension_likely(RISCV_ISA_EXT_Sx1p12)) >> + csr_write(CSR_ENVCFG, context->envcfg); >> csr_write(CSR_TVEC, context->tvec); >> csr_write(CSR_IE, context->ie); >> >> -- >> 2.43.0 >> > > We're still exposing Zicboz to userspace in hwprobe when only > RISCV_ISA_EXT_ZICBOZ is present, which will be the case for anything that > either doesn't implement 1.12, but does implement Zicboz, or maybe does > implement 1.12, but hasn't started putting Ss1p12 in its ISA string yet > (e.g. QEMU). We should either stop exposing Zicboz to userspace in those > cases (since it won't work) or rethink how we want to determine whether > or not we have envcfg CSRs. opensbi treats the existence of menvcfg as sufficient evidence to prove that the hart supports 1.12. I wouldn't object to having Zicboz imply Ss1p12/Sm1p12. -s > Thanks, > drew > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv