[PATCH v2] arm64: implement support for static call trampolines

Mark Rutland mark.rutland at arm.com
Thu Oct 29 09:30:12 EDT 2020


On Thu, Oct 29, 2020 at 12:58:32PM +0100, Peter Zijlstra wrote:
> On Thu, Oct 29, 2020 at 11:50:26AM +0000, Mark Rutland wrote:
> > Hi Ard,
> > 
> > On Wed, Oct 28, 2020 at 07:41:14PM +0100, Ard Biesheuvel wrote:
> > > 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.
> > 
> > Given the complexity and subtlety here, do we actually need this?
> 
> Only if you can get a performance win. The obvious benefit is loosing
> the load that's inherent in indirect function calls. The down-side of
> the indirect static-call implementation is that it will incur an extra
> I$ miss.
> 
> So it might be a wash, loose a data load miss, gain an I$ miss.

I reckon it'll be highly dependent on microarchitecture since it'll also
depend on how indirect branches are handled (with prediction,
forwarding, speculation, etc). I don't think we can easily reason about
this in general.

> The direct method (patching the call-site, where possible) would
> alleviate that (mostly) and be more of a win.

I think that where the original callsite can be patched with a direct
branch, it's desireable that we do so. That's simple enough, and there
are places where that'd be useful from a functional pov (e.g. if we want
to patch branches in hyp text to other hyp text).

However, if the range of the branch requires a trampoline I'd rather the
trampoline (and the procedure for updating it) be as simple as possible.

Thanks,
Mark.



More information about the linux-arm-kernel mailing list