Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4107782pxp; Tue, 15 Mar 2022 12:44:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm9VhNF4davhLjLzij6Coxrz4ki6fwm15VPpa860Q5JdborsEaKWMVXpROEkriZNauvrt7 X-Received: by 2002:a17:90a:7181:b0:1bf:a024:ab61 with SMTP id i1-20020a17090a718100b001bfa024ab61mr6403343pjk.200.1647373453569; Tue, 15 Mar 2022 12:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647373453; cv=none; d=google.com; s=arc-20160816; b=TmcK/HgrFRq61t3YpdYb+5VjNoPvc9VmW0ha9TBNncW8TIM99RbM8u/SD5vJCqu3Jq A3bBsD1usKtz2r2gcy09Nuyo3gpGDZG6O4eCHTo5wVv1gfZAa/KGCG7CO9biOY11JNEp TA21S2D4Fp1P+n0vkpgmuouQO0Anxmlhi3ck5USSTULblE36VHTHUlxLmUTwH+sTyU3l pKe5sDnTtDGEmYGIL+hpfF9EPOeaVGe05jXFC6bX/QgTjqFHUDW0O/9j8fd2MF0h+cJr UvXoLNYkQTCBIm+qFOzaFcxiE8LizpakZfsqEeptDSyQznMIBbVOSrxneq9vf1fd18lx AyCA== 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=LEEwRw8+0oWuduV8yqxbjfqDtS7mxY03eu7dCRX8Jmk=; b=li3M7fS2X7oXwd2sVubpuqnrZ6RWBoUP1E/x5mViMbp1DbzyibTd8nZWmnRG7Y/8+i Sda/XvaZNoLx1kJ1LSITY9jQshtKw4WvZVzT6XehjshrKDxX9vGB2JELpbXVnUGYh3uH d9EiSmqh8/yyKUdkcCs1xmNxL4LYM7qY2DknXKsAVNRIZ4kogoO8CMd+5uymiblw39z5 4CA4+QQcqk95so9wc0MbDbQ7p9AcuiobvdwZQWpj0zcaiJICIVLmuhbCs26+yrKwiHjD SXkjR/eD4Ef9NKXqvHSmdvFA9ivKRONcCGJNw2kIncplZF7+l5jTZGeSWaykZGHlSMWW wapA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=D73mRn9q; 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 c18-20020a17090a8d1200b001bd2d2b809fsi2951039pjo.1.2022.03.15.12.43.59; Tue, 15 Mar 2022 12:44:13 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=D73mRn9q; 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 S1344570AbiCODLE (ORCPT + 99 others); Mon, 14 Mar 2022 23:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233712AbiCODLD (ORCPT ); Mon, 14 Mar 2022 23:11:03 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED093EB89 for ; Mon, 14 Mar 2022 20:09:52 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id i6so21774wma.5 for ; Mon, 14 Mar 2022 20:09:52 -0700 (PDT) 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=LEEwRw8+0oWuduV8yqxbjfqDtS7mxY03eu7dCRX8Jmk=; b=D73mRn9qJPT/lNMgz1PI6Ul2I3MQY+JMoB5S5t1vU3cz1uquuRX5ykZbF6gV0j2b07 V4pxr9+sP5cj+BxujKLiC6XGCmpy0EFHXZL4XLtrY+9EEHdzeePt3EeCbhxBna5uRtUO +w9hzl8kSyToqOLNNU/4fCsHPuhg9vfeFQvXt58KVAB5X07oPtgH35or2cG297J/sUVO g1tHrGS+bsejIDsGIerLDZAk3KKVaX8NrmKqkj4v0dzBL3ppuqbIr2TE3T6kAEHKpMjJ 1RyLzDplSxFbkNpJNDghAMLKx81gQx2cNm1UHEAbIM7FyaABoDbW9NGo6W/zJYTH2e7Y uE5Q== 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=LEEwRw8+0oWuduV8yqxbjfqDtS7mxY03eu7dCRX8Jmk=; b=M+fRFyVZ11VEFDI6cMuqLk4NKigWJMdYwVJgZwXjJLZ+eGrRdDR9g/uiTvtkIFMdYU Wr0yVDglX5ASNgLP/yBo0/EWeoqLUWlelHyreZWHuJvxgQiMX2UMsTYoDxiwh/gE0ioh nwBoE/gBeiBykCLVKEG0UO15En+wJ3OhGBHvikWDitwu9ejkT0x4kPPgx2xhJao5xoK1 lmV78zpNL7+FvrK28UrHLGDumeGdtVu2kEUuK8Bt10sGj5xpm1K2kiS253ERnHkKVWnu rXdRpDL6MvwAy+4kXtA89vY9wVjm26lhTgjF4Y+GENWo8EFwS8FHLJPN62+ClzHOutoM 4nQA== X-Gm-Message-State: AOAM533XVuvzHeGA4YYk/Ml0ZTjyznmyXcdz5WNimfKqxcGEMDsLw9xO L/cPIYzaSi22uvU1I3BALb1Jh7dukRN4XSLGdNs3NQ== X-Received: by 2002:a05:600c:3c9c:b0:389:cc3b:9462 with SMTP id bg28-20020a05600c3c9c00b00389cc3b9462mr1529325wmb.105.1647313790542; Mon, 14 Mar 2022 20:09:50 -0700 (PDT) MIME-Version: 1.0 References: <20220314203845.832648-1-atishp@rivosinc.com> <20220314203845.832648-6-atishp@rivosinc.com> In-Reply-To: <20220314203845.832648-6-atishp@rivosinc.com> From: Anup Patel Date: Tue, 15 Mar 2022 08:39:37 +0530 Message-ID: Subject: Re: [PATCH v6 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 Tue, Mar 15, 2022 at 2:09 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 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 3455fdfd680e..a43c08af5f4b 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 >