X-Received: by 2002:a17:90a:9b08:b0:1bc:9b4f:8dff with SMTP id f8-20020a17090a9b0800b001bc9b4f8dffmr444706pjp.159.1645586269777; Tue, 22 Feb 2022 19:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645586269; cv=none; d=google.com; s=arc-20160816; b=P/LMA9aRRfYvy1MY42tkrZJhzO2/KpKVuZGti32KY0TfRoS5+/28ch+VY7xyg+eYRd k0rwo+Qrotv9f7dlQkU4BxfEvZn+cnkCTPaTsiifHIxDZMsx1/iTUdERAN7phBkLyQOS lIP1h1twFRT3hydQZVx04O7R4AOCNFBzPiWHvXNsMLHLwxLDOttG7G1POVSHUOXgGUX3 QJfuIn+LmQROGHonVwg97W/sVMBb4yuh/mQiECniEukWrTHsXShwV70QbvBMYoR5GNxl 5W4Z/iJ6NiDmBoikLEbvHI9Bf9mWwkkl+gP0r5i34v8TcHEjsltjjNxc86jRsS3wObe7 /qFg== 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=eeo52uagpfILZDuCXWJGVKXtbQVVcVG6rNSwyAmy21gaHzYyN0gKqP8mUcIm5TIXDW 6NCk1dX8S6Y7YtMndOsHzX39HID+G6+0k+DxaVu1BEDDkdc6H2cVKJqHKA34jRcdk5lD DYjBq5+uww7LNPPwxijSjfSKbSptQzo68aeNUcWsAS7+JiRO159f2DeW2q829p5+HdaQ nBsEqDJpqJr+QbKhqLb6zKVa/QQwFxsffczmyUJfzuo8sn0hL02vrguoOHAKADsp8O7a Scf+ZK80m4LVUkjLQbW0X38Wtw+rZgokZg48BmFu7jgTR/elPKgmQvNKaqDZBeQmzUyc V83A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=rRGe87CL; 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 b23si1155693pgn.291.2022.02.22.19.17.33; Tue, 22 Feb 2022 19:17:49 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=rRGe87CL; 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 S235612AbiBVUsy (ORCPT + 99 others); Tue, 22 Feb 2022 15:48:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235594AbiBVUsv (ORCPT ); Tue, 22 Feb 2022 15:48:51 -0500 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEBCA2F2C for ; Tue, 22 Feb 2022 12:48:25 -0800 (PST) Received: by mail-oi1-x235.google.com with SMTP id q5so15961015oij.6 for ; Tue, 22 Feb 2022 12:48:25 -0800 (PST) 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=rRGe87CLAPEMwKCoMohUgZZL6sAWpauySTKwK10hlBitWtAMxblHUSHWwMfnnBkzDT fQRz9htC6ToICG4iDBshh1uYJSdDxHP60alvI+vnzF7Hm2lnQDcS2Q3EdF2AyqHWEODk YK3FWoptNBw4L47SYKIRZBRn9HGdrtw6StUyCFBgVEQq+LUCsL+BrruzWkN2zlu3I3UT dBDqH2aN+5LJNpsley/R7n5BSncuZjiDC+w6sM05yMnG3hTh47q/E3jWM1zbOwXhwibt O+4JhqYfGO8WdcrKVyMpisub3OqqHSZs0KrAuz7/Vnn8BV6TgSxK2WMsOoNMv9EcDLRN 3Img== 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=kB56pTfNsqAM/QwI/+bCVKg8CqGd2mdgnbsiG4J5RRjIlq/AUOd7DDmX/ZZvh0Pi4O 8y4miMO8PbPrYvsTf0dm4WE+HWjWSIxiuM/FISwzylnI4fZVovSKesGTxpSVU7Vh16+b Sh02nKb/KX/+BOyxdNpFAmWImIup3/482hUkNf51a+N95JRMGoImyC0w3rWHtrdKHNnP GvKiFT//uRhMHt5h1OeOY4E1ZMAfeWcKTWfU4lIJgku79pqcW3r9v3e2Agxd/s6nN4Y8 CObpP5GJxhzXNpCjaeUUaP8SO/Ck8hdmC1f4tokPQLaWlIzy3LDEnQXlp9ECMvQChvHK K53g== X-Gm-Message-State: AOAM530kAiLt54lDlisHJWf5U5hcCV/GT9xIctY+yitgPu7oqt3/qJLo TbtJeYgbZFpfZkJf8aiBnQO3qV+O8wDCWA== X-Received: by 2002:a05:6808:903:b0:2d4:8451:d651 with SMTP id w3-20020a056808090300b002d48451d651mr3075448oih.29.1645562904409; Tue, 22 Feb 2022 12:48:24 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id o14sm16508197oaq.37.2022.02.22.12.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 12:48:23 -0800 (PST) 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 v5 1/6] RISC-V: Correctly print supported extensions Date: Tue, 22 Feb 2022 12:48:06 -0800 Message-Id: <20220222204811.2281949-2-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220222204811.2281949-1-atishp@rivosinc.com> References: <20220222204811.2281949-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