All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>
Cc: <linux-riscv@lists.infradead.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	<linux-kernel@vger.kernel.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	<linux-modules@vger.kernel.org>,
	"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
	"Anil S Keshavamurthy" <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH v5 1/2] kprobes: textmem API
Date: Tue, 26 Mar 2024 04:01:23 +0200	[thread overview]
Message-ID: <D03B7XJYRFC1.2L3I2TO5HNQD3@kernel.org> (raw)
In-Reply-To: <D03AL7A5G3M2.3UK4ASWILGBJS@kernel.org>

On Tue Mar 26, 2024 at 3:31 AM EET, Jarkko Sakkinen wrote:
> > > +#endif /* _LINUX_EXECMEM_H */
> > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > > index 9d9095e81792..87fd8c14a938 100644
> > > --- a/kernel/kprobes.c
> > > +++ b/kernel/kprobes.c
> > > @@ -44,6 +44,7 @@
> > >  #include <asm/cacheflush.h>
> > >  #include <asm/errno.h>
> > >  #include <linux/uaccess.h>
> > > +#include <linux/execmem.h>
> > >  
> > >  #define KPROBE_HASH_BITS 6
> > >  #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
> > > @@ -113,17 +114,17 @@ enum kprobe_slot_state {
> > >  void __weak *alloc_insn_page(void)
> > >  {
> > >  	/*
> > > -	 * Use module_alloc() so this page is within +/- 2GB of where the
> > > +	 * Use alloc_execmem() so this page is within +/- 2GB of where the
> > >  	 * kernel image and loaded module images reside. This is required
> > >  	 * for most of the architectures.
> > >  	 * (e.g. x86-64 needs this to handle the %rip-relative fixups.)
> > >  	 */
> > > -	return module_alloc(PAGE_SIZE);
> > > +	return alloc_execmem(PAGE_SIZE, GFP_KERNEL);
> > >  }
> > >  
> > >  static void free_insn_page(void *page)
> > >  {
> > > -	module_memfree(page);
> > > +	free_execmem(page);
> > >  }
> > >  
> > >  struct kprobe_insn_cache kprobe_insn_slots = {
> > > @@ -1580,6 +1581,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
> > >  		goto out;
> > >  	}
> > >  
> > > +#ifdef CONFIG_MODULES
> >
> > You don't need this block, because these APIs have dummy functions.
>
> Hmm... I'll verify this tomorrow.

It depends on having struct module available given "(*probed_mod)->state".

It is non-existent unless CONFIG_MODULES is set given how things are
flagged in include/linux/module.h.

BR, Jarkko

WARNING: multiple messages have this Message-ID (diff)
From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>
Cc: <linux-riscv@lists.infradead.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	<linux-kernel@vger.kernel.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	<linux-modules@vger.kernel.org>,
	"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
	"Anil S Keshavamurthy" <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH v5 1/2] kprobes: textmem API
Date: Tue, 26 Mar 2024 04:01:23 +0200	[thread overview]
Message-ID: <D03B7XJYRFC1.2L3I2TO5HNQD3@kernel.org> (raw)
In-Reply-To: <D03AL7A5G3M2.3UK4ASWILGBJS@kernel.org>

On Tue Mar 26, 2024 at 3:31 AM EET, Jarkko Sakkinen wrote:
> > > +#endif /* _LINUX_EXECMEM_H */
> > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > > index 9d9095e81792..87fd8c14a938 100644
> > > --- a/kernel/kprobes.c
> > > +++ b/kernel/kprobes.c
> > > @@ -44,6 +44,7 @@
> > >  #include <asm/cacheflush.h>
> > >  #include <asm/errno.h>
> > >  #include <linux/uaccess.h>
> > > +#include <linux/execmem.h>
> > >  
> > >  #define KPROBE_HASH_BITS 6
> > >  #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
> > > @@ -113,17 +114,17 @@ enum kprobe_slot_state {
> > >  void __weak *alloc_insn_page(void)
> > >  {
> > >  	/*
> > > -	 * Use module_alloc() so this page is within +/- 2GB of where the
> > > +	 * Use alloc_execmem() so this page is within +/- 2GB of where the
> > >  	 * kernel image and loaded module images reside. This is required
> > >  	 * for most of the architectures.
> > >  	 * (e.g. x86-64 needs this to handle the %rip-relative fixups.)
> > >  	 */
> > > -	return module_alloc(PAGE_SIZE);
> > > +	return alloc_execmem(PAGE_SIZE, GFP_KERNEL);
> > >  }
> > >  
> > >  static void free_insn_page(void *page)
> > >  {
> > > -	module_memfree(page);
> > > +	free_execmem(page);
> > >  }
> > >  
> > >  struct kprobe_insn_cache kprobe_insn_slots = {
> > > @@ -1580,6 +1581,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
> > >  		goto out;
> > >  	}
> > >  
> > > +#ifdef CONFIG_MODULES
> >
> > You don't need this block, because these APIs have dummy functions.
>
> Hmm... I'll verify this tomorrow.

It depends on having struct module available given "(*probed_mod)->state".

It is non-existent unless CONFIG_MODULES is set given how things are
flagged in include/linux/module.h.

BR, Jarkko

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

  reply	other threads:[~2024-03-26  2:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 21:55 [PATCH v5 1/2] kprobes: textmem API Jarkko Sakkinen
2024-03-25 21:55 ` Jarkko Sakkinen
2024-03-25 21:55 ` [PATCH v5 2/2] arch/riscv: Enable kprobes when CONFIG_MODULES=n Jarkko Sakkinen
2024-03-25 21:55   ` Jarkko Sakkinen
2024-03-26 13:57   ` Alexandre Ghiti
2024-03-26 13:57     ` Alexandre Ghiti
2024-03-26 16:49     ` Jarkko Sakkinen
2024-03-26 16:49       ` Jarkko Sakkinen
2024-03-26 16:54       ` Jarkko Sakkinen
2024-03-26 16:54         ` Jarkko Sakkinen
2024-03-26 19:03       ` Alexandre Ghiti
2024-03-26 19:03         ` Alexandre Ghiti
2024-03-25 22:06 ` [PATCH v5 1/2] kprobes: textmem API Jarkko Sakkinen
2024-03-25 22:06   ` Jarkko Sakkinen
2024-03-25 22:09 ` Jarkko Sakkinen
2024-03-25 22:09   ` Jarkko Sakkinen
2024-03-25 22:16   ` Jarkko Sakkinen
2024-03-25 22:16     ` Jarkko Sakkinen
2024-03-25 23:50   ` Masami Hiramatsu
2024-03-25 23:50     ` Masami Hiramatsu
2024-03-26  0:36     ` Jarkko Sakkinen
2024-03-26  0:36       ` Jarkko Sakkinen
2024-03-26  0:58 ` Masami Hiramatsu
2024-03-26  0:58   ` Masami Hiramatsu
2024-03-26  1:31   ` Jarkko Sakkinen
2024-03-26  1:31     ` Jarkko Sakkinen
2024-03-26  2:01     ` Jarkko Sakkinen [this message]
2024-03-26  2:01       ` Jarkko Sakkinen
2024-03-26 13:18       ` Jarkko Sakkinen
2024-03-26 13:18         ` Jarkko Sakkinen
2024-03-26 15:05         ` Masami Hiramatsu
2024-03-26 15:05           ` Masami Hiramatsu
2024-03-26 17:02           ` Jarkko Sakkinen
2024-03-26 17:02             ` 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=D03B7XJYRFC1.2L3I2TO5HNQD3@kernel.org \
    --to=jarkko@kernel.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.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.