Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6005428rwb; Mon, 5 Dec 2022 06:54:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Hy+S5Dgo3TSmBMIu4Ht1aa8/y6+CwK72vZjxHi+kUS5ClP6uaj1d6RbRnrB6PWxEcykcy X-Received: by 2002:a17:906:745:b0:7bd:f50f:a51c with SMTP id z5-20020a170906074500b007bdf50fa51cmr36307580ejb.285.1670252083185; Mon, 05 Dec 2022 06:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670252083; cv=none; d=google.com; s=arc-20160816; b=B0xxwLYDujHRI6yayJ6zMu2k62KSL7ezISPXjiCt8VdoyP9dS3BKhN+YmeDoLiJoAd TNz0aiWsIKRYq9hVeEZfIur9DBR0/h8sAr/YWEbG6YGG5BGqQGQBD5lcrF6Oxpqpq1u5 zSe1ZnVoJ56tN6H8Ja6DQKUVdltNKvwb9c5P7v93lYZKG7d+sr9EWTuAt8nVcUo8Qhxy Z5ZaxXE5D5hMgZnHorskjqn+wQB5HqtInJrgVro1tg0QCmWgwhkKs9gKLlB2szuVbnEp 8j/aOwniS+erS4xQ/eTYPUPCmNeKKIOMy6G34V/kLazQPMbaRP3YqvhY+4Kh3iJLsz3S klWw== 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=8wZueZhS3ooNREifS2ajqp6RU4R+sncaosBhEXeof08=; b=kDS9MhdjwyHgWyxLcaYgp1cd6TyHe5IS47CVggBR33i+gIXR8vLlH6u5Qxb5YMH83R ifyaVZN0ZQEv3HJetifpEg9V0imECezld8Mw9MV5BPCBNUqXCAu4YB4cLVKOC8Mqz/ci 9CIzu7YZ2lt6eOq3SWJ6K2unJHYG5r7jIf5O6XL6rmWAsUJbo/n5II3HxXHrocHdN6ol zCxymS2ACKyQarpt5w8AoElzJd9JiQ6RKwYDd4fMq2hCoZxkAxZBEVVHlrl1FpJaQ8wh vqEVMbyaGHEkInPDmGSbzoOxokV7m042Fj42hSDxqsmM0MJ0vGVaE9LIogIa9NuPV2oN otyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=YlOznsoe; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht17-20020a170907609100b0079ed0a585c2si1184753ejc.261.2022.12.05.06.54.22; Mon, 05 Dec 2022 06:54:43 -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=@microchip.com header.s=mchp header.b=YlOznsoe; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbiLEOqV (ORCPT + 81 others); Mon, 5 Dec 2022 09:46:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231969AbiLEOqR (ORCPT ); Mon, 5 Dec 2022 09:46:17 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCC41B1FE; Mon, 5 Dec 2022 06:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670251576; x=1701787576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/A732PXUzOa5QEDZseaW4QKYJ4f5uZaINwwbpO826ps=; b=YlOznsoeWfXvfw00ixYArB5bTZOboFkNqaRL97SW3/kf76ms/zr5XKhk qxehEX10fyl2082DgWmGXwQgG6oA61rOsJbkXFFjXRay2hkepBRvXN+DI kyptBhMNij1iHcIxlz79pEjAfcqBuSsGH9mYDUlQOVSuFzwftyCrc2aMD 8TZMnCJfXnW/UvFC/l3BFOubilIgSPMSNv6r2jerEzX3GAemOsEqcnxS/ CK+5/wyPChp3EgBsLlrzxhCo886yMaVp7XyKsSJvvR1w3r4WeRzlfrPxx NdwpmLMioozarvU1Ye00pXHXSqt3Qw7bOTPUW5b1TYA68M0xT+NxJhJLK w==; X-IronPort-AV: E=Sophos;i="5.96,219,1665471600"; d="scan'208";a="202640917" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 05 Dec 2022 07:46:15 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 5 Dec 2022 07:46:14 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 5 Dec 2022 07:46:12 -0700 From: Conor Dooley To: , Palmer Dabbelt CC: Conor Dooley , , , , , , , , , Subject: [PATCH v2 1/3] RISC-V: clarify ISA string ordering rules in cpu.c Date: Mon, 5 Dec 2022 14:45:24 +0000 Message-ID: <20221205144525.2148448-2-conor.dooley@microchip.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205144525.2148448-1-conor.dooley@microchip.com> References: <20221205144525.2148448-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 While the current list of rules may have been accurate when created it now lacks some clarity in the face of isa-manual updates. Instead of trying to continuously align this rule-set with the one in the specifications, change the role of this comment. This particular comment is important, as the array it "decorates" defines the order in which the ISA string appears to userspace in /proc/cpuinfo. Re-jig and strengthen the wording to provide contributors with a set order in which to add entries & note why this particular struct needs more attention than others. While in the area, add some whitespace and tweak some wording for readability's sake. Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Conor Dooley --- arch/riscv/kernel/cpu.c | 49 ++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 1b9a5a66e55a..db8b16ad9342 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -144,22 +144,45 @@ arch_initcall(riscv_cpuinfo_init); .uprop = #UPROP, \ .isa_ext_id = EXTID, \ } + /* - * Here are the ordering rules of extension naming defined by RISC-V - * specification : - * 1. All extensions should be separated from other multi-letter extensions - * by an underscore. - * 2. The first letter following the 'Z' conventionally indicates the most + * The canonical order of ISA extension names in the ISA string is defined in + * chapter 27 of the unprivileged specification. + * + * Ordinarily, for in-kernel data structures, this order is unimportant but + * isa_ext_arr defines the order of the ISA string in /proc/cpuinfo. + * + * The specification uses vague wording, such as should, when it comes to + * ordering, so for our purposes the following rules apply: + * + * 1. All multi-letter extensions must be separated from other extensions by an + * underscore. + * + * 2. Additional standard extensions (starting with 'Z') must be sorted after + * single-letter extensions and before any higher-privileged extensions. + + * 3. The first letter following the 'Z' conventionally indicates the most * closely related alphabetical extension category, IMAFDQLCBKJTPVH. - * If multiple 'Z' extensions are named, they should be ordered first - * by category, then alphabetically within a category. - * 3. Standard supervisor-level extensions (starts with 'S') should be - * listed after standard unprivileged extensions. If multiple - * supervisor-level extensions are listed, they should be ordered + * If multiple 'Z' extensions are named, they must be ordered first by + * category, then alphabetically within a category. + * + * 3. Standard supervisor-level extensions (starting with 'S') must be listed + * after standard unprivileged extensions. If multiple supervisor-level + * extensions are listed, they must be ordered alphabetically. + * + * 4. Standard machine-level extensions (starting with 'Zxm') must be listed + * after any lower-privileged, standard extensions. If multiple + * machine-level extensions are listed, they must be ordered * alphabetically. - * 4. Non-standard extensions (starts with 'X') must be listed after all - * standard extensions. They must be separated from other multi-letter - * extensions by an underscore. + * + * 5. Non-standard extensions (starting with 'X') must be listed after all + * standard extensions. If multiple non-standard extensions are listed, they + * must be ordered alphabetically. + * + * An example string following the order is: + * rv64imadc_zifoo_zigoo_zafoo_sbar_scar_zxmbaz_xqux_xrux + * + * New entries to this struct should follow the ordering rules described above. */ static struct riscv_isa_ext_data isa_ext_arr[] = { __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), -- 2.38.1