Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp75692rwb; Wed, 18 Jan 2023 14:22:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvi6Un/0KM54p/QIQ70NwftNbYQmGRMOFO/3xtoZUg///TnxOhGl9O9SW/6WOnKxJv8b802 X-Received: by 2002:a17:907:a057:b0:7c0:a99c:485c with SMTP id gz23-20020a170907a05700b007c0a99c485cmr4653337ejc.68.1674080553893; Wed, 18 Jan 2023 14:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674080553; cv=none; d=google.com; s=arc-20160816; b=HR4lEDxPgwWi1kmBEh71/w4al6wSJ9SXXPzW87CQrE5UklKYN91s2YHEGErO6jiPfK +QMgrmEZ0bAq1ZZu434Yc41c46kMRr0jlCU+Ve6B+4VaIXbrrUwsongr8h5+6GYCp5AG J3G0vAHl9uh09yEmpUfSBjrMgwccvdvsQT9HY9wiiT0Q4tdId4qWGiJOm5GHxs7LSv2k go7E62kO364raq8tHQlezh8EJ9nMzuE42ipd5NwhvW0dotM58fABXqb3VDDG7QCE/yMH kvdu0tdEJ1Odq/IXJd2Svz6rH1bKALI8vwzuRVdHt7TxA99ACSccS//esLLxqKeGqHZe ysog== 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=3zNbKcLPSXCXCe78MX3zuSN7GdirYK2fc6ZpER6QQ6U=; b=ZjXYIC/IVvGVhKfOBrtLVZ/DuN/IHvT2+ODcHg/T6j4nNnGuw/04mUCEMTQKcwEG0z BBmQeUncG3bKptRQQH1Rs/aCrx99XSdAOS1C4pLo4ZYd2Oc0uAkYKeh7cKiNJe2rOWXw u33NSO1aVWRrVgXUvX6nHUMuGznihdTD5suDRqXfaLDn5rHjrHF0talw0mx393/bNGkB 0Od1DfB+cjycnmmRcjBM4XUl5X/9B4dRyC/HRX0AQgDyzOOv5ApFId6K0REBVq7FCf04 kd7+rthuiB7URiEo1+aorNKNVnH6yO8uCBwYa2CbfA4VYJvnqXsSViAaSu87VGLijjMi OJXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kRf994SP; 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 di4-20020a170906730400b007ae814af6aasi15299474ejc.87.2023.01.18.14.22.23; Wed, 18 Jan 2023 14:22:33 -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=kRf994SP; 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 S229977AbjARWLP (ORCPT + 44 others); Wed, 18 Jan 2023 17:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjARWLL (ORCPT ); Wed, 18 Jan 2023 17:11:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C91630BD; Wed, 18 Jan 2023 14:11:10 -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 28AE761A30; Wed, 18 Jan 2023 22:11:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DB2FC433D2; Wed, 18 Jan 2023 22:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674079869; bh=CdZG5/YxLc49feLRzoUlE6cnoB+Dyy0CHB+Umiuydq0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kRf994SPqMKZzWMUowCxIVLg8cJ3eE51GDjGUNfDpYuDhiK6AtUImg0AJqu0SX7o0 Jiby7b9qkGsSSTE8oBDuFSSTd7onTrUNaVJ0MIFbPcyl6kcf0NRTLwzmH22tqC3ljd SEG8/6VYfKYONMhsM1HcXkI222re2DNCj7E1bC2HBsYlUceHPlKd07wrT0/5kXFuA9 ICTp6ZR7yRARSiuzNiXGSOEh83InEyf3KLt3u5nClt5LQY2qVo5NC6NTL/UWYGObxa O+tTlDAd5OeL3CWusasP3vGZ4IroWGvlV0efHJBtRsIqb5zSnwQT9Q7Ei3tDTASilu KWTUw9jCFeTPQ== Date: Wed, 18 Jan 2023 22:11:04 +0000 From: Conor Dooley To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner , Conor Dooley , Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: Re: [PATCH v4 09/13] riscv: switch to relative alternative entries Message-ID: References: <20230115154953.831-1-jszhang@kernel.org> <20230115154953.831-10-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bmKuqoHkdUUge14f" Content-Disposition: inline In-Reply-To: <20230115154953.831-10-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 --bmKuqoHkdUUge14f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 15, 2023 at 11:49:49PM +0800, Jisheng Zhang wrote: > Instead of using absolute addresses for both the old instrucions and > the alternative instructions, use offsets relative to the alt_entry > values. So this not only cuts the size of the alternative entry, but > also meets the prerequisite for patching alternatives in the vDSO, > since absolute alternative entries are subject to dynamic relocation, > which is incompatible with the vDSO building. >=20 > Signed-off-by: Jisheng Zhang > Reviewed-by: Andrew Jones > +/* add the relative offset to the address of the offset to get the absol= ute address */ > +#define __ALT_PTR(a, f) ((void *)&(a)->f + (a)->f) > +#define ALT_OLD_PTR(a) __ALT_PTR(a, old_offset) > +#define ALT_ALT_PTR(a) __ALT_PTR(a, alt_offset) LGTM, thanks for doing that! Certainly makes things more understandable. Reviewed-by: Conor Dooley > + oldptr =3D ALT_OLD_PTR(alt); > + altptr =3D ALT_ALT_PTR(alt); > if (!__riscv_isa_extension_available(NULL, alt->errata_id)) > continue; > =20 One minor nit, the oldptr/altptr assignments could go down here, below the if/continue, right? Obviously don't respin for that though! > - patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len); > - riscv_alternative_fix_offsets(alt->old_ptr, alt->alt_len, > - alt->old_ptr - alt->alt_ptr); > + patch_text_nosync(oldptr, altptr, alt->alt_len); > + riscv_alternative_fix_offsets(oldptr, alt->alt_len, oldptr - altptr); > } > } > #endif --bmKuqoHkdUUge14f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCY8hueAAKCRB4tDGHoIJi 0vqnAQCu6VGYhfeHulaTR2wdUMiEo1QZs/vLjK4o0+w72tjqvwEA3JzxSPC2w0S5 hP0afumacfOuguJC+7JJkFbi/XEE2wM= =RVgk -----END PGP SIGNATURE----- --bmKuqoHkdUUge14f--