All of lore.kernel.org
 help / color / mirror / Atom feed
* module loading issue/flaw in busy memory situation?
@ 2012-05-24 20:05 Wrobel Heinz-R39252
  0 siblings, 0 replies; 2+ messages in thread
From: Wrobel Heinz-R39252 @ 2012-05-24 20:05 UTC (permalink / raw)
  To: linuxppc-dev@lists.ozlabs.org

[-- Attachment #1: Type: text/plain, Size: 1905 bytes --]

Hi,

let's assume a module gets loaded into an already busy system, and the ".init.text" section with the __init function gets loaded into one memory region, and the normal ".text" section gets loaded into a totally different memory region.
Now assume that both regions are >32MB apart in addressing, so that a call from the __init .init.text function to any function in .text requires a trampoline as set up by the do_plt_call() function in arch/kernel/module*.c
So far so good for user code.

Now assume that the __init function is not trivial and will require register save/restore functions in prologue/epilogue with such calls generated by gcc, e.g., the __init function calls _rest32gpr_28_x() in the epilogue. This restore functions however is in the .text section due to the static link of the normal libs.

Now we have the __init function calling the trampoline, which is destroying r11. The trampoline is then jumping to the register restore function which relies on r11 still being intact, which it now isn't anymore.
Net result is a crash because the trampoline ABI conflicts with the register restore ABI and you get a case of garbage in leading to garbage out.

This situation has apparently occurred based on the debug results I have here.

In the general case of module development it seems unpredictable if gcc will actually call a register restore function from the __init function, or if the sections get loaded to require a trampoline, so for any non-trivial function in non-trivial memory setups, a crash would have to be expected, depending on the time of day and moon phase when the module gets loaded.

Is this a fundamental flaw in the interaction of the module section use specification and the module load mechanism with the ABI definition?

Or am I missing some incorrect setup or requirement for __init functions that I should deal with?

Thanks,

Heinz

[-- Attachment #2: Type: text/html, Size: 4382 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: module loading issue/flaw in busy memory situation?
@ 2012-05-25  7:56 Steffen Rumler
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Rumler @ 2012-05-25  7:56 UTC (permalink / raw)
  To: linuxppc-dev

Hi,

The basic question is, has the GPR r11 a dedicated function (to point to the previous stack frame)
or is it still a volatile GPR, according to EABI definition ?
In the case of a dedicated function was assigned, the trampoline code generation in

     arch/powerpc/kernel/module_32.c

must be corrected. I'd suggest to use r12 instead of r11, in this case.

Best Regards
Steffen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-25  8:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25  7:56 module loading issue/flaw in busy memory situation? Steffen Rumler
  -- strict thread matches above, loose matches on Subject: below --
2012-05-24 20:05 Wrobel Heinz-R39252

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.