[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/9] xen/arm64: entry: Don't jump outside of an alternative


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 27 Jun 2023 09:52:23 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mqXPWbi9gCNFb/0cjUi0Lw/8NKO/jfoYhBLXew9oV6s=; b=hHIKfusgAy3iJB6LboKBxbXCl+3SKotZZPEmsXaav1TKNvW/dPEBOhB47fKYVfMbazrJRNrkzu3LMGpHOlZmYQmhYZiBcdaVR8GvUG6fcNeP8KfEj08tgV640xz2eLz4K/U94eJqHqOJxDWFXkDJPHlPuy6dVh4DL81ujh2WywdGTj5DrjagmBei+myNOwG0uY4swHhCL+SP0yL8Te08xFqROXy1NCT9a+BehyARiply+I/YyJzSbmE/2sdNFE3Hbl6p9SHlydbtMcxLmfO2gFAsWsL/8H1xlEJRJDmZIFrSFBSDG8AT+gXPh2KN81+gneDzyCNhIKS/REREqdbR1Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YP5g1+25gVgodSWutKnkomO/ZWKDnpaNoivl+YSx1xPVXeiEpMfUJSk5lf5qCTRKzdDdwbp7N6+pCtoF803HoAdwANjcINr9Ka8VBOY3ljOKlJJdBZKBrrfPHMfTYrQvOFkovSu14Bc8451nQKHIF4DZ0nhYUO+MZIFlJ4N0DiD/Bhm/aCTpeKuQ1cmr2wUzr7XO3bsmgDp90GGx+zr5FuC9SKRtnLek9ppJbAELDrGZKNYH3paJgfMkwFgtBQQugLeYHU2xpIfA+ax1SWeLmez4p9S79VTANM9cPDONyy9o5BR7VEbNWPnChPvzi1V1EdPi7rP1ejBFaRqm7exC5Q==
  • Cc: <Luca.Fancellu@xxxxxxx>, <Henry.Wang@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 27 Jun 2023 07:53:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 25/06/2023 22:49, Julien Grall wrote:
> 
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> The instruction CBNZ can only jump to a pc-relative that is in the
> range +/- 1MB.
> 
> Alternative instructions replacement are living in a separate
> subsection of the init section. This is usually placed towards
> the end of the linker. Whereas text is towards the beginning.
> 
> While today Xen is quite small (~1MB), it could grow up to
> 2MB in the current setup. So there is no guarantee that the
> target address in the text section will be within the range +/-
> 1MB of the CBNZ in alternative section.
> 
> The easiest solution is to have the target address within the
> same section of the alternative. This means that we need to
> duplicate a couple of instructions.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> 
> ----
> 
> I couldn't come up with a solution that would not change the number
> of instructions executed in the entry path.
It looks like the max offset is indeed 1MB for conditional branches and I cannot
think of any better way of doing this, so:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

> ---
>  xen/arch/arm/arm64/entry.S | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S
> index 95f1a9268419..492591fdef54 100644
> --- a/xen/arch/arm/arm64/entry.S
> +++ b/xen/arch/arm/arm64/entry.S
> @@ -242,13 +242,24 @@
>          msr     daifclr, \iflags
>          bl      enter_hypervisor_from_guest
> 
> +        /*
> +         * CBNZ can only address an offset of +/- 1MB. This means, it is
> +         * not possible to jump outside of an alternative because
> +         * the .text section and .altinstr_replacement may be further
> +         * appart. The easiest way is to duplicate the few instructions
s/appart/apart

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.