linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: module: fix TOC symbol CRC
@ 2014-06-17 15:56 Laurent Dufour
  2014-06-18 23:44 ` Anton Blanchard
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Dufour @ 2014-06-17 15:56 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Anton Blanchard

The commit 71ec7c55ed91 introduced the magic symbol ".TOC." for ELFv2 ABI.
This symbol is built manually and has no CRC value computed. A zero value
is put in the CRC section to avoid modpost complaining about a missing CRC.
Unfortunately, this breaks the kernel module loading when the kernel is
relocated (kdump case for instance) because of the relocation applied to
the kcrctab values.

This patch compute a CRC value for the TOC symbol which will match the one
compute by the kernel when it is relocated - aka '0 - relocate_start' done in
maybe_relocated called by check_version (module.c).

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Cc: Anton Blanchard <anton@samba.org>
---
 arch/powerpc/kernel/module_64.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 077d2ce..a80c933 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -315,8 +315,15 @@ static void dedotify_versions(struct modversion_info *vers,
 	struct modversion_info *end;
 
 	for (end = (void *)vers + size; vers < end; vers++)
-		if (vers->name[0] == '.')
+		if (vers->name[0] == '.') {
 			memmove(vers->name, vers->name+1, strlen(vers->name));
+			/* The TOC symbol has no CRC computed. To avoid CRC
+			 * check failing, we must force it to the expected
+			 * value (see CRC check in module.c).
+			 */
+			if (!strcmp(vers->name, "TOC."))
+				vers->crc = -(unsigned long)reloc_start;
+		}
 }
 
 /* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */

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

* Re: [PATCH] powerpc: module: fix TOC symbol CRC
  2014-06-17 15:56 [PATCH] powerpc: module: fix TOC symbol CRC Laurent Dufour
@ 2014-06-18 23:44 ` Anton Blanchard
  2014-06-24  4:06   ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Anton Blanchard @ 2014-06-18 23:44 UTC (permalink / raw)
  To: Laurent Dufour, rusty; +Cc: linuxppc-dev


Hi Laurent,

> The commit 71ec7c55ed91 introduced the magic symbol ".TOC." for ELFv2
> ABI. This symbol is built manually and has no CRC value computed. A
> zero value is put in the CRC section to avoid modpost complaining
> about a missing CRC. Unfortunately, this breaks the kernel module
> loading when the kernel is relocated (kdump case for instance)
> because of the relocation applied to the kcrctab values.
> 
> This patch compute a CRC value for the TOC symbol which will match
> the one compute by the kernel when it is relocated - aka '0 -
> relocate_start' done in maybe_relocated called by check_version
> (module.c).

Adding Rusty since he maintains the module loader code.

Anton

> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> Cc: Anton Blanchard <anton@samba.org>
> ---
>  arch/powerpc/kernel/module_64.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/module_64.c
> b/arch/powerpc/kernel/module_64.c index 077d2ce..a80c933 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -315,8 +315,15 @@ static void dedotify_versions(struct
> modversion_info *vers, struct modversion_info *end;
>  
>  	for (end = (void *)vers + size; vers < end; vers++)
> -		if (vers->name[0] == '.')
> +		if (vers->name[0] == '.') {
>  			memmove(vers->name, vers->name+1, strlen(vers->name));
> +			/* The TOC symbol has no CRC computed. To avoid CRC
> +			 * check failing, we must force it to the expected
> +			 * value (see CRC check in module.c).
> +			 */
> +			if (!strcmp(vers->name, "TOC."))
> +				vers->crc = -(unsigned long)reloc_start;
> +		}
>  }
>  
>  /* Undefined symbols which refer to .funcname, hack to funcname
> (or .TOC.) */

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

* Re: [PATCH] powerpc: module: fix TOC symbol CRC
  2014-06-18 23:44 ` Anton Blanchard
@ 2014-06-24  4:06   ` Benjamin Herrenschmidt
  2014-06-24  8:42     ` Laurent Dufour
  2014-06-24  8:53     ` [PATCH V2] " Laurent Dufour
  0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-24  4:06 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: rusty, Laurent Dufour, linuxppc-dev

On Thu, 2014-06-19 at 09:44 +1000, Anton Blanchard wrote:
> Hi Laurent,
> 
> > The commit 71ec7c55ed91 introduced the magic symbol ".TOC." for ELFv2
> > ABI. This symbol is built manually and has no CRC value computed. A
> > zero value is put in the CRC section to avoid modpost complaining
> > about a missing CRC. Unfortunately, this breaks the kernel module
> > loading when the kernel is relocated (kdump case for instance)
> > because of the relocation applied to the kcrctab values.
> > 
> > This patch compute a CRC value for the TOC symbol which will match
> > the one compute by the kernel when it is relocated - aka '0 -
> > relocate_start' done in maybe_relocated called by check_version
> > (module.c).
> 
> Adding Rusty since he maintains the module loader code.

This patch gives me:

arch/powerpc/kernel/module_64.c: In function 'dedotify_versions':
arch/powerpc/kernel/module_64.c:325:33: error: 'reloc_start' undeclared (first use in this function)
arch/powerpc/kernel/module_64.c:325:33: note: each undeclared identifier is reported only once for each function it appears in

Cheers,
Ben.

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

* Re: [PATCH] powerpc: module: fix TOC symbol CRC
  2014-06-24  4:06   ` Benjamin Herrenschmidt
@ 2014-06-24  8:42     ` Laurent Dufour
  2014-06-24  8:53     ` [PATCH V2] " Laurent Dufour
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Dufour @ 2014-06-24  8:42 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Anton Blanchard; +Cc: rusty, linuxppc-dev

On 24/06/2014 06:06, Benjamin Herrenschmidt wrote:
> On Thu, 2014-06-19 at 09:44 +1000, Anton Blanchard wrote:
>> Hi Laurent,
>>
>>> The commit 71ec7c55ed91 introduced the magic symbol ".TOC." for ELFv2
>>> ABI. This symbol is built manually and has no CRC value computed. A
>>> zero value is put in the CRC section to avoid modpost complaining
>>> about a missing CRC. Unfortunately, this breaks the kernel module
>>> loading when the kernel is relocated (kdump case for instance)
>>> because of the relocation applied to the kcrctab values.
>>>
>>> This patch compute a CRC value for the TOC symbol which will match
>>> the one compute by the kernel when it is relocated - aka '0 -
>>> relocate_start' done in maybe_relocated called by check_version
>>> (module.c).
>>
>> Adding Rusty since he maintains the module loader code.
> 
> This patch gives me:
> 
> arch/powerpc/kernel/module_64.c: In function 'dedotify_versions':
> arch/powerpc/kernel/module_64.c:325:33: error: 'reloc_start' undeclared (first use in this function)
> arch/powerpc/kernel/module_64.c:325:33: note: each undeclared identifier is reported only once for each function it appears in

Hi Ben,

My mistake, I forgot to check building the kernel when module version
checking is disabled. I'll send a v2 asap.

Cheers,
Laurent.


> Cheers,
> Ben.
> 
> 

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

* [PATCH V2] powerpc: module: fix TOC symbol CRC
  2014-06-24  4:06   ` Benjamin Herrenschmidt
  2014-06-24  8:42     ` Laurent Dufour
@ 2014-06-24  8:53     ` Laurent Dufour
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Dufour @ 2014-06-24  8:53 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: rusty, linuxppc-dev, Anton Blanchard

The commit 71ec7c55ed91 introduced the magic symbol ".TOC." for ELFv2 ABI.
This symbol is built manually and has no CRC value computed. A zero value
is put in the CRC section to avoid modpost complaining about a missing CRC.
Unfortunately, this breaks the kernel module loading when the kernel is
relocated (kdump case for instance) because of the relocation applied to
the kcrctab values.

This patch compute a CRC value for the TOC symbol which will match the one
compute by the kernel when it is relocated - aka '0 - relocate_start' done in
maybe_relocated called by check_version (module.c).

Changes in V2:
 - fix only when relocation is applied to kcrctab.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Cc: Anton Blanchard <anton@samba.org>
---
 arch/powerpc/kernel/module_64.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 077d2ce..d807ee6 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -315,8 +315,17 @@ static void dedotify_versions(struct modversion_info *vers,
 	struct modversion_info *end;
 
 	for (end = (void *)vers + size; vers < end; vers++)
-		if (vers->name[0] == '.')
+		if (vers->name[0] == '.') {
 			memmove(vers->name, vers->name+1, strlen(vers->name));
+#ifdef ARCH_RELOCATES_KCRCTAB
+			/* The TOC symbol has no CRC computed. To avoid CRC
+			 * check failing, we must force it to the expected
+			 * value (see CRC check in module.c).
+			 */
+			if (!strcmp(vers->name, "TOC."))
+				vers->crc = -(unsigned long)reloc_start;
+#endif
+		}
 }
 
 /* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */

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

end of thread, other threads:[~2014-06-24  8:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-17 15:56 [PATCH] powerpc: module: fix TOC symbol CRC Laurent Dufour
2014-06-18 23:44 ` Anton Blanchard
2014-06-24  4:06   ` Benjamin Herrenschmidt
2014-06-24  8:42     ` Laurent Dufour
2014-06-24  8:53     ` [PATCH V2] " Laurent Dufour

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).