public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: dann frazier <dann.frazier@canonical.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: mark.rutland@arm.com, catalin.marinas@arm.com, duwe@lst.de,
	will.deacon@arm.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64/module: ftrace: deal with place relative nature of PLTs
Date: Mon, 15 Apr 2019 12:47:05 -0600	[thread overview]
Message-ID: <20190415184705.GA21567@xps13.dannf> (raw)
In-Reply-To: <20190413065925.6981-1-ard.biesheuvel@linaro.org>

On Fri, Apr 12, 2019 at 11:59:25PM -0700, Ard Biesheuvel wrote:
> Another bodge for the ftrace PLT code: plt_entries_equal() now takes
> the place relative nature of the ADRP/ADD based PLT entries into
> account, which means that a struct trampoline instance on the stack
> is no longer equal to the same set of opcodes in the module struct,
> given that they don't point to the same place in memory anymore.
> 
> Work around this by using memcmp() in the ftrace PLT handling code.

This fixes an issue I was seeing on a HiSilicon D06 server:
  https://bugs.launchpad.net/bugs/1822871

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Tested-by: dann frazier <dann.frazier@canonical.com>

  -dann

> ---
>  arch/arm64/kernel/ftrace.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> index 07b298120182..65a51331088e 100644
> --- a/arch/arm64/kernel/ftrace.c
> +++ b/arch/arm64/kernel/ftrace.c
> @@ -103,10 +103,15 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>  		 * to be revisited if support for multiple ftrace entry points
>  		 * is added in the future, but for now, the pr_err() below
>  		 * deals with a theoretical issue only.
> +		 *
> +		 * Note that PLTs are place relative, and plt_entries_equal()
> +		 * checks whether they point to the same target. Here, we need
> +		 * to check if the actual opcodes are in fact identical,
> +		 * regardless of the offset in memory so use memcmp() instead.
>  		 */
>  		trampoline = get_plt_entry(addr, mod->arch.ftrace_trampoline);
> -		if (!plt_entries_equal(mod->arch.ftrace_trampoline,
> -				       &trampoline)) {
> +		if (memcmp(mod->arch.ftrace_trampoline, &trampoline,
> +			   sizeof(trampoline))) {
>  			if (plt_entry_is_initialized(mod->arch.ftrace_trampoline)) {
>  				pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n");
>  				return -EINVAL;

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-04-15 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-13  6:59 [PATCH] arm64/module: ftrace: deal with place relative nature of PLTs Ard Biesheuvel
2019-04-15 18:47 ` dann frazier [this message]
2019-04-23 11:43 ` 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=20190415184705.GA21567@xps13.dannf \
    --to=dann.frazier@canonical.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=duwe@lst.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=will.deacon@arm.com \
    /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