From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org
Cc: anil.s.keshavamurthy@intel.com, aou@eecs.berkeley.edu,
catalin.marinas@arm.com, davem@davemloft.net, jarkko@kernel.org,
linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com,
mhiramat@kernel.org, naveen.n.rao@linux.ibm.com,
palmer@dabbelt.com, paul.walmsley@sifive.com, will@kernel.org
Subject: [PATCH v2 0/4] kprobes: permit use without modules
Date: Wed, 3 Apr 2024 16:01:50 +0100 [thread overview]
Message-ID: <20240403150154.667649-1-mark.rutland@arm.com> (raw)
Currently KPROBES depends on MODULES and cannot be built when support
for modules is not enabled. This is largely an artifact of the
default/generic code for allocating insn pages using module_alloc(),
though several architectures do not use this and have no strict
dependency on MODULES. It would be nice to allow KPROBES to be used
without MODULES, as this can be useful for testing and/or in certain
constrained environments.
This series (based on v6.9-rc1) removes the artificial dependency on
MODULES. This permits (but does not require) that architectures which
don't use module_alloc() to allocate kprobe insn pages can support
kprobes when module support is not enabled.
The series deliberately avoids adding a common text allocator, as the
requirements for allocating kprobe memory van vary by architecture, and
can differ from other text allocations. However, architectures can
easily call a common allocator if they wish, and this series does not
preclude using common allocators immediately or in future.
The key change is in patch 3. This requires that architectures which
provide their own alloc function must provide the corresponding free
function and select HAVE_KPROBES_ALLOC with any appropriate dependencies
for their implementation. Architectures which use the generic functions
are left as-is with a dependency on MODULES.
The final patch allows the core kprobes code to be built without
MODULES, and removes the explicit dependency from Kconfig. This is
derived from Jarkko's recent v6 attempt:
https://lore.kernel.org/lkml/20240326012102.27438-1-jarkko@kernel.org/
With the series applied, arm64 and riscv can enable KPROBES without
MODULES, while powerpc/s390/x86 are still depend on MODULES as their
alloc functions currently use module_alloc(), and all other
architectures with KPROBES uses the generic implementation that depends
on MODULES. I believe it should be relatively easy to enable
powerpc/s390/x86 to not depend on MODULES.
Since v1 [1]:
* Rebase to v6.9-rc2 (trivial)
* Update to Jarkko's v7 cleanups for core kprobes
* Fix accidental use of KPROBES_USE_MODULE_ALLOC
* Improve commit messages
* Update Cc lists
[1] https://lore.kernel.org/lkml/20240326163624.3253157-1-mark.rutland@arm.com/
Mark.
Jarkko Sakkinen (1):
kprobes: Remove core dependency on modules
Mark Rutland (3):
arm64: patching: always use fixmap
kprobes/treewide: Add kprobes_ prefix to insn alloc/free functions
kprobes/treewide: Explicitly override alloc/free functions
arch/Kconfig | 5 ++-
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/patching.c | 10 ++---
arch/arm64/kernel/probes/kprobes.c | 7 ++-
arch/powerpc/Kconfig | 3 +-
arch/powerpc/kernel/kprobes.c | 7 ++-
arch/powerpc/kernel/optprobes.c | 4 +-
arch/riscv/Kconfig | 1 +
arch/riscv/kernel/probes/kprobes.c | 7 ++-
arch/s390/Kconfig | 3 +-
arch/s390/kernel/kprobes.c | 7 ++-
arch/x86/Kconfig | 3 +-
arch/x86/kernel/kprobes/core.c | 7 ++-
include/linux/kprobes.h | 7 +--
kernel/kprobes.c | 68 +++++++++++++++++-------------
kernel/trace/trace_kprobe.c | 15 ++++++-
16 files changed, 103 insertions(+), 52 deletions(-)
--
2.30.2
next reply other threads:[~2024-04-03 15:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 15:01 Mark Rutland [this message]
2024-04-03 15:01 ` [PATCH v2 1/4] arm64: patching: always use fixmap Mark Rutland
2024-04-03 16:20 ` Jarkko Sakkinen
2024-04-03 16:51 ` Mark Rutland
2024-04-04 14:48 ` Jarkko Sakkinen
2024-04-03 17:52 ` Catalin Marinas
2024-04-03 23:44 ` Masami Hiramatsu
2024-04-03 15:01 ` [PATCH v2 2/4] kprobes/treewide: Add kprobes_ prefix to insn alloc/free functions Mark Rutland
2024-04-03 16:39 ` Jarkko Sakkinen
2024-04-03 15:01 ` [PATCH v2 3/4] kprobes/treewide: Explicitly override " Mark Rutland
2024-04-03 16:40 ` Jarkko Sakkinen
2024-04-03 15:01 ` [PATCH v2 4/4] kprobes: Remove core dependency on modules Mark Rutland
2024-04-03 16:41 ` Jarkko Sakkinen
2024-04-04 8:15 ` Jarkko Sakkinen
2024-04-04 15:18 ` Jarkko Sakkinen
2024-04-04 16:10 ` Masami Hiramatsu
2024-04-04 16:47 ` Mark Rutland
2024-04-05 3:13 ` Masami Hiramatsu
2024-04-13 20:16 ` Jarkko Sakkinen
2024-04-11 22:54 ` Jarkko Sakkinen
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=20240403150154.667649-1-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=catalin.marinas@arm.com \
--cc=davem@davemloft.net \
--cc=jarkko@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--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
all inboxes | Powered by JetHome®