[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1b19fbeccf3d4a75a5ed3a507d29f7dd@AcuMS.aculab.com>
Date: Mon, 25 Oct 2021 14:25:53 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Frederic Weisbecker' <frederic@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ard Biesheuvel <ardb@...nel.org>
CC: LKML <linux-kernel@...r.kernel.org>,
James Morse <james.morse@....com>,
Quentin Perret <qperret@...gle.com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Mark Rutland <mark.rutland@....com>
Subject: RE: [PATCH 2/4] arm64: implement support for static call trampolines
From: Frederic Weisbecker
> Sent: 25 October 2021 13:21
>
> Implement arm64 support for the 'unoptimized' static call variety, which
> routes all calls through a single trampoline that is patched to perform a
> tail call to the selected function.
>
> It is expected that the direct branch instruction will be able to cover
> the common case. However, given that static call targets may be located
> in modules loaded out of direct branching range, we need a fallback path
> that loads the address into R16 and uses a branch-to-register (BR)
> instruction to perform an indirect call.
>
...
> +void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
> +{
> + /*
> + * -0x8 <literal>
> + * 0x0 bti c <--- trampoline entry point
> + * 0x4 <branch or nop>
> + * 0x8 ldr x16, <literal>
> + * 0xc cbz x16, 20
> + * 0x10 br x16
> + * 0x14 ret
> + */
Since the 'ldr x16, <literal>' is just a 32bit constant
(for a pc-relative load).
Can't you save a word by making offset 0x4 <branch or ldr x16, <literal>> ?
Or am I missing something?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists