Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp757734pxp; Wed, 16 Mar 2022 16:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPFHoTv+J5o9jZs+HfMDiZ+gscj0ayO4vS9pl7drVuKu5g7lR3KelZSMtOE8npg5B9u0tj X-Received: by 2002:a17:903:1ce:b0:150:2117:16b3 with SMTP id e14-20020a17090301ce00b00150211716b3mr2295550plh.26.1647473091520; Wed, 16 Mar 2022 16:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647473091; cv=none; d=google.com; s=arc-20160816; b=Le61TFiJp2mg3rPrQYIiHO4gGrVPl/inljrhXm6YpbqD4bCHwnMYzRe8UXAqh9zcJ7 ZI3wXzClIiNFd+PvvvWulLDUcxYdL9ocBo1WUaIEFWEjNapY/H1x1VLzpv+Qgh3dmsQ7 f1cQd9IK3DjFmkdkRKOYspVJAGNau30+nCRW2dPoNFXspJPX+Fx5p2qjCRqabhMzJ+N4 GegvieCV7dkmeVeBEi1TD6voUTV7yUu6VALAfCrU5zxgbCTzhYB+15a+6Y3WYdy439+9 jV+/i1R/UdBpBauCHDvAiz6PLHIITaa1sGks/pysFr7k+P/QpSWR8OieGIYKNJSNFj/S 3/eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iS9w0OaNOwq2lVntX7Egw8nvc58/BIqmU/Sn5pstZMs=; b=zD2CXrCdE/BEOgyCQnEC1C8Xdxm9k6W/EC0vZbD9sjYtXkqmpKmTeMZM7wPOJ2NYXi TymDzjtaKTDf4WUW17PQFdiSd6b+0IMtWwVAd3yGzVvVM1UEj3uFdTaTNGyh0MGCFJDh W+qJRcRTMeYBzFOFeWHnjV6zmXCinrnaTBzWiUqwWhTivHJX9U1B76a+8yvp4xClpxz6 FOt4tkJpGrIw7J5dtXh7EP0vpxCzJrgJbFqa0fRI1PV2P9mkBGXet0ZrzCimksXloJsQ zCoNwCwh6ENs51SuPItrFPKA7+nH3I7liCsXnAp+U2ZCxrfQ7xEzxdSXoF/sjzNsBVR3 8S4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=J1u1mo5R; 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 z18-20020a170903019200b00151840f9b71si3533732plg.294.2022.03.16.16.24.37; Wed, 16 Mar 2022 16:24:51 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=J1u1mo5R; 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 S245085AbiCNUkQ (ORCPT + 99 others); Mon, 14 Mar 2022 16:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245068AbiCNUkN (ORCPT ); Mon, 14 Mar 2022 16:40:13 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C48739825 for ; Mon, 14 Mar 2022 13:39:02 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id s16so13860891qks.4 for ; Mon, 14 Mar 2022 13:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iS9w0OaNOwq2lVntX7Egw8nvc58/BIqmU/Sn5pstZMs=; b=J1u1mo5RTmgXNbrfgwFkTpTBTCeG52RUdgQLYIOwlkQUNknzurIy6+GGvvcZXSWiLj 258uDYkHGO11XTf8680JctynowTt+FLeqeGfy/ic1OP1weDl7Y0vYg+Ztpxl8I9lJoh4 +6VB2xfNOq2j1lXC+uvSbeNWsEII1X668sYtnPAIIOPfDTItK+mxrg0krcuPqpiI0r2j zq81+lWc1U+Jj70SklpzoXnlFdQ9Nj+w/dTSSobJgYtpzmw6pzFB3maNdWQqej5UxR1U y9CNXLH6DHZnZelBEg8/HTIjMZSuJpMfwEv7niu2i8l2J+yZNLWqrR2uNUvFFmXToFfT a4fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iS9w0OaNOwq2lVntX7Egw8nvc58/BIqmU/Sn5pstZMs=; b=1+a5p9YXJ+z8KBgXg6Q2PvVW38qeXnOtj0TtxiSwTcl63GkWiX/izwNVxchu68+GDW DNRgtXhyPxhZfRa8EXXbtgASzyBeTCcsDWwCa/Ox1iGkZ+gswBS8xgKoyGo5hw9mEERq ylD2i9U7ah1Ug+2qc2d+wI35HFuyJ8CgdkzJm1tvAlAlMvsxYeu8EJF+WKCqQHtLmdwp Mapysfye94C7rwTTU2K54wf9ESesOBM1kMJTwkDw2m0xF8bFZy4mbJh/BSCoV7TxYdgw b4RXEkD51/TMXpBUzI3+yYy+M52cLjtm4il2RVvB9fKZdLL8bGhSz6Q+3j4KkxSUr8KZ /aog== X-Gm-Message-State: AOAM530mMcIQ0DaJY04vXzNMHO2i3aL+/KxDPwdPv6tkVZllmycj02DR lbOFBCFacsPKoasPTSATJqytoB63FWVG/g== X-Received: by 2002:a05:620a:2584:b0:67b:3209:96ec with SMTP id x4-20020a05620a258400b0067b320996ecmr15883646qko.755.1647290341311; Mon, 14 Mar 2022 13:39:01 -0700 (PDT) Received: from rivos-atish.ba.rivosinc.com (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id j188-20020a3755c5000000b0067d1c76a09fsm8597023qkb.74.2022.03.14.13.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 13:39:00 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Tsukasa OI , Anup Patel , Heiko Stuebner , Atish Patra , Albert Ou , Atish Patra , Damien Le Moal , devicetree@vger.kernel.org, Jisheng Zhang , Krzysztof Kozlowski , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Rob Herring Subject: [PATCH v6 1/6] RISC-V: Correctly print supported extensions Date: Mon, 14 Mar 2022 13:38:40 -0700 Message-Id: <20220314203845.832648-2-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220314203845.832648-1-atishp@rivosinc.com> References: <20220314203845.832648-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_PASS, 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 From: Tsukasa OI This commit replaces BITS_PER_LONG with number of alphabet letters. Current ISA pretty-printing code expects extension 'a' (bit 0) through 'z' (bit 25). Although bit 26 and higher is not currently used (thus never cause an issue in practice), it will be an annoying problem if we start to use those in the future. This commit disables printing high bits for now. Reviewed-by: Anup Patel Tested-by: Heiko Stuebner Signed-off-by: Tsukasa OI Signed-off-by: Atish Patra --- arch/riscv/kernel/cpufeature.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index d959d207a40d..dd3d57eb4eea 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -13,6 +13,8 @@ #include #include +#define NUM_ALPHA_EXTS ('z' - 'a' + 1) + unsigned long elf_hwcap __read_mostly; /* Host ISA bitmap */ @@ -63,7 +65,7 @@ void __init riscv_fill_hwcap(void) { struct device_node *node; const char *isa; - char print_str[BITS_PER_LONG + 1]; + char print_str[NUM_ALPHA_EXTS + 1]; size_t i, j, isa_len; static unsigned long isa2hwcap[256] = {0}; @@ -133,13 +135,13 @@ void __init riscv_fill_hwcap(void) } memset(print_str, 0, sizeof(print_str)); - for (i = 0, j = 0; i < BITS_PER_LONG; i++) + for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++) if (riscv_isa[0] & BIT_MASK(i)) print_str[j++] = (char)('a' + i); pr_info("riscv: ISA extensions %s\n", print_str); memset(print_str, 0, sizeof(print_str)); - for (i = 0, j = 0; i < BITS_PER_LONG; i++) + for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++) if (elf_hwcap & BIT_MASK(i)) print_str[j++] = (char)('a' + i); pr_info("riscv: ELF capabilities %s\n", print_str); -- 2.30.2