* Re: [Patch 4/4] module: trim exception table in module_free() [not found] ` <20090526083751.5050.60959.sendpatchset@localhost.localdomain> @ 2009-05-27 2:21 ` Rusty Russell 2009-05-27 3:11 ` Amerigo Wang 0 siblings, 1 reply; 8+ messages in thread From: Rusty Russell @ 2009-05-27 2:21 UTC (permalink / raw) To: Amerigo Wang, linux-alpha Cc: linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 On Tue, 26 May 2009 06:05:39 pm Amerigo Wang wrote: > void module_free(struct module *mod, void *module_region) > { > vfree(module_region); > - /* FIXME: If module_region == mod->init_region, trim exception > - table entries. */ > + if (module_region == mod->module_init) > + mod->num_exentries = 0; > } Hi Amerigo, This looks wrong. The extable covers both init and core exception entries. We want to remove the ones in the module_init section. The good news is that it's sorted, so they're either at the start or the end (except sparc 32). The bad news is that this is really a generic problem, and deserves a generic fix. That's easy for archs which use the generic sort_extable(), but alpha, ia64 and sparc(32) will need to define their own trim_extable(). Thanks! Rusty. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-27 2:21 ` [Patch 4/4] module: trim exception table in module_free() Rusty Russell @ 2009-05-27 3:11 ` Amerigo Wang 2009-05-27 5:23 ` Rusty Russell 0 siblings, 1 reply; 8+ messages in thread From: Amerigo Wang @ 2009-05-27 3:11 UTC (permalink / raw) To: Rusty Russell Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 Rusty Russell wrote: > On Tue, 26 May 2009 06:05:39 pm Amerigo Wang wrote: > >> void module_free(struct module *mod, void *module_region) >> { >> vfree(module_region); >> - /* FIXME: If module_region == mod->init_region, trim exception >> - table entries. */ >> + if (module_region == mod->module_init) >> + mod->num_exentries = 0; >> } >> > > Hi Amerigo, > > This looks wrong. The extable covers both init and core exception entries. > We want to remove the ones in the module_init section. The good news is that > it's sorted, so they're either at the start or the end (except sparc 32). > Hi, Rusty. Yes? The extable of a module is in '__ex_table' section, and during the section transfer, one section will be either in module_init or module_core, so its entries are only in one of them, not both, right? Thank you. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-27 3:11 ` Amerigo Wang @ 2009-05-27 5:23 ` Rusty Russell 2009-05-27 5:48 ` Amerigo Wang 2009-05-27 7:46 ` Amerigo Wang 0 siblings, 2 replies; 8+ messages in thread From: Rusty Russell @ 2009-05-27 5:23 UTC (permalink / raw) To: Amerigo Wang Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 On Wed, 27 May 2009 12:41:00 pm Amerigo Wang wrote: > Rusty Russell wrote: > > On Tue, 26 May 2009 06:05:39 pm Amerigo Wang wrote: > >> void module_free(struct module *mod, void *module_region) > >> { > >> vfree(module_region); > >> - /* FIXME: If module_region == mod->init_region, trim exception > >> - table entries. */ > >> + if (module_region == mod->module_init) > >> + mod->num_exentries = 0; > >> } > > > > Hi Amerigo, > > > > This looks wrong. The extable covers both init and core exception > > entries. We want to remove the ones in the module_init section. The good > > news is that it's sorted, so they're either at the start or the end > > (except sparc 32). > > Hi, Rusty. > > Yes? The extable of a module is in '__ex_table' section, and during the > section transfer, one > section will be either in module_init or module_core, so its entries are > only in one of them, > not both, right? 32-bit example: #include <linux/module.h> #include <linux/uaccess.h> #include <linux/moduleparam.h> static unsigned long uaddr; module_param(uaddr, ulong, 0600); void extable_not_init(u64 val) { __put_user(val, (u64 *)uaddr); } static int __init init(void) { __put_user(0, (u64 *)uaddr); return 0; } module_init(init); __ex_table ends up with two entries: Contents of section __ex_table: 0000 0c000000 00000000 0e000000 00000000 ................ 0010 10000000 0a000000 12000000 0a000000 ................ The first is for the __put_user in .text (extable_not_init()) and the second is for the one in .init.text (init()). Depending on how the module gets allocated, the one referring to .init.text may be first or last. (You can see here why we haven't fixed this: exceptions in __init in modules are rare, perhaps non-existent). Hope that clarifies? Rusty. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-27 5:23 ` Rusty Russell @ 2009-05-27 5:48 ` Amerigo Wang 2009-05-27 7:46 ` Amerigo Wang 1 sibling, 0 replies; 8+ messages in thread From: Amerigo Wang @ 2009-05-27 5:48 UTC (permalink / raw) To: Rusty Russell Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 Rusty Russell wrote: > __ex_table ends up with two entries: > > Contents of section __ex_table: > 0000 0c000000 00000000 0e000000 00000000 ................ > 0010 10000000 0a000000 12000000 0a000000 ................ > > The first is for the __put_user in .text (extable_not_init()) and the second is > for the one in .init.text (init()). > > Depending on how the module gets allocated, the one referring to .init.text > may be first or last. > Hmm, I understand now. The problem is that we don't know which entries are for __init, and which are not... > (You can see here why we haven't fixed this: exceptions in __init in modules > are rare, perhaps non-existent). > Agreed. Is it possible to put extable for __init in a separate section? Thanks for your explanation! ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-27 5:23 ` Rusty Russell 2009-05-27 5:48 ` Amerigo Wang @ 2009-05-27 7:46 ` Amerigo Wang 2009-05-28 6:55 ` Rusty Russell 1 sibling, 1 reply; 8+ messages in thread From: Amerigo Wang @ 2009-05-27 7:46 UTC (permalink / raw) To: Rusty Russell Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 Rusty Russell wrote: > __ex_table ends up with two entries: > > Contents of section __ex_table: > 0000 0c000000 00000000 0e000000 00000000 ................ > 0010 10000000 0a000000 12000000 0a000000 ................ > > The first is for the __put_user in .text (extable_not_init()) and the second is > for the one in .init.text (init()). > > Depending on how the module gets allocated, the one referring to .init.text > may be first or last. > Hmm, how about the following? :-) struct exception_table_entry *p = mod->extable; for (;p <= mod->extable+mod->num_exentries; p++ ) if (with_in_module_init(p->insn, mod)) trim_it(p); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-27 7:46 ` Amerigo Wang @ 2009-05-28 6:55 ` Rusty Russell 2009-05-31 5:15 ` Amerigo Wang 0 siblings, 1 reply; 8+ messages in thread From: Rusty Russell @ 2009-05-28 6:55 UTC (permalink / raw) To: Amerigo Wang Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 On Wed, 27 May 2009 05:16:11 pm Amerigo Wang wrote: > Rusty Russell wrote: > > __ex_table ends up with two entries: > > > > Contents of section __ex_table: > > 0000 0c000000 00000000 0e000000 00000000 ................ > > 0010 10000000 0a000000 12000000 0a000000 ................ > > > > The first is for the __put_user in .text (extable_not_init()) and the > > second is for the one in .init.text (init()). > > > > Depending on how the module gets allocated, the one referring to > > .init.text may be first or last. > > Hmm, how about the following? :-) > > struct exception_table_entry *p = mod->extable; > > for (;p <= mod->extable+mod->num_exentries; p++ ) > if (with_in_module_init(p->insn, mod)) > trim_it(p); More like this: void trim_init_extable(struct module *m) { /* Since entries are sorted, init entries are at the start... */ while (m->num_exentries && within_module_init(m->extable[0].insn)) { m->extable++; m->num_exentries--; } /* ... or the end. */ while (m->num_exentries && within_module_init(m->extable[m->num_exentries-1].insn)) m->num_exentries--; } Cheers, Rusty. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-28 6:55 ` Rusty Russell @ 2009-05-31 5:15 ` Amerigo Wang 2009-06-01 12:28 ` Rusty Russell 0 siblings, 1 reply; 8+ messages in thread From: Amerigo Wang @ 2009-05-31 5:15 UTC (permalink / raw) To: Rusty Russell Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 Rusty Russell wrote: > On Wed, 27 May 2009 05:16:11 pm Amerigo Wang wrote: > >> Rusty Russell wrote: >> >>> __ex_table ends up with two entries: >>> >>> Contents of section __ex_table: >>> 0000 0c000000 00000000 0e000000 00000000 ................ >>> 0010 10000000 0a000000 12000000 0a000000 ................ >>> >>> The first is for the __put_user in .text (extable_not_init()) and the >>> second is for the one in .init.text (init()). >>> >>> Depending on how the module gets allocated, the one referring to >>> .init.text may be first or last. >>> >> Hmm, how about the following? :-) >> >> struct exception_table_entry *p = mod->extable; >> >> for (;p <= mod->extable+mod->num_exentries; p++ ) >> if (with_in_module_init(p->insn, mod)) >> trim_it(p); >> > > More like this: > > void trim_init_extable(struct module *m) > { > /* Since entries are sorted, init entries are at the start... */ > while (m->num_exentries && within_module_init(m->extable[0].insn)) { > m->extable++; > m->num_exentries--; > } > > /* ... or the end. */ > while (m->num_exentries && within_module_init(m->extable[m->num_exentries-1].insn)) > m->num_exentries--; > } > Great! Thank you! But does this works on all arch? Or only except sparc32? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch 4/4] module: trim exception table in module_free() 2009-05-31 5:15 ` Amerigo Wang @ 2009-06-01 12:28 ` Rusty Russell 0 siblings, 0 replies; 8+ messages in thread From: Rusty Russell @ 2009-06-01 12:28 UTC (permalink / raw) To: Amerigo Wang Cc: linux-alpha, linux-kernel, akpm, jdike, mingo, sparclinux, linux-ia64 On Sun, 31 May 2009 02:45:44 pm Amerigo Wang wrote: > Rusty Russell wrote: > > On Wed, 27 May 2009 05:16:11 pm Amerigo Wang wrote: > >> Rusty Russell wrote: > >>> __ex_table ends up with two entries: > >>> > >>> Contents of section __ex_table: > >>> 0000 0c000000 00000000 0e000000 00000000 ................ > >>> 0010 10000000 0a000000 12000000 0a000000 ................ > >>> > >>> The first is for the __put_user in .text (extable_not_init()) and the > >>> second is for the one in .init.text (init()). > >>> > >>> Depending on how the module gets allocated, the one referring to > >>> .init.text may be first or last. > >> > >> Hmm, how about the following? :-) > >> > >> struct exception_table_entry *p = mod->extable; > >> > >> for (;p <= mod->extable+mod->num_exentries; p++ ) > >> if (with_in_module_init(p->insn, mod)) > >> trim_it(p); > > > > More like this: > > > > void trim_init_extable(struct module *m) > > { > > /* Since entries are sorted, init entries are at the start... */ > > while (m->num_exentries && within_module_init(m->extable[0].insn)) { > > m->extable++; > > m->num_exentries--; > > } > > > > /* ... or the end. */ > > while (m->num_exentries && > > within_module_init(m->extable[m->num_exentries-1].insn)) > > m->num_exentries--; > > } > > Great! Thank you! > But does this works on all arch? Or only except sparc32? Variations will work on all archs. sparc32 doesn't sort its exception table AFAICT, so it will need something more sophisticated (ISTR they have exception areas, so perhaps setting length to 0 would 'delete' them). Hope that helps, Rusty. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-06-01 12:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20090526083717.5050.32719.sendpatchset@localhost.localdomain>
[not found] ` <20090526083751.5050.60959.sendpatchset@localhost.localdomain>
2009-05-27 2:21 ` [Patch 4/4] module: trim exception table in module_free() Rusty Russell
2009-05-27 3:11 ` Amerigo Wang
2009-05-27 5:23 ` Rusty Russell
2009-05-27 5:48 ` Amerigo Wang
2009-05-27 7:46 ` Amerigo Wang
2009-05-28 6:55 ` Rusty Russell
2009-05-31 5:15 ` Amerigo Wang
2009-06-01 12:28 ` Rusty Russell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).