Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powerpc/ftrace: Reserve instructions from function entry for ftrace #2579

Closed
wants to merge 4 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: powerpc/ftrace: Reserve instructions from function entry for ftrace
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367

@kernel-patches-bot
Copy link
Author

Master branch: 9b6eb04
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 1b8c924
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 9e98ace
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 1b8c924
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b38101c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b75daca
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: d24d2a2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 086d490
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 9087c6f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: a33c0c7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: d0b3822
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b03e194
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 13c6a37
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 6966d4c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b4f7278
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: a19df71
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 08894d9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: c561d11
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 08d4dba
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 80bebeb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: dda7596
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 5e214f2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: c62dd8a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615367
version: 1

On some architectures, enabling function tracing results in multiple
instructions being emitted at function entry. As an example, on
powerpc64 with -mprofile-kernel, two instructions are emitted at
function entry:
	mflr	r0
	bl	_mcount

It is desirable to nop out both these instructions when ftrace is not
active. For that purpose, it is essential to mark both these
instructions as belonging to ftrace so that other kernel subsystems
(such as kprobes) do not modify these instructions.

Add support for this by allowing architectures to override
ftrace_cmp_recs() and to match against address ranges over and above a
single MCOUNT_INSN_SIZE.

For powerpc32, we mark the two instructions preceding the call to
_mcount() as belonging to ftrace.

For powerpc64, an additional aspect to consider is that functions can
have a global entry point for setting up the TOC when invoked from other
modules. If present, global entry point always involves two instructions
(addis/lis and addi). To handle this, we provide a custom
ftrace_init_nop() for powerpc64 where we identify functions having a
global entry point and record this information in the LSB of
dyn_ftrace->arch.mod. This information is used in ftrace_cmp_recs() to
reserve instructions from the global entry point.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reported-by: kernel test robot <lkp@intel.com>
…h address

On some architectures, ftrace location can include multiple
instructions, and does not necessarily match the function entry address
returned by kallsyms_lookup(). Drop the check in is_ftrace_location() to
accommodate the same.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
On certain architectures, ftrace can reserve multiple instructions at
function entry. Rather than rejecting kprobe on addresses other than the
exact ftrace call instruction, use the address returned by ftrace to
probe at the correct address when CONFIG_KPROBES_ON_FTRACE is enabled.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=615367 irrelevant now. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/615367=>bpf-next branch February 28, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants