Patch "powerpc: Simplify module TOC handling" has been added to the 4.4-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handling
From: Alan Modra <[email protected]>
commit c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9 upstream.
PowerPC64 uses the symbol .TOC. much as other targets use _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in powerpc parlance, the TOC pointer). Global offset tables are generally local to an executable or shared library, or in the kernel, module. Thus it does not make sense for a module to resolve a relocation against .TOC. to the kernel's .TOC. value. A module has its own .TOC., and indeed the powerpc64 module relocation processing ignores the kernel value of .TOC. and instead calculates a module-local value.
This patch removes code involved in exporting the kernel .TOC., tweaks modpost to ignore an undefined .TOC., and the module loader to twiddle the section symbol so that .TOC. isn't seen as undefined.
Note that if the kernel was compiled with -msingle-pic-base then ELFv2 would not have function global entry code setting up r2. In that case the module call stubs would need to be modified to set up r2 using the kernel .TOC. value, requiring some of this code to be reinstated.
mpe: Furthermore a change in binutils master (not yet released) causes the current way we handle the TOC to no longer work when building with MODVERSIONS=y and RELOCATABLE=n. The symptom is that modules can not be loaded due to there being no version found for TOC.
--- arch/powerpc/kernel/misc_64.S | 28 ---------------------------- arch/powerpc/kernel/module_64.c | 12 +++++++++--- scripts/mod/modpost.c | 3 ++- 3 files changed, 11 insertions(+), 32 deletions(-)
arch/powerpc/kernel/misc_64.S +0 -28
@@ -701,31 +701,3 @@ _GLOBAL(kexec_sequence) li r5,0 blr /* image->start(physid, image->start, 0); */ #endif /* CONFIG_KEXEC */ - -#ifdef CONFIG_MODULES -#if defined(_CALL_ELF) && _CALL_ELF == 2 - -#ifdef CONFIG_MODVERSIONS -.weak __crc_TOC. -.section "___kcrctab+TOC.","a" -.globl __kcrctab_TOC. -__kcrctab_TOC.: - .llong __crc_TOC. -#endif - -/* - * Export a fake .TOC. since both modpost and depmod will complain otherwise. - * Both modpost and depmod strip the leading . so we do the same here. - */ -.section "__ksymtab_strings","a" -__kstrtab_TOC.: - .asciz "TOC." - -.section "___ksymtab+TOC.","a" -/* This symbol name is important: it's used by modpost to find exported syms */ -.globl __ksymtab_TOC. -__ksymtab_TOC.: - .llong 0 /* .value */ - .llong __kstrtab_TOC. -#endif /* ELFv2 */ -#endif /* MODULES */
arch/powerpc/kernel/module_64.c +9 -3
@@ -326,7 +326,10 @@ static void dedotify_versions(struct mod } } -/* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */ +/* +* Undefined symbols which refer to .funcname, hack to funcname. Make .TOC. +* seem to be defined (value set later). +*/ static void dedotify (Elf64_Sym *syms,unsigned int numsyms,char *strtab) {unsigned int i;
@@ -334,8 +337,11 @@ static void dedotify(Elf64_Sym *syms, unfor (i =1 ; i < numsyms; i++) {if (syms[i].st_shndx ==SHN_UNDEF ) {char *name = strtab + syms[i].st_name; -if (name[0 ] =='.' ) +if (name[0 ] =='.' ) { +if (strcmp (name+1 ,"TOC." ) ==0 ) + syms[i].st_shndx =SHN_ABS ;memmove (name, name+1 ,strlen (name)); + } } } }
@@ -351,7 +357,7 @@ static Elf64_Sym *find_dot_toc(Elf64_Shd numsyms = sechdrs[symindex].sh_size /sizeof (Elf64_Sym);for (i =1 ; i < numsyms; i++) { -if (syms[i].st_shndx ==SHN_UNDEF +if (syms[i].st_shndx ==SHN_ABS &&strcmp (strtab + syms[i].st_name,"TOC." ) ==0 )return &syms[i]; }
scripts/mod/modpost.c +2 -1
@@ -594,7 +594,8 @@ static int ignore_undef_symbol(struct elif (strncmp (symname,"_restgpr0_" ,sizeof ("_restgpr0_" ) -1 ) ==0 ||strncmp (symname,"_savegpr0_" ,sizeof ("_savegpr0_" ) -1 ) ==0 ||strncmp (symname,"_restvr_" ,sizeof ("_restvr_" ) -1 ) ==0 || -strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 ) +strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 || +strcmp (symname,".TOC." ) ==0 )return 1 ;/* Do not ignore this symbol */ return 0 ;
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/powerpc-simplify-module-toc-handling.patch
Michael Ellerman
reviewerQuoted 16 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 8 lines
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.
Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Sorry for the churn.
cheers
Greg KH
maintainerQuoted 24 lines · Michael Ellerman
Quoted 23 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
Quoted 7 lines
Quoted 1 line
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
If I drop this one, then the next patch in the series, "powerpc: Fix dedotify for binutils >= 2.26" does not apply, so I'll have to drop that as well. Is that acceptable?
thanks,
greg k-h
Michael Ellerman
reviewerQuoted 27 lines · Greg KH
Quoted 26 lines · Michael Ellerman
Quoted 24 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.
Quoted 8 lines
Quoted 4 lines
Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
If I drop this one, then the next patch in the series, "powerpc: Fix dedotify for binutils >= 2.26" does not apply, so I'll have to drop that as well. Is that acceptable?
Yeah that's OK.
I'll send a backport for that one.
cheers
Greg KH
maintainerQuoted 33 lines · Michael Ellerman
Quoted 32 lines · Greg KH
Quoted 30 lines · Michael Ellerman
Quoted 16 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 8 lines
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Quoted 7 lines
Quoted 3 lines
If I drop this one, then the next patch in the series, "powerpc: Fix dedotify for binutils >= 2.26" does not apply, so I'll have to drop that as well. Is that acceptable?
Yeah that's OK.
I'll send a backport for that one.
Ok, please do so, as I've now dropped both of those patches from the tree.
greg k-h
Quoted 25 lines · Michael Ellerman
Quoted 24 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
Quoted 8 lines
Quoted 1 line
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Sorry for the churn.
Is that specifically for ppc64el? Module loading has been completely broken in powerpc 64-bit kernels in Debian unstable since we got binutils 2.26 and these two patches certainly fixed the big-endian case without any need for a new kmod.
Ben.
Signature · 2 lines
Ben Hutchings Sturgeon's Law: Ninety percent of everything is crap.
Michael Ellerman
reviewerQuoted 32 lines · Ben Hutchings
Quoted 31 lines · Michael Ellerman
Quoted 16 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch
and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 8 lines
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Quoted 6 lines
Quoted 1 line
Sorry for the churn.
Is that specifically for ppc64el? Module loading has been completely broken in powerpc 64-bit kernels in Debian unstable since we got binutils 2.26 and these two patches certainly fixed the big-endian case without any need for a new kmod.
Yes, it's only required on LE.
I'll have to defer to Alan on the details, but on BE we don't see those relocations against .TOC. and so none of this matters.
cheers
Quoted 36 lines · Michael Ellerman
Quoted 35 lines · Ben Hutchings
Quoted 33 lines · Michael Ellerman
Quoted 17 lines · On Tue, 2016-02-23 at 19:24 -0800, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
powerpc: Simplify module TOC handling
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
powerpc-simplify-module-toc-handling.patch and it can be found in the queue-4.4 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 8 lines
From
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Fri, 15 Jan 2016 20:52:22 +1100
Subject: powerpc: Simplify module TOC handlingFrom: Alan Modra <[email protected]>
commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9upstream.Hi Greg,
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Sorry for the churn.
Quoted 8 lines
Quoted 4 lines
Is that specifically for ppc64el? Module loading has been completely broken in powerpc 64-bit kernels in Debian unstable since we got binutils 2.26 and these two patches certainly fixed the big-endian case without any need for a new kmod.
Yes, it's only required on LE.
I'll have to defer to Alan on the details, but on BE we don't see those relocations against .TOC. and so none of this matters.
The following patch "powerpc: Fix dedotify for binutils >= 2.26" certainly is needed for BE, so someone should send Greg a version that applies on top of 4.4 without the TOC change. (It could even be me, but my patch/compile/test cycle on powerpc is rather slow.)
Ben.
Signature · 2 lines
Ben Hutchings When in doubt, use brute force. - Ken Thompson
Michael Ellerman
reviewerQuoted 5 lines · Ben Hutchings
The following patch "powerpc: Fix dedotify for binutils >= 2.26" certainly is needed for BE, so someone should send Greg a version that applies on top of 4.4 without the TOC change. (It could even be me, but my patch/compile/test cycle on powerpc is rather slow.)
Yep, it's on my very long TODO list.
I'll try and send it out today.
cheers