Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6464649rwb; Mon, 5 Dec 2022 12:45:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FWUExRM8tjvq4+aMXhc2x+px8nxZTLpyJMmKBCDQX1HUUviZ5gZpaj73igR4z0J8mwb1E X-Received: by 2002:a17:906:3e41:b0:78d:bc9f:33da with SMTP id t1-20020a1709063e4100b0078dbc9f33damr69303072eji.80.1670273134730; Mon, 05 Dec 2022 12:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670273134; cv=none; d=google.com; s=arc-20160816; b=Oej73jfmSkAyxCaSaax7903SNFFtDqDRFEFj/K4IV2dXxQ5bg1JUXh4b25s/HlJ48D mjNn+gpaY6TMgeAqT80GtCdpXicKnnAAdXLx082LQvYZSOFSybbCkwMwu1EUOWnxtmm9 Q9xnmZ729s4wnTho0REl3HFWprG2dchauvDt6d5spjtbrxhu4AHmwhTMAQlaBPX8muAF HUw0mgCmQfeVNsQ0wUyBSHKWoGQ4VRZpYeUZIhRWgKqx/2+3rQRwsVODqMk++/CH3r1g B2A/HqkTy5L5IVBjCPQbGVCA3Nk/4qRThz2x4sV4l6U6E1/BPMDiM3CU1dgUyZG3BQx8 FKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6PHaXPrET5nvjCFBdTKe0XqNHgbUwYG1DOwEWL2k0Ro=; b=WDH58w62kRcKV779pYpOSYLSC6/fbgGsO5Knu4Pa7jg0DWYY9VuJJ0jd+PBoIyFJW3 qfmY1XtLhXtzyqXOTkTb6ht+wi7CmlYlHOZVDliuvhrDEBWybgWwC09xtYiEim2CBJ/M 5C+20lclVhqVofUHNwCFao2xB8rZRHbz6nQCd7yuHcAVnmetsfMMX7TvJ2TIqq4BkH// c4FBUDaTiPsylqwpqn7k/5JUEp53S+6ICXFQDYiF6Mpfszb0yxoS0jXN/Gq6pFMmyQcc jqrF1QnzIlUIFTRbuxXqFh8V5kn2lFJOjgmgGtuw5+EFCdqalONe6a37/UihXdXdxSQ6 MepQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BlXA9gT0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a056402129300b0046ccce3279csi346317edv.178.2022.12.05.12.45.15; Mon, 05 Dec 2022 12:45:34 -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=@kernel.org header.s=k20201202 header.b=BlXA9gT0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234802AbiLETlA (ORCPT + 80 others); Mon, 5 Dec 2022 14:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233846AbiLETke (ORCPT ); Mon, 5 Dec 2022 14:40:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860EC29353; Mon, 5 Dec 2022 11:37:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 174A06131A; Mon, 5 Dec 2022 19:37:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A6CDC433D7; Mon, 5 Dec 2022 19:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670269078; bh=wSny7RERsEy+UvZ++K0y8YLBWfl7nMC8O5faKH/dK5Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BlXA9gT0eqmwlqDoytEbsI9VfOu37m0BZQsf89RKkm4L/X+6Mnsz9vTR0N91jBoLc B3DeAOTuf5KRNarPtvhR7zFXHXsTOLczZljfJPdvFNDzwpxt1xTWBCqQWzxwo09uO2 7iHqvay3TvlmYZgAFzglrP6YsOUW+2ZPP2vpQwaX2tnP66jfa2qMavGglFit/xrTMi Uw5Rf76NVuEjBVIPMymjBj1ZfxdXgF80x2TvkAsBmGw0lM3ZDigbbouaIn/6jVH5Sj 6I5KCZAKJxfkgq0IPTqM+DLbwatH8e9d0dbd1T/Y37rEy02/PX//xw7H9Q6At/IjHe goPrJDaa2kJGw== Date: Mon, 5 Dec 2022 19:37:53 +0000 From: Conor Dooley To: Jisheng Zhang Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner , Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: Re: [PATCH v2 05/13] riscv: cpufeature: extend riscv_cpufeature_patch_func to all ISA extensions Message-ID: References: <20221204174632.3677-1-jszhang@kernel.org> <20221204174632.3677-6-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BmYcKwzzQlEdZjdk" Content-Disposition: inline In-Reply-To: <20221204174632.3677-6-jszhang@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 --BmYcKwzzQlEdZjdk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 05, 2022 at 01:46:24AM +0800, Jisheng Zhang wrote: > make the riscv_cpufeature_patch_func() scan all ISA extensions rather > than limited feature macros. Certainly looks like a nice cleanup. Perhaps for the changelog, something along the lines of: "riscv_cpufeature_patch_func() currently only scans a limited set of cpufeatures, explicitly defined with macros. Extend it to probe for all ISA extensions" >=20 > 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 | 73 +++++----------------------- > 2 files changed, 15 insertions(+), 67 deletions(-) > @@ -311,25 +264,23 @@ void __init_or_module riscv_cpufeature_patch_func(s= truct alt_entry *begin, > for (alt =3D begin; alt < end; alt++) { > if (alt->vendor_id !=3D 0) > continue; > - if (alt->errata_id >=3D CPUFEATURE_NUMBER) { > - WARN(1, "This feature id:%d is not in kernel cpufeature list", > + if (alt->errata_id >=3D RISCV_ISA_EXT_MAX) { > + WARN(1, "This extension id:%d is not in ISA extension list", > alt->errata_id); > continue; > } > =20 > - tmp =3D (1U << alt->errata_id); > - if (cpu_req_feature & tmp) { > - /* do the basic patching */ > - patch_text_nosync(alt->old_ptr, alt->alt_ptr, > - alt->alt_len); > + if (!__riscv_isa_extension_available(NULL, alt->errata_id)) > + continue; > =20 > - riscv_alternative_fix_auipc_jalr(alt->old_ptr, > - alt->alt_len, > - alt->old_ptr - alt->alt_ptr); > - riscv_alternative_fix_jal(alt->old_ptr, > - alt->alt_len, > - alt->old_ptr - alt->alt_ptr); > - } > + /* do the basic patching */ > + patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len); > + riscv_alternative_fix_auipc_jalr(alt->old_ptr, > + alt->alt_len, > + alt->old_ptr - alt->alt_ptr); > + riscv_alternative_fix_jal(alt->old_ptr, > + alt->alt_len, > + alt->old_ptr - alt->alt_ptr); nit: Now that you've dropped a level of indent, can alt->alt_len move up a line? Thanks, Conor. --BmYcKwzzQlEdZjdk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCY45IkQAKCRB4tDGHoIJi 0hVgAP0f7h5X+BsSkUkvJUlU5ALjV6I0EekLwH8GeuYfU1EEzQEA9g48tJXXGwRo Wncokwq3bL0VVPX5RDCVCBtQ7BgoPws= =GI0I -----END PGP SIGNATURE----- --BmYcKwzzQlEdZjdk--