From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C06FD326924 for ; Tue, 25 Aug 2026 17:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787677914; cv=none; b=IxPsYDH7e4HD4Bu+nVRSW/xq0grgPeugu21Nrn/fheO1YLguiOLYunG9r5SAIiAqR0c+zR6ymtqqNrjkJUANFRuV+pDD3HwZ240DrD8dgGbPQsz3gI+wx0EdzLxhNy1yxSXB23Um3OXWMjEr3hVosMieYTBwdxhg/5zcWNXMzNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787677914; c=relaxed/simple; bh=g5UNxXmg5cAeaRTceZJZHhPIr5+UWGQJrpzRUQhbnk4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZTC3ANqksqIPCrkmcIUNCSjS5s7tNjy4Gb036dekNVU1rapnnR+/AyRSNcx0+19+03Uq25VptBRvy454Cx0U7dvyXUETsL7TP0bEjJ28PRncmAy++AYt3vz4ffmWiggXu5Lobg4+iBNXl6ntpPgDw2co25C3mecNYbaLWtsDgDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fVIgfkrh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fVIgfkrh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EDC11F000E9; Tue, 25 Aug 2026 17:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787677913; bh=YgNzfthrPLgt/ZxHWpTZNFzsuzDY2DE9pgpiEHo8naA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=fVIgfkrhDrXmR0hMwMHBVIvYbUWO2ZA9gkfT/roB2Y6/MLQnzI+awK1qS8sfEwwzd 6u3GNEs5AnMGT03YOTCKt3jN9lAHMdLMs7kAbF9aJ1eqm/cym+c8xXDULHFYkAZ9aK Ke2AOuIOK84CtjT59BZuaZCmez7kkZPZGyfy4Xl7q7CKiEGlRuUSczaigRRhYJXWWu 9hJ4+zBkszUQ8OM3IRc/uelUaY0f9YCiijHFGxmr16Arpm4rEZZJvS/8lxOFrTrCoL tCQHS9YZMRZWvkXUCcjXNGzmLYZIp7sPjXvL8auwGulMfVY5ptmjKfIBGFbe19HqZf E3lDVXoJZdGFA== Date: Tue, 25 Aug 2026 18:11:49 +0100 From: Conor Dooley To: Ivy Lopez Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, andrew.jones@oss.qualcomm.com, conor.dooley@microchip.com, schwab@suse.de, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] riscv: hwprobe: fix has_fpu() to require D extension only Message-ID: <20260825-essay-flashily-8df1f3d9a615@spud> References: <20260816003216.22534-1-skunkolee@gmail.com> <20260825142034.31230-1-skunkolee@gmail.com> 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-sha512; protocol="application/pgp-signature"; boundary="uHLKe7TsjCFlo9+n" Content-Disposition: inline In-Reply-To: <20260825142034.31230-1-skunkolee@gmail.com> --uHLKe7TsjCFlo9+n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 25, 2026 at 08:20:34AM -0600, Ivy Lopez wrote: > The kernel never supports F without D, since D depends on F. As such, > has_fpu() checking either extension with '||' is incorrect: it > reports FPU support when only F is present, which is not sufficient > for D-dependent state save/restore, and weakens > RISCV_HWPROBE_IMA_FD semantics to "F or D" instead of "F and D". >=20 > Fix has_fpu() to check D only, which is equivalent to requiring both > extensions given the dependency. Revert the explicit F && D check in > sys_hwprobe.c back to calling has_fpu(), which is now correct. >=20 > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D221874 > Suggested-by: Conor Dooley > Suggested-by: Andreas Schwab > Signed-off-by: Ivy Lopez > --- > Changes in v2: > - Original v1 approach (explicit F && D check in sys_hwprobe.c) was a > no-op since F-without-D is structurally impossible. Per Conor and > Andreas, fix has_fpu() itself instead, checking D only. Revert the > sys_hwprobe.c change back to calling has_fpu(). > - Link to v1: https://lore.kernel.org/r/20260816003216.22534-1-skunkolee@= gmail.com This v2 looks like a diff on top of your v1, but your v1 didn't get applied (AFAIK) so this patch doesn't make sense. > arch/riscv/include/asm/switch_to.h | 4 ++-- > arch/riscv/kernel/sys_hwprobe.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/= switch_to.h > index 0e71eb82f920..8186cda88e17 100644 > --- a/arch/riscv/include/asm/switch_to.h > +++ b/arch/riscv/include/asm/switch_to.h > @@ -60,8 +60,8 @@ static inline void __switch_to_fpu(struct task_struct *= prev, > =20 > static __always_inline bool has_fpu(void) > { > - return riscv_has_extension_likely(RISCV_ISA_EXT_f) || > - riscv_has_extension_likely(RISCV_ISA_EXT_d); > + /* D extension depends on F, so checking D alone is sufficient. */ > + return riscv_has_extension_likely(RISCV_ISA_EXT_d); > } > #else > static __always_inline bool has_fpu(void) { return false; } > diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwpr= obe.c > index 7f91beb82a1c..1659d31fd288 100644 > --- a/arch/riscv/kernel/sys_hwprobe.c > +++ b/arch/riscv/kernel/sys_hwprobe.c > @@ -85,7 +85,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, > u64 missing =3D 0; > =20 > pair->value =3D 0; > - if (riscv_isa_extension_available(NULL, f) && riscv_isa_extension_avail= able(NULL, d)) > + if (has_fpu()) > pair->value |=3D RISCV_HWPROBE_IMA_FD; > =20 > if (riscv_isa_extension_available(NULL, c)) This second portion should be dropped, since it is a reversion to how things were before. Additionally, please don't submit new versions as a reply to old ones. Thanks, Conor. --uHLKe7TsjCFlo9+n Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCao3M1QAKCRB4tDGHoIJi 0qgmAQC/hiOuEjHspWrysb8INLzRB8p+7uvuyEv/2sgxOAuWOQEAvkfRe8gte6xL iJ7IsVpIiUGoKfw9aIR7R14Hr1M3TQs= =fZVf -----END PGP SIGNATURE----- --uHLKe7TsjCFlo9+n--