Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2622564pxm; Mon, 28 Feb 2022 02:55:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJybaJ0Gt2al7bkMERI5k39RNw5iictyBcW1Yq5rqIbsSNUOH63qPOyqQi9qM6TuxbOGC4qp X-Received: by 2002:a05:6402:70d:b0:410:ba4d:736f with SMTP id w13-20020a056402070d00b00410ba4d736fmr18577912edx.0.1646045738236; Mon, 28 Feb 2022 02:55:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646045738; cv=none; d=google.com; s=arc-20160816; b=Ypv6UUkzY7s1YPUBgud7daQneGpT/KON/xV1aVD0trVedPF73PGZgxIiSGa+N10EJf OByM12o6SQlIbecJUiZ++3EE0NCtP1amwhXTD4fmj74uNDy4DYVpHE6gcUeKtec1JPDl agXF3J9Sz09vNIGafYCIf7TLHvHVQV6JydQuTiGPmOl/kJgwVLUMzP2H1oG2aPur6HeS NItw5iIoZuyjOD770k/DDSSBy5rgrtW+e4H31Q2RzOtTtx+kEgxbaE9HoQdcbc2EuNT8 lyQUBSGUM/BaQDeC0BvsRgJDHiIgKeC4yOdWWLTLmG9DlujeAt1cDICgijDg1xj0wjnQ 3EgQ== 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=AnO7RJd7lIaXKXrGVfiV/DsRScB6mJSjgNzjp2pSS5E=; b=dHI/28E23OLl3vpiSVYUh2qaOIUSnOPX5a0ZFV9zzDWBKEVb3Ch6pe2Nj/l0OVUJs6 mP+9N5tt4k/WWENpNlYjmReXiqmgwLc7KNq82MV/6H//K3/GHI8RKYQzbIqGUIRAgnDP WOtUF2RTd03NHXa2pt2zNPCAILlEBbanv59VphEzUFYGSK4Yy1tRPouf3R5aXTQ6d4XN Vk1wA74RaRmYjn+xUQuWN7pYf+VUFoMUT3WGbIPHq8Selela9T+ceghmBk+nGrfRIl9a Y4VlKU9kplaN7XaGLpxT9dv/tb63CGq3/R0pih45SCqvviAt8MRldUH0/0QIHXw1Ih6u cv0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=7c66SOwY; 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 p3-20020a1709060e8300b006cf6504d1a3si5238682ejf.705.2022.02.28.02.55.15; Mon, 28 Feb 2022 02:55:38 -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=7c66SOwY; 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 S234708AbiB1KH7 (ORCPT + 99 others); Mon, 28 Feb 2022 05:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234649AbiB1KH5 (ORCPT ); Mon, 28 Feb 2022 05:07:57 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C37531226 for ; Mon, 28 Feb 2022 02:07:19 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id d17so14488637wrc.9 for ; Mon, 28 Feb 2022 02:07:19 -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=AnO7RJd7lIaXKXrGVfiV/DsRScB6mJSjgNzjp2pSS5E=; b=7c66SOwY/5D6ac4Gr2dhD7c1d55xW30W4PtBtluMV01alcTFMgytmQio0L2BKqun4w 9qH8cgBStRaEJQx4YfunkHdz5E8/LsW9HkXkoQH7wGtqB03DUnGqMJnDmgvcCmVzZR5b SgWCEUZr/tWTN2o25v+mtJyA/uYE3BAFJAoDNP54vZurfkR5WHIlwfxaXZQMIskQkrvx uAQNcDzTR/KrwuPJS+7cE5KZxeusc/zHFEAYEQMldl1iYfM43jQf0GUbFJsIk7QDfEIW /N6ezzl5t1Dg+dkPm9LLIkS/fPinvJzH7luFkXXqFoAvrlIfeP+yoTV6cv1MS6jeOb6y rL7g== 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=AnO7RJd7lIaXKXrGVfiV/DsRScB6mJSjgNzjp2pSS5E=; b=w3Bx4qlPFIcSTv3gH1Nj5BweOyxANQIzuUJ9A0R0fD/4G15hXbQVfuFx80g9LZhbvt +yWTHPiq490ZJkMWONNgRy7JwXH+x39JJ0TQ5pa0dOKgOMr53+/l1e+TN77Gkcdy/Geo v94ls8Wiuf7Ii5XkPGB/7hgOJqZgmbs6zCC1b3T7NVZ+r6Eb2Fhkg3N6yxkt5aodyank k9UllekCBBY+BmvL+u3k77dKxKMkQmnn/w+miGum9hLKgYwmQm2Q8Pu4sREqemTewWJF 5kB98ZP/3H2nl9ozi0nicBcpKVuDh78Oz/zji0VeZ7nU0JsxAU9kJQoM11Q+LHvUqsht 255g== X-Gm-Message-State: AOAM531QsLzyeM7i2p4bqp0hgp4CMexE4K9NiMGk6ZLidzeNBF2EL8/3 YWeWXHVPxt25h6lealWIhcliuxWaA243RlVWDwl5KQ== X-Received: by 2002:adf:b645:0:b0:1e3:bab:7594 with SMTP id i5-20020adfb645000000b001e30bab7594mr15213752wre.346.1646042837663; Mon, 28 Feb 2022 02:07:17 -0800 (PST) MIME-Version: 1.0 References: <20220222204811.2281949-1-atishp@rivosinc.com> <20220222204811.2281949-6-atishp@rivosinc.com> In-Reply-To: <20220222204811.2281949-6-atishp@rivosinc.com> From: Anup Patel Date: Mon, 28 Feb 2022 15:36:59 +0530 Message-ID: Subject: Re: [PATCH v5 5/6] RISC-V: Do no continue isa string parsing without correct XLEN To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , 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: > > The isa string should begin with either rv64 or rv32. Otherwise, it is > an incorrect isa string. Currently, the string parsing continues even if > it doesnot begin with current XLEN. > > Fix this by checking if it found "rv64" or "rv32" in the beginning. > > Tested-by: Heiko Stuebner > Signed-off-by: Atish Patra Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > arch/riscv/kernel/cpufeature.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > index c6693873e95c..f3a4b0619aa0 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -84,6 +84,7 @@ void __init riscv_fill_hwcap(void) > for_each_of_cpu_node(node) { > unsigned long this_hwcap = 0; > DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX); > + const char *temp; > > if (riscv_of_processor_hartid(node) < 0) > continue; > @@ -93,6 +94,7 @@ void __init riscv_fill_hwcap(void) > continue; > } > > + temp = isa; > #if IS_ENABLED(CONFIG_32BIT) > if (!strncmp(isa, "rv32", 4)) > isa += 4; > @@ -100,6 +102,9 @@ void __init riscv_fill_hwcap(void) > if (!strncmp(isa, "rv64", 4)) > isa += 4; > #endif > + /* The riscv,isa DT property must start with rv64 or rv32 */ > + if (temp == isa) > + continue; > bitmap_zero(this_isa, RISCV_ISA_EXT_MAX); > for (; *isa; ++isa) { > const char *ext = isa++; > -- > 2.30.2 >