|
|
c283d0 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
c283d0 |
From: Daniel Axtens <dja@axtens.net>
|
|
|
c283d0 |
Date: Fri, 22 Oct 2021 09:53:15 +1100
|
|
|
c283d0 |
Subject: [PATCH] powerpc-ieee1275: load grub at 4MB, not 2MB
|
|
|
c283d0 |
|
|
|
c283d0 |
This was first reported under PFW but reproduces under SLOF.
|
|
|
c283d0 |
|
|
|
c283d0 |
- The core.elf was 2126152 = 0x207148 bytes in size with the following
|
|
|
c283d0 |
program headers (per readelf):
|
|
|
c283d0 |
|
|
|
c283d0 |
Entry point 0x200000
|
|
|
c283d0 |
There are 4 program headers, starting at offset 52
|
|
|
c283d0 |
|
|
|
c283d0 |
Program Headers:
|
|
|
c283d0 |
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
|
|
|
c283d0 |
LOAD 0x000160 0x00200000 0x00200000 0x21f98 0x2971c RWE 0x8
|
|
|
c283d0 |
GNU_STACK 0x0220f8 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
|
|
|
c283d0 |
LOAD 0x0220f8 0x00232000 0x00232000 0x1e4e50 0x1e4e50 RWE 0x4
|
|
|
c283d0 |
NOTE 0x206f48 0x00000000 0x00000000 0x00200 0x00000 R 0x4
|
|
|
c283d0 |
|
|
|
c283d0 |
- SLOF places the ELF file at 0x4000 (after the reserved space for
|
|
|
c283d0 |
interrupt handlers etc.) upwards. The image was 2126152 = 0x207148
|
|
|
c283d0 |
bytes in size, so it runs from 0x4000 - 0x20b148. We'll call 0x4000 the
|
|
|
c283d0 |
load address.
|
|
|
c283d0 |
|
|
|
c283d0 |
0x0 0x4000 0x20b148
|
|
|
c283d0 |
|----------|--------------|
|
|
|
c283d0 |
| reserved | ELF contents |
|
|
|
c283d0 |
|
|
|
c283d0 |
- SLOF then copies the first LOAD program header (for .text). That runs
|
|
|
c283d0 |
for 0x21f98 bytes. It runs from
|
|
|
c283d0 |
(load addr + 0x160) to (load addr + 0x160 + 0x21f98)
|
|
|
c283d0 |
= 0x4160 to 0x260f8
|
|
|
c283d0 |
and we copy it to 0x200000 to 0x221f98. This overwrites the end of the
|
|
|
c283d0 |
image:
|
|
|
c283d0 |
|
|
|
c283d0 |
0x0 0x4000 0x200000 0x221f98
|
|
|
c283d0 |
|----------|------------|---------------|
|
|
|
c283d0 |
| reserved | ELF cont.. | .text section |
|
|
|
c283d0 |
|
|
|
c283d0 |
- SLOF zeros the bss up to PhysAddr + MemSize = 0x22971c
|
|
|
c283d0 |
|
|
|
c283d0 |
0x0 0x4000 0x200000 0x221f98 0x22971c
|
|
|
c283d0 |
|----------|------------|---------------|--------|
|
|
|
c283d0 |
| reserved | ELF cont.. | .text section | bss 0s |
|
|
|
c283d0 |
|
|
|
c283d0 |
- SLOF then goes to fulfil the next LOAD header (for mods), which is
|
|
|
c283d0 |
for 0x1e4e50 bytes. We copy from
|
|
|
c283d0 |
(load addr + 0x220f8) to (load addr + 0x220f8 + 0x1e4e50)
|
|
|
c283d0 |
= 0x260f8 to 0x20af48
|
|
|
c283d0 |
and we copy it to 0x232000 to 0x416e50:
|
|
|
c283d0 |
|
|
|
c283d0 |
0x0 0x4000 0x200000 0x221f98 0x22971c
|
|
|
c283d0 |
|----------|------------|---------------|--------|
|
|
|
c283d0 |
| reserved | ELF cont.. | .text section | bss 0s |
|
|
|
c283d0 |
|-------------|
|
|
|
c283d0 |
| copied area |
|
|
|
c283d0 |
0x260f8 0x20af48
|
|
|
c283d0 |
|
|
|
c283d0 |
This goes poorly:
|
|
|
c283d0 |
|
|
|
c283d0 |
0x0 0x4000 0x200000 0x221f98 0x22971c 0x232000 0x40bf08 0x416e50
|
|
|
c283d0 |
|----------|------------|---------------|--------|-----|-----------|-------------|
|
|
|
c283d0 |
| reserved | ELF cont.. | .text section | bss 0s | pad | some mods | .text start |
|
|
|
c283d0 |
|
|
|
c283d0 |
This matches the observations on the running system - 0x40bf08 was where
|
|
|
c283d0 |
the contents of memory no longer matched the contents of the ELF file.
|
|
|
c283d0 |
|
|
|
c283d0 |
This was reported as a license verification failure on SLOF as the
|
|
|
c283d0 |
last module's .module_license section fell past where the corruption
|
|
|
c283d0 |
began.
|
|
|
c283d0 |
|
|
|
c283d0 |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
c283d0 |
[rharwood@redhat.com: trim very detailed commit message]
|
|
|
c283d0 |
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
c283d0 |
---
|
|
|
c283d0 |
grub-core/Makefile.core.def | 2 +-
|
|
|
c283d0 |
include/grub/offsets.h | 2 +-
|
|
|
c283d0 |
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
|
c283d0 |
|
|
|
c283d0 |
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
|
c283d0 |
index 3f3459b2c70..6b00eb55575 100644
|
|
|
c283d0 |
--- a/grub-core/Makefile.core.def
|
|
|
c283d0 |
+++ b/grub-core/Makefile.core.def
|
|
|
c283d0 |
@@ -89,7 +89,7 @@ kernel = {
|
|
|
c283d0 |
i386_xen_pvh_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x100000';
|
|
|
c283d0 |
|
|
|
c283d0 |
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
|
|
|
c283d0 |
- powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
|
|
|
c283d0 |
+ powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x400000';
|
|
|
c283d0 |
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
|
|
|
c283d0 |
mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
|
|
|
c283d0 |
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
|
|
|
c283d0 |
diff --git a/include/grub/offsets.h b/include/grub/offsets.h
|
|
|
c283d0 |
index 871e1cd4c38..69211aa798b 100644
|
|
|
c283d0 |
--- a/include/grub/offsets.h
|
|
|
c283d0 |
+++ b/include/grub/offsets.h
|
|
|
c283d0 |
@@ -63,7 +63,7 @@
|
|
|
c283d0 |
#define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
|
|
|
c283d0 |
|
|
|
c283d0 |
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
|
|
c283d0 |
-#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
|
|
|
c283d0 |
+#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x400000
|
|
|
c283d0 |
|
|
|
c283d0 |
#define GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR 0x80200000
|
|
|
c283d0 |
|