Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp355181rwr; Thu, 27 Apr 2023 02:11:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Hu3eykbsabTM8QH8exd6KsTmINxFnRxjccs/hEAVKYVIRGi5DRyQIPhYbqRh82crVRAVy X-Received: by 2002:a05:6a00:2d8a:b0:63a:2829:7e33 with SMTP id fb10-20020a056a002d8a00b0063a28297e33mr1424635pfb.0.1682586712991; Thu, 27 Apr 2023 02:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682586712; cv=none; d=google.com; s=arc-20160816; b=Uz4JBT93Us7JJSf6dvazDQdkZPVQWpK+v8l6ZTvdm2rMJO4omd7ad8jKORuMpxlpZq WIU4XMyEgAcwEh2D73I4QsXMw+UpZTSn1pLHzI0A2vEdysm4MIyDDY2HBDlMK4GFdWtO 4kA69frLAnJUKYTkxx4uuc4UjyqoZmC3ThjXi76MiF99+gPkxxu3hzP5RGI2l3qh1V0S GbkYJ/RREAUQBYTbGrj3jwSbzdmMRSOCfHBtNiSbpBuQ/+sOTDk3NjPr/RkqwwzRt6m5 pe3XW2NJ2IW8XhmR4PRE4kXefrKLTRoqhTq/Xa9+Yn7Ug9Xuc/ZddKpI1vUvm6lMNDRU fncQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5+Gi46UcJjNRhre7uiwVmDh5VldgDnwYunLMgeESyJU=; b=0aaOHjqjPHuHnz7rZVA+dVukNAav0n1zrP701t65GqKBmyMJ24P3tjOaqeV6uHg3wD 90HQFdCEsa1xUVZG9Jz9HtnY4gmkz0uyVGiOAn7typHhdq4ywWmqspOpksw510e/Kk7K Olond8Vyst2QmMivobrzXdLr1GG++iDm1Es9rwOWRgg1cx3TWs5shg5CxpRzkD531suP YFp2dy8ekBIPzDcqWJjH30HnbOuoq/rDMzyGdDHMPcQz8K1mDa/SOnpTyg0O2+DO9zOO 3ZIuyDrGPb5G9ByUd3Ba5lWrjpq40cuNUZfJMxKj1415HIJJvuUoei0U3zgn4RD8DUWh NV+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=cah3sDFB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a621b12000000b0063c56e46f9esi17660140pfb.294.2023.04.27.02.11.36; Thu, 27 Apr 2023 02:11:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=cah3sDFB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243249AbjD0JFM (ORCPT + 99 others); Thu, 27 Apr 2023 05:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243126AbjD0JFK (ORCPT ); Thu, 27 Apr 2023 05:05:10 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC95E48 for ; Thu, 27 Apr 2023 02:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1682586297; x=1714122297; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=H/3ifw4Me7ZLmwRnUHcz2Bf1iRNy/a2wlnlif9iRpDc=; b=cah3sDFBb5tTV9Mch1JmUFC33HXv1Y1cPd42PSxtXpQnI1bMsTk2vypb pnYvDmHJ06TMMm4fddRwpCoNjp7f31rSPeLA/48P88xtjAsfh5XrqEz+k 1J/hE2Wof8DMj8FW0aE+AZEHzHba7rHNxDB1AjqcZtyk7dsNW2EhkR/Aj TooXs0CsSUTCoSADm6GMzUNLJMA4aNKJmVyzLqoE8ZHzqY7RMKJKrxN5S 4U9raH+DissYJOJJleY4iPak76Y26ZRDdj7azWKcB05hVIAJgJxDQIX7J 4K4/YHCvOYmJcNHGFt9oereBuyCTMluI1T9kz8QVfMPx4M/yiD4N8jthf g==; X-IronPort-AV: E=Sophos;i="5.99,230,1677567600"; d="asc'?scan'208";a="210933956" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 Apr 2023 02:04:56 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 27 Apr 2023 02:04:54 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 27 Apr 2023 02:04:52 -0700 Date: Thu, 27 Apr 2023 10:04:34 +0100 From: Conor Dooley To: Andrew Jones CC: Conor Dooley , Yangyu Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , , , Wende Tan , Soha Jin , Hongren Zheng Subject: Re: [PATCH 1/2] riscv: allow case-insensitive ISA string parsing Message-ID: <20230427-unveiling-kiwi-631e966f77cc@wendy> References: <20230425120016.187010-1-cyy@cyyself.name> <20230426-porthole-wronged-d5a6a3b89596@spud> <6kjgearxffbnnq4bsqs7e3jz6efz436m6gb3zjh7cfi357oxlv@krxto6orxwwn> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="g9EKRzq+LmoI7/Xs" Content-Disposition: inline In-Reply-To: <6kjgearxffbnnq4bsqs7e3jz6efz436m6gb3zjh7cfi357oxlv@krxto6orxwwn> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --g9EKRzq+LmoI7/Xs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 27, 2023 at 09:53:19AM +0200, Andrew Jones wrote: > On Wed, Apr 26, 2023 at 07:54:39PM +0100, Conor Dooley wrote: > > (+CC Drew) > >=20 > > Hey Yangyu, > >=20 > > One meta-level comment - can you submit this patch + my dt-bindings > > patch as a v2? > > Some comments below. > >=20 > > On Tue, Apr 25, 2023 at 08:00:15PM +0800, Yangyu Chen wrote: > > > According to RISC-V ISA specification, the ISA naming strings are case > > > insensitive. The kernel docs require the riscv,isa string must be all > > > lowercase to simplify parsing currently. However, this limitation is = not > > > consistent with RISC-V ISA Spec. > >=20 > > Please remove the above and cite ACPI's case-insensitivity as the > > rationale for this change. > >=20 > > > This patch modifies the ISA string parser in the kernel to support > > > case-insensitive ISA string parsing. It replaces `strncmp` with > > > `strncasecmp`, replaces `islower` with `isalpha`, and wraps the > > > dereferenced char in the parser with `tolower`. > > >=20 > > > Signed-off-by: Yangyu Chen > > > --- > > > arch/riscv/kernel/cpu.c | 6 ++++-- > > > arch/riscv/kernel/cpufeature.c | 20 ++++++++++---------- > > > 2 files changed, 14 insertions(+), 12 deletions(-) > > >=20 > > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > > > index 8400f0cc9704..531c76079b73 100644 > > > --- a/arch/riscv/kernel/cpu.c > > > +++ b/arch/riscv/kernel/cpu.c > > > @@ -4,6 +4,7 @@ > > > */ > > > =20 > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -41,7 +42,7 @@ int riscv_of_processor_hartid(struct device_node *n= ode, unsigned long *hart) > > > pr_warn("CPU with hartid=3D%lu has no \"riscv,isa\" property\n", *= hart); > > > return -ENODEV; > > > } > > > - if (isa[0] !=3D 'r' || isa[1] !=3D 'v') { > > > + if (tolower(isa[0]) !=3D 'r' || tolower(isa[1]) !=3D 'v') { > > > pr_warn("CPU with hartid=3D%lu has an invalid ISA of \"%s\"\n", *h= art, isa); > > > return -ENODEV; > >=20 > > I don't understand why this is even here in the first place. I'd be > > inclined to advocate for it's entire removal. Checking *only* that there > > is an "rv" in that string seems pointless to me. If you're on a 64-bit > > kernel and the node has riscv,isa =3D "rv32ima" it's gonna say it is ok= ay? > > Drew what do you think? >=20 > It makes some sense to me as a garbage detector. It's unlikely the first > two bytes will be "rv" if the string is random junk. Preventing the input of absolute rubbish is dt-validate's job & if the dtb itself has been corrupted somehow I suspect that we have bigger problems than checking for "rv" will solve. > also do a strlen(isa) >=3D 4 check first, though. of_property_read_string= () > will succeed even when the string is "". I don't think that checking that there are at least 4 characters isn't even sufficient. Either we should confirm that this is a valid riscv,isa to run on (so rv##ima w/ ## matching the kernel) or not bother at all. It's a different issue though, and I'd be inclined to revisit it in the future when the ACPI stuff is in, along with perhaps the cleanup parts of Heiko's series too. --g9EKRzq+LmoI7/Xs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZEo6ogAKCRB4tDGHoIJi 0tBzAP9Gjrxk70KxyJ3D82eZXdg5mq4oq9mwEu5UuYkAARPQawD/U/mk5q1Wts6h 7VXEioB99Mb4kdKQojdZuCuYnvN6lAU= =IMRq -----END PGP SIGNATURE----- --g9EKRzq+LmoI7/Xs--