[email protected]>, Masahiro Yamada <[email protected]>, Jarkko Sakkinen 
<[email protected]>, Sami Tolvanen <[email protected]>, "Naveen N. Rao" 
<[email protected]>, Marco Elver <[email protected]>, Kees Cook 
<[email protected]>, Steven Rostedt <[email protected]>, Nathan 
Chancellor <[email protected]>, "Russell King \(Oracle\)" 
<[email protected]>, Mark Brown <[email protected]>, Borislav Petkov 
<[email protected]>, Alexander Egorenkov <[email protected]>, Thomas 
Bogendoerfer <[email protected]>, Parisc List 
<[email protected]>, Nathaniel McCallum <[email protected]>, 
Dmitry Torokhov <[email protected]>, "David S. Miller" 
<[email protected]>, "Kirill A. Shutemov" <[email protected]>, 
Tobias Huschle <[email protected]>, "Peter Zijlstra \(Intel\)" 
<[email protected]>, "H. Peter Anvin" <[email protected]>, sparclinux 
<[email protected]>, Tiezhu Yang <[email protected]>, Miroslav 
Benes <mbenes@
 suse.cz>, Chen Zhongjin <[email protected]>, linux-riscv 
<[email protected]>, the arch/x86 maintainers <[email protected]>, 
Russell King <[email protected]>, Ingo Molnar <[email protected]>, Aaron 
Tomlin <[email protected]>, Albert Ou <[email protected]>, Heiko Carstens 
<[email protected]>, Liao Chang <[email protected]>, Paul Walmsley 
<[email protected]>, Josh Poimboeuf <[email protected]>, Thomas 
Richter <[email protected]>, "open list:BROADCOM NVRAM DRIVER" 
<[email protected]>, Changbin Du <[email protected]>, Palmer 
Dabbelt <[email protected]>, linuxppc-dev <[email protected]>, 
[email protected]
Errors-To: [email protected]
Sender: "Linuxppc-dev" 
<[email protected]>

On Thu, Jun 09, 2022 at 03:23:16PM +0200, Ard Biesheuvel wrote:
> On Thu, 9 Jun 2022 at 15:14, Jarkko Sakkinen <[email protected]> wrote:
> >
> > On Wed, Jun 08, 2022 at 09:12:34AM -0700, Song Liu wrote:
> > > On Wed, Jun 8, 2022 at 7:21 AM Masami Hiramatsu <[email protected]> 
> > > wrote:
> > > >
> > > > Hi Jarkko,
> > > >
> > > > On Wed, 8 Jun 2022 08:25:38 +0300
> > > > Jarkko Sakkinen <[email protected]> wrote:
> > > >
> > > > > On Wed, Jun 08, 2022 at 10:35:42AM +0800, Guo Ren wrote:
> > > > > > .
> > > > > >
> > > > > > On Wed, Jun 8, 2022 at 8:02 AM Jarkko Sakkinen <[email protected]> 
> > > > > > wrote:
> > > > > > >
> > > > > > > Tracing with kprobes while running a monolithic kernel is 
> > > > > > > currently
> > > > > > > impossible because CONFIG_KPROBES is dependent of CONFIG_MODULES. 
> > > > > > >  This
> > > > > > > dependency is a result of kprobes code using the module allocator 
> > > > > > > for the
> > > > > > > trampoline code.
> > > > > > >
> > > > > > > Detaching kprobes from modules helps to squeeze down the user 
> > > > > > > space,
> > > > > > > e.g. when developing new core kernel features, while still having 
> > > > > > > all
> > > > > > > the nice tracing capabilities.
> > > > > > >
> > > > > > > For kernel/ and arch/*, move module_alloc() and module_memfree() 
> > > > > > > to
> > > > > > > module_alloc.c, and compile as part of vmlinux when either 
> > > > > > > CONFIG_MODULES
> > > > > > > or CONFIG_KPROBES is enabled.  In addition, flag kernel module 
> > > > > > > specific
> > > > > > > code with CONFIG_MODULES.
> > > > > > >
> > > > > > > As the result, kprobes can be used with a monolithic kernel.
> > > > > > It's strange when MODULES is n, but vmlinux still obtains 
> > > > > > module_alloc.
> > > > > >
> > > > > > Maybe we need a kprobe_alloc, right?
> > > > >
> > > > > Perhaps not the best name but at least it documents the fact that
> > > > > they use the same allocator.
> > > > >
> > > > > Few years ago I carved up something "half-way there" for kprobes,
> > > > > and I used the name text_alloc() [*].
> > > > >
> > > > > [*] 
> > > > > https://lore.kernel.org/all/[email protected]/
> > > >
> > > > Yeah, I remember that. Thank you for updating your patch!
> > > > I think the idea (split module_alloc() from CONFIG_MODULE) is good to 
> > > > me.
> > > > If module support maintainers think this name is not good, you may be
> > > > able to rename it as text_alloc() and make the module_alloc() as a
> > > > wrapper of it.
> > >
> > > IIUC, most users of module_alloc() use it to allocate memory for text, 
> > > except
> > > that module code uses it for both text and data. Therefore, I guess 
> > > calling it
> > > text_alloc() is not 100% accurate until we change the module code (to use
> > > a different API to allocate memory for data).
> >
> > After reading the feedback, I'd stay on using module_alloc() because
> > it has arch-specific quirks baked in. Easier to deal with them in one
> > place.
> >
> 
> In that case, please ensure that you enable this only on architectures
> where it is needed. arm64 implements alloc_insn_page() without relying
> on module_alloc() so I would not expect to see any changes there.

Right, got it, thanks for remark.

BR, Jarkko

Reply via email to