Re: [PATCH 2/4] arm64: implement support for static call trampolines

From: Peter Zijlstra
Date: Tue Oct 26 2021 - 06:46:08 EST


On Tue, Oct 26, 2021 at 11:36:55AM +0100, Mark Rutland wrote:

> My preference overall is to keep the trampoline self-contained, and I'd
> prefer to keep the RET inline in the trampoline rather than trying to
> factor it out so that all the control-flow is clearly in one place.
>
> So I'd prefer that we have the sequence as-is:
>
> | 0: .quad 0x0
> | bti c
> | < insn >
> | ldr x16, 0b
> | cbz x16, 1f
> | br x16
> | 1: ret

OK, fair enough. In that case:

Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Although I do think that function can use a comment to explain the magic
involved.

> If we knew these were only called with IRQs enabled (and so we can take
> an IPI to generate a context synchronization event), we could patch
> <insn> to a RET and point the literal back at the BTI, e.g.

Given the static_call() usage on x86 I'm pretty sure you'll want them
with IRQs disabled.