[PATCH] powerpc/misc: fix exported functions that reference the TOC

Michael Ellerman mpe at ellerman.id.au
Mon Apr 3 23:29:59 AEST 2017


Oliver O'Halloran <oohall at gmail.com> writes:

> When the kernel is compiled to use 64bit ABIv2 the _GLOBAL() macro does not
> include a global entry point. A function's global entry point is used when the
> function is called from a different TOC context and in the kernel this
> typically means a call from a module into the vmlinux (or vis-a-vis).
>
> There are a few exported ASM functions declared with _GLOBAL() and calling
> them from a module will module will likely crash the kernel since any TOC
> relative load will yield garbage.
>
> To fix this use _GLOBAL_TOC() for exported asm functions rather than _GLOBAL()
> and some documentation about when to use each.

I wonder if we should just change _GLOBAL() to include the global entry
point. Persisting with _GLOBAL_TOC() seems like it's just going to be a
game of whack-a-mole.

Just grepping now I see ~50 functions defined with _GLOBAL() which are
also EXPORT'ed. Now presumably none of them use the TOC? But there's no
way to verify it, other than inspecting each one, and there's no way to
ensure we don't break it again in future.

The other option would be just to make a rule that anything EXPORT'ed
must use _GLOBAL_TOC().

cheers


More information about the Linuxppc-dev mailing list