Always load PowerPC kernel to KERNEL_LOAD_ADDR
PATCH 1/1 Always load PowerPC kernel to KERNEL_LOAD_ADDR
Linux changed its physical address location in the elf header from 0xc0000000 to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.
This patch assures that the lowest segment in the elf binary is loaded to KERNEL_LOAD_ADDR, which is where the firmware expects it.
With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
--- hw/ppc_oldworld.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/ppc_oldworld.c +3 -1
@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size =load_elf (kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size =load_elf (kernel_filename, kernel_base - lowaddr,NULL ,NULL ,NULL );if (kernel_size <0 ) kernel_size = load_aout(kernel_filename, kernel_base,
Signature · 1 line
1.6.0.2
Quoted 20 lines · Alexander Graf
Linux changed its physical address location in the elf header from
0xc0000000to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.This patch assures that the lowest segment in the elf binary is loaded to
KERNEL_LOAD_ADDR, which is where the firmware expects it.With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
Signed-off-by Alexander Graf <[email protected]>--- hw/ppc_oldworld.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)hw/ppc_oldworld.c +0
-0
hw/ppc_oldworld.c static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, · line 215
Quoted 10 lines
hw/ppc_oldworld.c +3
-1@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size =load_elf (kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size =load_elf (kernel_filename, kernel_base - lowaddr,NULL ,NULL ,NULL );
Hello,
Can't you speculatively load at kernel_base assuming it's a new kernel, then only if lowaddr indicates it was an old kernel you do the second load to fix things up?
Maybe also a comment or two in the code explaining the hack.. :)
Cheers
Quoted 37 lines · Edgar E. Iglesias
Quoted 32 lines · Alexander Graf
Linux changed its physical address location in the elf header from
0xc0000000to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.This patch assures that the lowest segment in the elf binary is loaded to
KERNEL_LOAD_ADDR, which is where the firmware expects it.With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
Signed-off-by Alexander Graf <[email protected]>---
hw/ppc_oldworld.c| 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)hw/ppc_oldworld.c +3
-1@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size = load_elf(kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size = load_elf(kernel_filename, kernel_base - lowaddr,Quoted 1 line
NULL, NULL, NULL);Hello,
Quoted 3 lines
Can't you speculatively load at
kernel_baseassuming it's a new kernel, then only if lowaddr indicates it was an old kernel you do the second load to fix things up?
Hm - so we only call load_elf once for new kernels? Sounds like a good idea :-).
Quoted 1 line
Maybe also a comment or two in the code explaining the hack.. :)
Right, that might be nice.
Alex
Quoted 3 lines
Cheers
Quoted 39 lines · Alexander Graf
Quoted 36 lines · Edgar E. Iglesias
Quoted 22 lines · Alexander Graf
Linux changed its physical address location in the elf header from
0xc0000000to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.This patch assures that the lowest segment in the elf binary is loaded to
KERNEL_LOAD_ADDR, which is where the firmware expects it.With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
Signed-off-by Alexander Graf <[email protected]>---
hw/ppc_oldworld.c| 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)hw/ppc_oldworld.c +0
-0@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }hw/ppc_oldworld.c static void ppc_heathrow_init (ram_addr_t ram_size, · line 217
Quoted 10 lines
hw/ppc_oldworld.c +3
-1if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size =load_elf (kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size =load_elf (kernel_filename, kernel_base - lowaddr,NULL ,NULL ,NULL );Hello,
Quoted 6 lines
Quoted 3 lines
Can't you speculatively load at
kernel_baseassuming it's a new kernel, then only if lowaddr indicates it was an old kernel you do the second load to fix things up?Hm - so we only call
load_elfonce for new kernels? Sounds like a good idea :-).
Yes, if it works :)
Cheers
Quoted 46 lines · Alexander Graf
Quoted 38 lines · Edgar E. Iglesias
Quoted 33 lines · Alexander Graf
Linux changed its physical address location in the elf header from
0xc0000000to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.This patch assures that the lowest segment in the elf binary is loaded
toKERNEL_LOAD_ADDR, which is where the firmware expects it.With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
Signed-off-by Alexander Graf <[email protected]>---
hw/ppc_oldworld.c| 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)hw/ppc_oldworld.c +3
-1@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size = load_elf(kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size = load_elf(kernel_filename, kernel_base - lowaddr,Quoted 1 line
NULL, NULL, NULL);Hello,
Quoted 4 lines
Can't you speculatively load at
kernel_baseassuming it's a new kernel,
then only if lowaddr indicates it was an old kernel you do the second load to fix things up?
Quoted 7 lines
Hm - so we only call
load_elfonce for new kernels? Sounds like a good idea :-).Quoted 1 line
Maybe also a comment or two in the code explaining the hack.. :)
Right, that might be nice.
I have just committed a fix based on your patch and implementing that. I also added a comment explaining the hack.
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 50 lines · Aurelien Jarno
Quoted 49 lines · Alexander Graf
Quoted 38 lines · Edgar E. Iglesias
Quoted 33 lines · Alexander Graf
Linux changed its physical address location in the elf header from
0xc0000000to 0 on 2.6.25, causing later kernels to fail booting with the -kernel option.This patch assures that the lowest segment in the elf binary is loaded
toKERNEL_LOAD_ADDR, which is where the firmware expects it.With this patch applied, I was able to successfully boot a 2.6.18 and a 2.6.27 Linux kernel using the -kernel option.
Signed-off-by Alexander Graf <[email protected]>---
hw/ppc_oldworld.c| 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)hw/ppc_oldworld.c +3
-1@@ -207,9 +207,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, }if (linux_boot) { +uint64_t lowaddr =0 ; kernel_base =KERNEL_LOAD_ADDR ;/* now we can load the kernel */ - kernel_size = load_elf(kernel_filename, kernel_base -0xc0000000ULL , +load_elf (kernel_filename,0 ,NULL , &lowaddr,NULL ); + kernel_size = load_elf(kernel_filename, kernel_base - lowaddr,Quoted 1 line
NULL, NULL, NULL);Hello,
Quoted 4 lines
Can't you speculatively load at
kernel_baseassuming it's a new kernel,
then only if lowaddr indicates it was an old kernel you do the second load to fix things up?Hm - so we only call
load_elfonce for new kernels? Sounds like a good idea :-).
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Maybe also a comment or two in the code explaining the hack.. :)
Right, that might be nice.
I have just committed a fix based on your patch and implementing that. I also added a comment explaining the hack.
Heh - I literally started to look at the patch again about 2 seconds before your mail came in.
Thanks!
Alex