Skip to contentSkip to conversation

powerpc: Fix dynamic relocation

PATCH In review Alexander Graf 3 participants 4 messages Mar 9, 2013 1 message not in the archive PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Fix dynamic relocation

Commit 5ac47f7a introduced dynamic relocation of code by manually relocating TOC entries. However, we need to access the TOC using the physical address that we have for it, not the virtual address that we can't even access yet.

Drop the offset from the TOC accessing pointer.

This fixes Linux 3.9 booting on OpenBIOS for me.

---

I've also encountered breakage on a G5 Mac, not sure if it's related. I'll have to test whether this is the culprit on that one too.

Ben, please make sure that this gets into 3.9.

---
 arch/powerpc/kernel/prom_init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/prom_init.c +1 -1
index 7f7fb7f..2bf7cc3 100644
@@ -2851,7 +2851,7 @@ static void reloc_toc(void)
 		(__prom_init_toc_end - __prom_init_toc_start) / sizeof(long);
 
 	/* Need to add offset to get at __prom_init_toc_start */
-	__reloc_toc(__prom_init_toc_start + offset, offset, nr_entries);
+	__reloc_toc(__prom_init_toc_start, offset, nr_entries);
 
 	mb();
 }
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 7 lines · Alexander Graf

Commit 5ac47f7a introduced dynamic relocation of code by manually relocating TOC entries. However, we need to access the TOC using the physical address that we have for it, not the virtual address that we can't even access yet.

Drop the offset from the TOC accessing pointer.

Quoted 8 lines

This fixes Linux 3.9 booting on OpenBIOS for me.

---

I've also encountered breakage on a G5 Mac, not sure if it's related. I'll have to test whether this is the culprit on that one too.

That might fix the mac too.. Anton's patch assumed OF ran in real mode in which case the top bits of the address are ignored, meaning we could use kernel virtual addresses but that isn't the case with Apple OF which has MMU enabled and maps memory 1:1. I suppose OpenBIOS has the same problem ? Or is this a 32-bit issue as well ?

Quoted 18 lines

Ben, please make sure that this gets into 3.9.

---
 arch/powerpc/kernel/prom_init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/prom_init.c +1 -1
index 7f7fb7f..2bf7cc3 100644
@@ -2851,7 +2851,7 @@ static void reloc_toc(void)
 		(__prom_init_toc_end - __prom_init_toc_start) / sizeof(long);
 
 	/* Need to add offset to get at __prom_init_toc_start */
-	__reloc_toc(__prom_init_toc_start + offset, offset, nr_entries);
+	__reloc_toc(__prom_init_toc_start, offset, nr_entries);
 
 	mb();
 }
#2 lore raw

Am 09.03.2013 um 08:29 schrieb Benjamin Herrenschmidt <[email protected].= org>:

Quoted 16 lines · Alexander Graf
Quoted 9 lines

Commit 5ac47f7a introduced dynamic relocation of code by manually relocating TOC entries. However, we need to access the TOC using the physical address that we have for it, not the virtual address that we can't even access yet.
=20
Drop the offset from the TOC accessing pointer.
=20
This fixes Linux 3.9 booting on OpenBIOS for me.
=20

Quoted 6 lines

=20
---
=20
I've also encountered breakage on a G5 Mac, not sure if it's related. I'll have to test whether this is the culprit on that one too.

Quoted 6 lines

=20
That might fix the mac too.. Anton's patch assumed OF ran in real mode in which case the top bits of the address are ignored, meaning we could use kernel virtual addresses but that isn't the case with Apple OF which has MMU enabled and maps memory 1:1. I suppose OpenBIOS has the same problem ? Or is this a 32-bit issue as well ?

That's exactly what OpenBIOS does, yes :).

Alex

Quoted 7 lines

=20

arch/powerpc/kernel/prom_i=

Quoted 6 lines

Ben, please make sure that this gets into 3.9.
---
arch/powerpc/kernel/prom_init.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)

=20

arch/powerpc/kernel/prom_i= renamed from arch/powerpc/kernel/prom_init.c +0 -0

nit.c

Quoted 14 lines
Quoted 9 lines

index 7f7fb7f..2bf7cc3 100644

arch/powerpc/kernel/prom_init.c +0 -0
@@ -2851,7 +2851,7 @@ static void reloc_toc(void)
       (__prom_init_toc_end - __prom_init_toc_start) / sizeof(long);

=20
/* Need to add offset to get at __prom_init_toc_start */

arch/powerpc/kernel/prom_init.c +1 -1
-    __reloc_toc(__prom_init_toc_start + offset, offset, nr_entries);
+    __reloc_toc(__prom_init_toc_start, offset, nr_entries);
Quoted 3 lines

=20
mb();
}

=20
=20

A message that is not in the archive (sent off-list or not yet received): 1362814152.6977.32.camel__2059.78525705195$1362814216$gmane$org@pasglop

#4 lore raw
Quoted 1 line · Benjamin Herrenschmidt

That might fix the mac too..

It does.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."