Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10181084rwl; Wed, 11 Jan 2023 16:01:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXvqbmNysz8nFq7AY8bg9ofuLvyNzFeIY0ScSoMAqMiGTza73X6MWHcHweuF8S1oVwS9I4DZ X-Received: by 2002:aa7:ca55:0:b0:468:38e5:f233 with SMTP id j21-20020aa7ca55000000b0046838e5f233mr64069814edt.24.1673481671809; Wed, 11 Jan 2023 16:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481671; cv=none; d=google.com; s=arc-20160816; b=tIbzjGu73agNXnBU5kgx/NjrwzbRBWEGNa1n1Z7IDKuyi59Q+kRNTARyaGOthxuHkV v1+yyHkEkhYTsmDorz8ipamJjYQAsV0KZffaA44mp0LCZN3XUtp1eLd8tGgzYHOEOmrD mPlu02rL/QTsP9TGYFRjzETKacbkEFPJubYVytyY5PIbGDDETV6pUcoSooFxuRtIxsHI d5JuIB6hcWKGgQKqyE+EfU6EbBMZqf2SNYqphdV+OYSql/zCqxIe9ekMIUeFdW9sEqq4 huztAFMW02jsPF607sp5dbu0G7nnqKYDG+Qz3jRtsQ0qN+ysK2CfZsz9Nlu79YHMHeZA grow== 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; bh=C0+mG45mRejEbuUBv6ZNqXk6dLBoNYlyJLKqxUhLWdo=; b=r3/TaW/8E70xS4VnEJECq635Ms7cnSZyFdNpxKF/V94H+MOHLFp/sBciYA/aU6F7T5 UvRD47pcTZq5Tz685xjWDt6YQYVU1xuM+TNW+6cRfSTQFobGUT6cg5+J53Zl1HpW4Pbl cmWI3wrvqjOgFjoOHp6w/3+qDUdzo0T4LZs4KvzktQACmTYJISW3ea1PXwHoQHH71txH /IiH4+X4hwBgpSYE3YZwzfXTcw59Dnp7MQfRRROrLjuM5fqEbpXHRejSGGN1hBzbfOLJ x6hj6gfoPG9YhQfGwak2Lw9H6ijYDWST0cn1LS4u8Z3hXn1xN2s8VWWWI8AM0U/1ef20 awpw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020aa7c0c8000000b0046c38a4d141si13707660edp.100.2023.01.11.16.00.58; Wed, 11 Jan 2023 16:01:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235329AbjAKXaJ (ORCPT + 52 others); Wed, 11 Jan 2023 18:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbjAKXaG (ORCPT ); Wed, 11 Jan 2023 18:30:06 -0500 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07EABB97; Wed, 11 Jan 2023 15:30:03 -0800 (PST) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pFkXe-00019a-Nt; Thu, 12 Jan 2023 00:29:58 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Jisheng Zhang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Andrew Jones Subject: Re: [PATCH v3 05/13] riscv: cpufeature: extend riscv_cpufeature_patch_func to all ISA extensions Date: Thu, 12 Jan 2023 00:29:57 +0100 Message-ID: <2398293.3Lj2Plt8kZ@diego> In-Reply-To: <20230111171027.2392-6-jszhang@kernel.org> References: <20230111171027.2392-1-jszhang@kernel.org> <20230111171027.2392-6-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR 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 Hi Jisheng. Am Mittwoch, 11. Januar 2023, 18:10:19 CET schrieb Jisheng Zhang: > riscv_cpufeature_patch_func() currently only scans a limited set of > cpufeatures, explicitly defined with macros. Extend it to probe for all > ISA extensions. > > Signed-off-by: Jisheng Zhang > Reviewed-by: Andrew Jones > Reviewed-by: Heiko Stuebner > --- > arch/riscv/include/asm/errata_list.h | 9 ++-- > arch/riscv/kernel/cpufeature.c | 63 ++++------------------------ > 2 files changed, 11 insertions(+), 61 deletions(-) hmmm ... I do see a somewhat big caveat for this. and would like to take back my Reviewed-by for now With this change we would limit the patchable cpufeatures to actual riscv extensions. But cpufeatures can also be soft features like how performant the core handles unaligned accesses. See Palmer's series [0]. Also this essentially codifies that each ALTERNATIVE can only ever be attached to exactly one extension. But contrary to vendor-errata, it is very likely that we will need combinations of different extensions for some alternatives in the future. In my optimization quest, I found that it's actually pretty neat to convert the errata-id for cpufeatures to a bitfield [1], because then it's possible to just combine extensions into said bitfield [2]: ALTERNATIVE_2("nop", "j strcmp_zbb_unaligned", 0, CPUFEATURE_ZBB | CPUFEATURE_FAST_UNALIGNED, 0, CONFIG_RISCV_ISA_ZBB, "j variant_zbb", 0, CPUFEATURE_ZBB, CPUFEATURE_FAST_UNALIGNED, CONFIG_RISCV_ISA_ZBB) [the additional field there models a "not" component] So I really feel this would limit us quite a bit. Heiko [0] https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/commit/?h=riscv-hwprobe-v1&id=510c491cb9d87dcbdc91c63558dc704968723240 [1] https://github.com/mmind/linux-riscv/commit/f57a896122ee7e666692079320fc35829434cf96 [2] https://github.com/mmind/linux-riscv/commit/8cef615dab0c00ad68af2651ee5b93d06be17f27#diff-194cb8a86f9fb9b03683295f21c8f46b456a9f94737f01726ddbcbb9e3aace2cR12