Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2822393pxm; Mon, 28 Feb 2022 06:47:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKMyONF5N57tyOtdFCUfN2HG0HxxXJ2ZxzUGOylinVqjRrHyQFNuzunUWH1dP0M/nfRcST X-Received: by 2002:a17:906:a08b:b0:6cf:65bc:e7de with SMTP id q11-20020a170906a08b00b006cf65bce7demr15303313ejy.220.1646059674364; Mon, 28 Feb 2022 06:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646059674; cv=none; d=google.com; s=arc-20160816; b=Ix35vSj3VJSRvuaQLBRY/g+Zjz2LdjoskaDHTpf6og5h9+PGDKwPKq6b7MGpIvUclz ghjpDon5nMGkMrIF3/mR8+XlhWsOJ120EleNVitXRRZATI80F9EVeTICjyT3fi/yeBpb 7OeN6XVhfR7A9myu1OKJJ/CPjYHn5uWBDSpMB2RsG1CKtJT5N+imvb7wEXUpN2bqc/ho lu9y2sw9Kw1/0tQbfdEkMu8Kx6LJ/7YDbwtKy8susN4uGTcRckzUW3vlXF5c3Ae4xS9x 0W6zgzsBkw/rhKzvC1EUzp8DTbEsRNfrEsWjnFGOIk9zXTE5mcWfQI37a0qUdiltTHQz 3Nbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yPvOIdycXQv0CBu7pmocJI7OMI66VIOa7x9qdeQslIs=; b=so+orpCOAOP6cO4bnXfIWtjw5iaR3dM/7Yakg4w3HF7erQzuL9ESixJMnC+GfpEn/6 tuCRSTULv7kv2M2opmbLckRgyvgcze/GF27s6hkpMZuNY+e9YDYBALRPLhzNIyFcjACI AqnOgq6xq0l+IJrRizwIZoMxSsWKDBDMgnKF6ayicSkWlCM1qUL9tkY4GN1Ht4UBcuFx ICwdHK6mYN0MKLdW6JxaOQEFr7CmiaX+5aasW0DdcDL1SQ3CEXtPBcsJwkVuOsBhtIkn 1NA4xZi4k8kKRTM0gZXV8sKu1zuhEWvymFhPHWE60RAOUWFIy3NjfOec4Eeb0LEm6dow K8ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=d53iGwE3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7db4f000000b004132c0a3964si6671299edt.113.2022.02.28.06.47.31; Mon, 28 Feb 2022 06:47:54 -0800 (PST) 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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=d53iGwE3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbiB1KEu (ORCPT + 99 others); Mon, 28 Feb 2022 05:04:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbiB1KEu (ORCPT ); Mon, 28 Feb 2022 05:04:50 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 641E12C650 for ; Mon, 28 Feb 2022 02:04:11 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id v21so14503639wrv.5 for ; Mon, 28 Feb 2022 02:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yPvOIdycXQv0CBu7pmocJI7OMI66VIOa7x9qdeQslIs=; b=d53iGwE3xhZsK5rLeA1vM2S47Vce3tog6ZsY0kRQlxX6tRHqSOExJk2DZvxFv1ociQ 21ui5eSo0k3AxTFOeZQ8c6RVK3YQeRrlv8J6iUxcqkMOoSKr2OvyofAaxJnxCK9mxaxc M9jKBHTJ6N/6ZAvzVqWgaUrkkujnLNznxJIzJDxCEsQ8Hwd3gdhY59hPP4oycPJyQZX1 vFxwUWDwlst2nTwldyDYuLICAZll1WX1ce6qJAo61db967AgmAzskPZLcYbMDUaFAdCc OWlP3PT95GxVyeSza/8UCHWO++xGejdvdlKx4bYKm3JiIAMCvLx5Hi0HqUmSFS13yDru 8+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yPvOIdycXQv0CBu7pmocJI7OMI66VIOa7x9qdeQslIs=; b=oPKd9iEsfUsMgXJMYTq1ZYedc/x0XerCvc8bPFudHYtG9Bs/5lHYFfIg4k9m9ci6YF H0mvAyLeYFyfOv+AfC8hsBhvYN8gvSMq8YzF8G9f2nlzrh7aPTBFx15NOWk68C35Usza SZCKWpejaTdTAwU2oSS9T4ay9jbLVknsNG34mDkYqZWlBBXFy73fQOQvnX40+fg0cKFU 1lHOCaRB/UUILQlxIrHcLsMUvJwAoNi7vZBE5+5d0ZG8peBTZCgMeXkHDNcmFm08l8sh VfVj6Nhut9MycS747QtgEiGWUFgOCkEoLaRguZtEwF1eYDmNf+9ouGV260BfB0bu7Qks q7zg== X-Gm-Message-State: AOAM532XzSS219UAlv+A0jLIQ0ueG540kFKmjHwcX4HqWqvvP6h8Rj6Z 4HkMSsjLGCaNAHCaATd5z7+FwiiTOsOpn8yJL7EQpg== X-Received: by 2002:a5d:64a8:0:b0:1ef:f99c:8c12 with SMTP id m8-20020a5d64a8000000b001eff99c8c12mr174925wrp.214.1646042649763; Mon, 28 Feb 2022 02:04:09 -0800 (PST) MIME-Version: 1.0 References: <20220222204811.2281949-1-atishp@rivosinc.com> <20220222204811.2281949-4-atishp@rivosinc.com> In-Reply-To: <20220222204811.2281949-4-atishp@rivosinc.com> From: Anup Patel Date: Mon, 28 Feb 2022 15:33:51 +0530 Message-ID: Subject: Re: [PATCH v5 3/6] RISC-V: Extract multi-letter extension names from "riscv, isa" To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , Tsukasa OI , Heiko Stuebner , Albert Ou , Atish Patra , Damien Le Moal , DTML , Jisheng Zhang , Krzysztof Kozlowski , linux-riscv , Palmer Dabbelt , Paul Walmsley , Rob Herring Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, Feb 23, 2022 at 2:18 AM Atish Patra wrote: > > From: Tsukasa OI > > Currently, there is no usage for version numbers in extensions as > any ratified non base ISA extension will always at v1.0. > > Extract the extension names in place for future parsing. > > Tested-by: Heiko Stuebner > Reviewed-by: Anup Patel > Signed-off-by: Tsukasa OI > [Improved commit text and comments] > Signed-off-by: Atish Patra Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > arch/riscv/kernel/cpufeature.c | 35 ++++++++++++++++++++++++++-------- > 1 file changed, 27 insertions(+), 8 deletions(-) > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > index 72c5f6ef56b5..b0df7eff47f7 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -124,8 +124,28 @@ void __init riscv_fill_hwcap(void) > ext_long = true; > /* Multi-letter extension must be delimited */ > for (; *isa && *isa != '_'; ++isa) > - if (!islower(*isa) && !isdigit(*isa)) > + if (unlikely(!islower(*isa) > + && !isdigit(*isa))) > ext_err = true; > + /* Parse backwards */ > + ext_end = isa; > + if (unlikely(ext_err)) > + break; > + if (!isdigit(ext_end[-1])) > + break; > + /* Skip the minor version */ > + while (isdigit(*--ext_end)) > + ; > + if (ext_end[0] != 'p' > + || !isdigit(ext_end[-1])) { > + /* Advance it to offset the pre-decrement */ > + ++ext_end; > + break; > + } > + /* Skip the major version */ > + while (isdigit(*--ext_end)) > + ; > + ++ext_end; > break; > default: > if (unlikely(!islower(*ext))) { > @@ -151,14 +171,13 @@ void __init riscv_fill_hwcap(void) > } > if (*isa != '_') > --isa; > - /* > - * TODO: Full version-aware handling including > - * multi-letter extensions will be added in-future. > - */ > - if (ext_err || ext_long) > + > + if (unlikely(ext_err)) > continue; > - this_hwcap |= isa2hwcap[(unsigned char)(*ext)]; > - this_isa |= (1UL << (*ext - 'a')); > + if (!ext_long) { > + this_hwcap |= isa2hwcap[(unsigned char)(*ext)]; > + this_isa |= (1UL << (*ext - 'a')); > + } > } > > /* > -- > 2.30.2 >