Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6484123pxb; Tue, 15 Feb 2022 03:33:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWaCi/jYxKzO5TrRKr+xVfV+Vwtq1ieV3ySEsXcRKglDQsyqTUrlZeQGj6kdRAFwnaEUzv X-Received: by 2002:a17:902:ced1:: with SMTP id d17mr3835964plg.42.1644924794909; Tue, 15 Feb 2022 03:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644924794; cv=none; d=google.com; s=arc-20160816; b=MZhNEKYyg2fARGDuNVmNwHVAzFgriaXk1KsVYsKNv0KB12H3IIrQAnzWKb42PN4tSF liTrhIphFDMAtivq89KJh8TEkDdywJXbczl7YZM5ViB++IeJFI29D0NAeKhjgQjlt7YH TTLo+2PhrQ9Y9D3Y/ssdeIZKA2wlLH6dsVt5FyzkBcvk8+x3xZR8gsjPhdl+C40IJdR5 yHPdBHVv4sskXwXcKSYkEBfq1RykTzNJRHB1u5YTzkrDhHp0ur6jSdIMZ1P71p0m29Qh vVcSHmK92ylqSZK5+KS5oWSXzWon1zhui2d9pGMUiJSoiPJRm0vOKvJIxyoZprNzRVNV yyrg== 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=t1wflCr1vStMilehgvIe0w5v3TJPtXNP/omwaXqFnbs=; b=FFuDXfTx3XzYsQw9llxImpc+0t7c05ewe393rwppzFtBfitKuVwFYtZ6JyTvNzfYYq AMjkiUdTRcj+Gm8sN+A9vfwRHMO6FYk9YkWGDCnR/e2QIfOwq9RuXdiaPBoZP2bDBwlb zUvVZZcMdmMEp4UKHuPiZobGaB6FdO93MCYJhfVVi2r8zC5AOVCvkLsOCGPFmrKnQlHs wjA/TXD+aEpt1uAVM1Cq7VmXsadh3VZ2M9+BYcL0Bzlbhf7g0cHHvHKuCpcNHrJM5UJP M8hP6yc/9kN3DzwIGGEZ4PhhUYPkbADiuMAEShiw/7Yk8M+D+/9Gf64kwR1C9JTnZupZ i4JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=X2ztBi1B; 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 bg3si2885518plb.7.2022.02.15.03.33.01; Tue, 15 Feb 2022 03:33:14 -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=X2ztBi1B; 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 S235982AbiBOJld (ORCPT + 99 others); Tue, 15 Feb 2022 04:41:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:32992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235983AbiBOJlb (ORCPT ); Tue, 15 Feb 2022 04:41:31 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCCB0E4D07 for ; Tue, 15 Feb 2022 01:41:20 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id p9so10520333wra.12 for ; Tue, 15 Feb 2022 01:41:20 -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=t1wflCr1vStMilehgvIe0w5v3TJPtXNP/omwaXqFnbs=; b=X2ztBi1BvP5dZxfZSWhpEp86yS7NH+aFVQUGt8uylxVUHrTPgLxljm/I823I20QDAC myDO9b6pKdhXfxOflamUH9a0V56xRHIzRt+zobHm2aSQI9lX2AtyVbvDJ4b/hbAVMJwj O9vb1GNkZY2UcPTCqfIbCX+8y2sqNQNjI5x14V4+FrxOupZqMwREoOU7tUaRNhVammTS 15HBCcV5/vHuri9+ncnfWaytYpmQXGl85VY7/QOaHfZV4ygqrf/US1M/Trp4pBEdNttY GmI4NuNrS9A1UQGLBpSYyXFp+7ZES8mph1JTwI5jnuKmU+GSd5GjMsnzQcXxqbHmEldG KnAA== 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=t1wflCr1vStMilehgvIe0w5v3TJPtXNP/omwaXqFnbs=; b=wyD84+PsfYNWD0W/tR42mRoHQZSL7LljoTMx6ynZHqCeX6SEEAJQTpaCH0n0M2VvEl SOMGB0mU7rjvIDVezYzQrnXj5ZTYCj2O0TYG5a5PX2OgKSzr/FZyDosYJePigWKBuj7W fJGrLtcJ3YALYCGZI4hvKHQ3jiRbRoYDf6Dfl5A2y40m4XHHluJuyP81uVLmPCfh5gsH ViOnWTDjM8sObQB12eV2g0DsFHAoCjZSdSHV+fNAIBddviIt8MxWxKq1Lkxmf4zOeujo 2n7ixxNBcktEAIMhIoKnifpgRO6WqFFffuHn3XURc72YMyzFF/EUg6jq2LjRbC/VBhGf UG5g== X-Gm-Message-State: AOAM531F7EpZDc7BAUqxbx46TpdWPtH3mHMAnarqCYXGm3DrCGEdo3IO KIOL0NRecM6ACiKBxqkVWCE3m9sUd4c+9wccl+g/vQ== X-Received: by 2002:a5d:4209:: with SMTP id n9mr2515369wrq.86.1644918078895; Tue, 15 Feb 2022 01:41:18 -0800 (PST) MIME-Version: 1.0 References: <20220215090211.911366-1-atishp@rivosinc.com> <20220215090211.911366-2-atishp@rivosinc.com> In-Reply-To: <20220215090211.911366-2-atishp@rivosinc.com> From: Anup Patel Date: Tue, 15 Feb 2022 15:11:06 +0530 Message-ID: Subject: Re: [PATCH v3 1/6] RISC-V: Correctly print supported extensions 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 Tue, Feb 15, 2022 at 2:32 PM Atish Patra wrote: > > 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. > > Signed-off-by: Tsukasa OI > Signed-off-by: Atish Patra > Tested-by: Heiko Stuebner Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > 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 >