From: Quentin Perret <qperret@google.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: mark.rutland@arm.com, Peter Zijlstra <peterz@infradead.org>,
catalin.marinas@arm.com, james.morse@arm.com, will@kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] arm64: implement support for static call trampolines
Date: Thu, 29 Oct 2020 11:27:47 +0000 [thread overview]
Message-ID: <20201029112747.GA4090840@google.com> (raw)
In-Reply-To: <20201028184114.6834-1-ardb@kernel.org>
Hi Ard,
On Wednesday 28 Oct 2020 at 19:41:14 (+0100), Ard Biesheuvel wrote:
> diff --git a/arch/arm64/include/asm/static_call.h b/arch/arm64/include/asm/static_call.h
> new file mode 100644
> index 000000000000..7ddf939d57f5
> --- /dev/null
> +++ b/arch/arm64/include/asm/static_call.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_STATIC_CALL_H
> +#define _ASM_STATIC_CALL_H
> +
> +/*
> + * We have to account for the possibility that the static call site may
> + * be updated to refer to a target that is out of range for an ordinary
> + * 'B' branch instruction, and so we need to pre-allocate some space for
> + * a ADRP/ADD/BR sequence.
> + */
> +#define __ARCH_DEFINE_STATIC_CALL_TRAMP(name, insn) \
> + asm(".pushsection .static_call.text, \"ax\" \n" \
> + ".align 5 \n" \
> + ".globl " STATIC_CALL_TRAMP_STR(name) " \n" \
> + STATIC_CALL_TRAMP_STR(name) ": \n" \
> + "hint 34 /* BTI C */ \n" \
> + insn " \n" \
> + "ret \n" \
> + "nop \n" \
> + "nop \n" \
> + "adrp x16, " STATIC_CALL_KEY(name) " \n" \
> + "ldr x16, [x16, :lo12:" STATIC_CALL_KEY(name) "] \n" \
> + "br x16 \n" \
> + ".popsection \n")
Still trying to understand all this in details, so bear with me, but is
there any way this could be turned into the 'inline' static call
variant?
That is, could we have a piece of inline assembly at all static_call
locations that would do a branch-link, with basically x0-x18 and
x29,x30 in the clobber list (+ some have some magic to place the
parameters in the right register, like we do for SMCCC calls for
instance). That'd save a branch to the trampoline.
Ideally we'd need a way to tell the compile 'this inline assembly code
does a function call', but I'm not aware of any easy way to do that
(other that marking register clobbered + probably other things that I'm
missing).
In any case, I was looking forward to an arm64 static call port so
thanks for putting that together.
Quentin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-10-29 11:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 18:41 [PATCH v2] arm64: implement support for static call trampolines Ard Biesheuvel
2020-10-29 10:28 ` Peter Zijlstra
2020-10-29 10:40 ` Peter Zijlstra
2020-10-29 10:58 ` Ard Biesheuvel
2020-10-29 11:46 ` Peter Zijlstra
2020-10-29 11:49 ` Ard Biesheuvel
2020-10-29 11:54 ` Peter Zijlstra
2020-10-29 12:14 ` Ard Biesheuvel
2020-10-29 11:27 ` Quentin Perret [this message]
2020-10-29 11:32 ` Ard Biesheuvel
2020-10-29 11:44 ` Peter Zijlstra
2020-10-29 14:10 ` Steven Rostedt
2020-10-29 11:54 ` Quentin Perret
2020-10-29 13:22 ` Ard Biesheuvel
2020-11-16 10:18 ` Quentin Perret
2020-11-16 10:31 ` Ard Biesheuvel
2020-11-16 12:05 ` Quentin Perret
2020-10-29 11:50 ` Mark Rutland
2020-10-29 11:58 ` Peter Zijlstra
2020-10-29 13:30 ` Mark Rutland
2020-10-29 11:59 ` Ard Biesheuvel
2020-10-29 13:21 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201029112747.GA4090840@google.com \
--to=qperret@google.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).