All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Sven Schnelle <svens@linux.ibm.com>,
	Yinan Liu <yinan@linux.alibaba.com>,
	linuxppc-dev@lists.ozlabs.org,
	Sachin Sant <sachinp@linux.ibm.com>,
	linux-kernel@vger.kernel.org, ardb@kernel.org,
	keescook@chromium.org
Subject: Re: [powerpc] ftrace warning kernel/trace/ftrace.c:2068 with code-patching selftests
Date: Thu, 27 Jan 2022 13:08:46 +0000	[thread overview]
Message-ID: <YfKZXvB9vCN1bA1c@FVFF77S0Q05N> (raw)
In-Reply-To: <20220127074601.41a3773d@rorschach.local.home>

On Thu, Jan 27, 2022 at 07:46:01AM -0500, Steven Rostedt wrote:
> On Thu, 27 Jan 2022 12:27:04 +0000
> Mark Rutland <mark.rutland@arm.com> wrote:
> 
> > Ah, so those non-ELF relocations for the mcount_loc table just mean "apply the
> > KASLR offset here", which is equivalent for all entries.
> > 
> > That makes sense, thanks!
> 
> And this is why we were having such a hard time understanding each other ;-)

;)

With that in mind, I think that we understand that the build-time sort works
for:

* arch/x86, becuase the non-ELF relocations for mcount_loc happen to be
  equivalent.
 
* arch/arm, because there's no dynamic relocaiton and the mcount_loc entries
  have been finalized prior to sorting.

... but doesn't work for anyone else (including arm64) because the ELF
relocations are not equivalent, and need special care that is not yet
implemented.

So we should have arm and x86 opt-in, but for now everyone else (including
arm64, powerpc, s390) should be left with the prior behaviour with the runtime
sort only (in case the build-time sort breaks anything, as I mentioned in my
other mail).

Does that sound about right?

In future we might be able to do something much smarter (e.g. adding some
preprocessing to use relative entries).

I'll take a look at shelf. :)

Thanks,
Mark.

> I started a new project called "shelf", which is a shell interface to
> read ELF files (Shelf on a ELF!).
> 
> It uses my ccli library:
> 
>    https://github.com/rostedt/libccli
> 
> and can be found here:
> 
>    https://github.com/rostedt/shelf
> 
> Build and install the latest libccli and then build this with just
> "make".
> 
>   $ shelf vmlinux
> 
> and then you can see what is stored in the mcount location:
> 
>   shelf> dump symbol __start_mcount_loc - __stop_mcount_loc
> 
> I plan on adding more to include the REL and RELA sections and show how
> they affect symbols and such.
> 
> Feel free to contribute too ;-)
> 
> -- Steve

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: keescook@chromium.org, linux-kernel@vger.kernel.org,
	Sven Schnelle <svens@linux.ibm.com>,
	Sachin Sant <sachinp@linux.ibm.com>,
	Yinan Liu <yinan@linux.alibaba.com>,
	linuxppc-dev@lists.ozlabs.org, ardb@kernel.org
Subject: Re: [powerpc] ftrace warning kernel/trace/ftrace.c:2068 with code-patching selftests
Date: Thu, 27 Jan 2022 13:08:46 +0000	[thread overview]
Message-ID: <YfKZXvB9vCN1bA1c@FVFF77S0Q05N> (raw)
In-Reply-To: <20220127074601.41a3773d@rorschach.local.home>

On Thu, Jan 27, 2022 at 07:46:01AM -0500, Steven Rostedt wrote:
> On Thu, 27 Jan 2022 12:27:04 +0000
> Mark Rutland <mark.rutland@arm.com> wrote:
> 
> > Ah, so those non-ELF relocations for the mcount_loc table just mean "apply the
> > KASLR offset here", which is equivalent for all entries.
> > 
> > That makes sense, thanks!
> 
> And this is why we were having such a hard time understanding each other ;-)

;)

With that in mind, I think that we understand that the build-time sort works
for:

* arch/x86, becuase the non-ELF relocations for mcount_loc happen to be
  equivalent.
 
* arch/arm, because there's no dynamic relocaiton and the mcount_loc entries
  have been finalized prior to sorting.

... but doesn't work for anyone else (including arm64) because the ELF
relocations are not equivalent, and need special care that is not yet
implemented.

So we should have arm and x86 opt-in, but for now everyone else (including
arm64, powerpc, s390) should be left with the prior behaviour with the runtime
sort only (in case the build-time sort breaks anything, as I mentioned in my
other mail).

Does that sound about right?

In future we might be able to do something much smarter (e.g. adding some
preprocessing to use relative entries).

I'll take a look at shelf. :)

Thanks,
Mark.

> I started a new project called "shelf", which is a shell interface to
> read ELF files (Shelf on a ELF!).
> 
> It uses my ccli library:
> 
>    https://github.com/rostedt/libccli
> 
> and can be found here:
> 
>    https://github.com/rostedt/shelf
> 
> Build and install the latest libccli and then build this with just
> "make".
> 
>   $ shelf vmlinux
> 
> and then you can see what is stored in the mcount location:
> 
>   shelf> dump symbol __start_mcount_loc - __stop_mcount_loc
> 
> I plan on adding more to include the REL and RELA sections and show how
> they affect symbols and such.
> 
> Feel free to contribute too ;-)
> 
> -- Steve

  reply	other threads:[~2022-01-27 13:09 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  9:19 [powerpc] ftrace warning kernel/trace/ftrace.c:2068 with code-patching selftests Sachin Sant
2022-01-24  9:19 ` Sachin Sant
2022-01-24 12:15 ` Yinan Liu
2022-01-24 16:45   ` Steven Rostedt
2022-01-25  3:20     ` Yinan Liu
2022-01-26 14:37       ` Mark Rutland
2022-01-27 11:46         ` Mark Rutland
2022-01-27 11:46           ` Mark Rutland
2022-01-27 12:03           ` Ard Biesheuvel
2022-01-27 12:03             ` Ard Biesheuvel
2022-01-27 12:20             ` Mark Rutland
2022-01-27 12:20               ` Mark Rutland
2022-01-27 12:22               ` Ard Biesheuvel
2022-01-27 12:22                 ` Ard Biesheuvel
2022-01-27 12:59                 ` Mark Rutland
2022-01-27 12:59                   ` Mark Rutland
2022-01-27 13:07                   ` Ard Biesheuvel
2022-01-27 13:07                     ` Ard Biesheuvel
2022-01-27 13:24                     ` Mark Rutland
2022-01-27 13:24                       ` Mark Rutland
2022-01-27 13:59                       ` Ard Biesheuvel
2022-01-27 13:59                         ` Ard Biesheuvel
2022-01-27 14:54                         ` Mark Rutland
2022-01-27 14:54                           ` Mark Rutland
2022-01-27 15:01                           ` Ard Biesheuvel
2022-01-27 15:01                             ` Ard Biesheuvel
2022-01-27 12:04           ` Sven Schnelle
2022-01-27 12:04             ` Sven Schnelle
2022-01-27 12:27             ` Mark Rutland
2022-01-27 12:27               ` Mark Rutland
2022-01-27 12:46               ` Steven Rostedt
2022-01-27 12:46                 ` Steven Rostedt
2022-01-27 13:08                 ` Mark Rutland [this message]
2022-01-27 13:08                   ` Mark Rutland
2022-01-27 13:16                   ` Sven Schnelle
2022-01-27 13:16                     ` Sven Schnelle
2022-01-27 13:33                     ` Mark Rutland
2022-01-27 13:33                       ` Mark Rutland
2022-01-27 13:55                       ` Steven Rostedt
2022-01-27 13:55                         ` Steven Rostedt
2022-01-27 14:56                         ` Mark Rutland
2022-01-27 14:56                           ` Mark Rutland
2022-01-27 16:41           ` Kees Cook
2022-01-27 16:41             ` Kees Cook
2022-01-25  4:00     ` Sachin Sant
2022-01-25 14:28       ` Steven Rostedt

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=YfKZXvB9vCN1bA1c@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rostedt@goodmis.org \
    --cc=sachinp@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=yinan@linux.alibaba.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 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.