From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7DBDC4332F for ; Sat, 5 Nov 2022 05:15:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DF4485148; Sat, 5 Nov 2022 06:15:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 28F1D851F1; Sat, 5 Nov 2022 06:15:51 +0100 (CET) Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DFB08806C9 for ; Sat, 5 Nov 2022 06:15:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peterlin@andestech.com Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 2A55Feld054961; Sat, 5 Nov 2022 13:15:40 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from APC323 (10.0.12.98) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Sat, 5 Nov 2022 13:15:36 +0800 Date: Sat, 5 Nov 2022 13:12:53 +0000 From: Yu-Chien Peter Lin To: Samuel Holland CC: Subject: Re: [PATCH] riscv: Fix detecting FPU support in standard extension Message-ID: References: <20221104112127.30467-1-peterlin@andestech.com> <2d17a8c8-bab5-3c56-0928-d5a81939ec3a@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <2d17a8c8-bab5-3c56-0928-d5a81939ec3a@sholland.org> User-Agent: Mutt/2.2.6 (2022-06-05) X-Originating-IP: [10.0.12.98] X-DNSRBL: X-MAIL: Atcsqr.andestech.com 2A55Feld054961 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Fri, Nov 04, 2022 at 11:39:43PM -0500, Samuel Holland wrote: > On 11/4/22 06:21, Yu Chien Peter Lin wrote: > > We should check the string until it hits underscore, in case it > > searches for the letters in the custom extension. For example, > > "rv64imac_xandes" will be treated as D extension support since > > there is a "d" in "andes", resulting illegal instruction caused > > by initializing FCSR. > > > > Signed-off-by: Yu Chien Peter Lin > > --- > > arch/riscv/cpu/cpu.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c > > index 52ab02519f..dc949c1306 100644 > > --- a/arch/riscv/cpu/cpu.c > > +++ b/arch/riscv/cpu/cpu.c > > @@ -36,6 +36,7 @@ static inline bool supports_extension(char ext) > > #ifdef CONFIG_CPU > > struct udevice *dev; > > char desc[32]; > > + int i; > > > > uclass_find_first_device(UCLASS_CPU, &dev); > > if (!dev) { > > @@ -43,9 +44,16 @@ static inline bool supports_extension(char ext) > > return false; > > } > > if (!cpu_get_desc(dev, desc, sizeof(desc))) { > > - /* skip the first 4 characters (rv32|rv64) */ > > - if (strchr(desc + 4, ext)) > > - return true; > > + /* > > + * skip the first 4 characters (rv32|rv64) and > > + * check until underscore > > + */ > > + for (i = 4; i < sizeof(desc); i++) { > > + if (!(desc[i] - '_')) > > Why not use "if (desc[i] == '_')"? Also, you need to stop at the null > terminator. > > Regards, > Samuel Hi Samuel, Oops, I'll fix this. Thanks for your review! Best regards, Peter Lin > > > + break; > > + if (desc[i] == ext) > > + return true; > > + } > > } > > > > return false; >