All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] arm64: ftrace: move ftrace-mod.o contents into linker script
Date: Mon, 20 Nov 2017 13:29:03 +0000	[thread overview]
Message-ID: <20171120132902.GB2687@arm.com> (raw)
In-Reply-To: <20171120131538.10492-1-ard.biesheuvel@linaro.org>

Hi Ard,

Thanks for this. Somebody ran across this internally a while back, but
it slipped through the cracks. I remember thinking at the time that the
Kconfig dependencies here looked a little weird too and perhaps
ARM64_MODULE_PLTS should be selected by RANDOMIZE_MODULE_REGION_FULL
instead of RANDOMIZE_BASE.

Anyhow, comments below.

On Mon, Nov 20, 2017 at 01:15:38PM +0000, Ard Biesheuvel wrote:
> When building the arm64 kernel with bot CONFIG_ARM64_MODULE_PLTS and
> CONFIG_DYNAMIC_FTRACE enabled, the ftrace-mod.o object file is built
> with the kernel and contains a trampoline that is linked into each
> module, so that modules can be loaded far away from the kernel and
> still reach the ftrace entry point in the core kernel with an ordinary
> relative branch, as is emitted by the compiler instrumentation code
> dynamic ftrace relies on.
> 
> In order to be able to build out of tree modules, this object file
> needs to be included into the linux-headers or linux-devel packages,
> which is undesirable, as it makes arm64 a special case (although a
> precedent does exist for 32-bit PPC).

Agreed that we should avoid the object file, if possible.

> Given that the trampoline only consists of two instructions, let's
> hack it into the module linker script instead.

Why do we have to do this in the linker script? Couldn't we just generate
the .S file we currently use?

> diff --git a/arch/arm64/kernel/module-ftrace.lds b/arch/arm64/kernel/module-ftrace.lds
> new file mode 100644
> index 000000000000..9df69ddaa7bb
> --- /dev/null
> +++ b/arch/arm64/kernel/module-ftrace.lds
> @@ -0,0 +1,7 @@
> +SECTIONS {
> +	.text.ftrace_trampoline : ALIGN (8) {
> +		QUAD (0x0);		/* 0:	.quad	0x0		*/
> +		LONG (0x58ffffd0);	/*	ldr	x16, 0b		*/
> +		LONG (0xd61f0200);	/*	br	x16		*/
> +	}
> +}

How do we guarantee these are little-endian?

Will

  reply	other threads:[~2017-11-20 13:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20 13:15 [RFC PATCH] arm64: ftrace: move ftrace-mod.o contents into linker script Ard Biesheuvel
2017-11-20 13:29 ` Will Deacon [this message]
2017-11-20 13:39   ` Ard Biesheuvel
2017-11-20 13:47     ` Will Deacon

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=20171120132902.GB2687@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.