From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Jiri Kosina <jikos@kernel.org>
Cc: Miroslav Benes <mbenes@suse.cz>,
Seth Jennings <sjenning@redhat.com>,
Vojtech Pavlik <vojtech@suse.com>,
linux-kernel@vger.kernel.org, live-patching@vger.kernel.org,
"Cyril B." <cbay@alwaysdata.com>
Subject: Re: [PATCH] livepatch: Cleanup page permission changes
Date: Thu, 5 Nov 2015 09:17:59 -0600 [thread overview]
Message-ID: <20151105151759.GC28254@treble.redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1511051038160.22567@pobox.suse.cz>
On Thu, Nov 05, 2015 at 10:40:26AM +0100, Jiri Kosina wrote:
> On Thu, 5 Nov 2015, Jiri Kosina wrote:
>
> > > > > +#ifdef CONFIG_DEBUG_SET_MODULE_RONX
> > > > > +static void set_page_attributes(void *start, void *end,
> > > > > + int (*set)(unsigned long start, int num_pages))
> > > > > +{
> > > > > + unsigned long begin_pfn = PFN_DOWN((unsigned long)start);
> > > > > + unsigned long end_pfn = PFN_DOWN((unsigned long)end);
> > > > > +
> > > > > + if (end_pfn > begin_pfn)
> > > > > + set(begin_pfn << PAGE_SHIFT, end_pfn - begin_pfn);
> > > > > +}
> >
> > BTW is there any reason not to make use of the function from module.c
> > which does exactly the same, instead of copy pasting it all around?
> >
> > > > > +static void set_module_ro_rw(struct module *mod)
> > > > > +{
> > > > > + set_page_attributes(mod->module_core,
> > > > > + mod->module_core + mod->core_ro_size,
> > > > > + set_memory_rw);
> > > > > +}
> > > > > +static void set_module_ro_ro(struct module *mod)
> > > >
> > > > Honestly, I find both the function names above horrible and not really
> > > > self-explanatory (especially the _ro_ro variant). At least comment,
> > > > explaining what they are actually doing, or picking up a better name,
> > > > would make the code much more self-explanatory in my eyes.
> > >
> > > Being the patch author, naturally the function names make sense to me.
> >
> > :)
> >
> > > set_module_ro_ro() means "set the module's read-only area to have
> > > read-only permissions."
> > >
> > > Do you have any suggestions for a better name?
> >
> > I'd even say it's superfluous to have the functions at the first place,
> > and just calling set_page_attributes() directly makes the intent clear
> > enough already.
>
> To make my proposal more clear:
>
> - move set_page_attributes() to module.h and provide empty stub for
> !CONFIG_DEBUG_SET_MODULE_RONX case (and probably rename it to something
> like module_set_page_attributes() to avoid namespace conflicts with mm
> code)
>
> - make use of that function both from module.c (where it's already being
> used) and livepatch.c, where it'd be called directly
Ok, I'll use the module.c version of set_page_attributes() and get rid
of the set_module_ro_(ro|rw) functions.
I'd rather keep set_page_attributes() named as it already is, because
there's nothing module-specific about it. It just happens to currently
live in module.c.
--
Josh
next prev parent reply other threads:[~2015-11-05 15:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 20:00 [PATCH] x86/livepatch: Fix crash with !CONFIG_DEBUG_SET_MODULE_RONX Josh Poimboeuf
2015-11-03 10:22 ` Miroslav Benes
2015-11-03 15:22 ` Josh Poimboeuf
2015-11-03 17:42 ` [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf
2015-11-04 9:18 ` Jiri Kosina
2015-11-04 16:10 ` Josh Poimboeuf
2015-11-04 16:13 ` Josh Poimboeuf
2015-11-04 9:40 ` Miroslav Benes
2015-11-04 22:56 ` Jiri Kosina
2015-11-04 23:12 ` Josh Poimboeuf
2015-11-05 9:28 ` Jiri Kosina
2015-11-05 9:40 ` Jiri Kosina
2015-11-05 15:17 ` Josh Poimboeuf [this message]
2015-11-05 17:33 ` Josh Poimboeuf
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=20151105151759.GC28254@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=cbay@alwaysdata.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=sjenning@redhat.com \
--cc=vojtech@suse.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.