diff mbox series

init: Fix starting stripped kernel

Message ID 20180925062600.25374-1-mikey@neuling.org
State Accepted
Headers show
Series init: Fix starting stripped kernel | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/make_check success Test make_check on branch master

Commit Message

Michael Neuling Sept. 25, 2018, 6:26 a.m. UTC
Currently if we try to run a raw/stripped binary kernel (ie. without
the elf header) we crash with:

  [    0.008757768,5] INIT: Waiting for kernel...
  [    0.008762937,5] INIT: platform wait for kernel load failed
  [    0.008768171,5] INIT: Assuming kernel at 0x20000000
  [    0.008779241,3] INIT: ELF header not found. Assuming raw binary.
  [    0.017047348,5] INIT: Starting kernel at 0x0, fdt at 0x3044b230 14339 bytes
  [    0.017054251,0] FATAL: Kernel is zeros, can't execute!
  [    0.017059054,0] Assert fail: core/init.c:590:0
  [    0.017065371,0] Aborting!

This is because we haven't set kernel_entry correctly in this path.
This fixes it.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 core/init.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stewart Smith Sept. 27, 2018, 7:16 a.m. UTC | #1
Michael Neuling <mikey@neuling.org> writes:
> Currently if we try to run a raw/stripped binary kernel (ie. without
> the elf header) we crash with:
>
>   [    0.008757768,5] INIT: Waiting for kernel...
>   [    0.008762937,5] INIT: platform wait for kernel load failed
>   [    0.008768171,5] INIT: Assuming kernel at 0x20000000
>   [    0.008779241,3] INIT: ELF header not found. Assuming raw binary.
>   [    0.017047348,5] INIT: Starting kernel at 0x0, fdt at 0x3044b230 14339 bytes
>   [    0.017054251,0] FATAL: Kernel is zeros, can't execute!
>   [    0.017059054,0] Assert fail: core/init.c:590:0
>   [    0.017065371,0] Aborting!
>
> This is because we haven't set kernel_entry correctly in this path.
> This fixes it.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  core/init.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks, merged to master as of 80b7b37c63a587258b27e4f87e150936680badff.

Sounds like something we should have a test for though :)
diff mbox series

Patch

diff --git a/core/init.c b/core/init.c
index a7e70c9ec3..262ac5fb31 100644
--- a/core/init.c
+++ b/core/init.c
@@ -394,6 +394,7 @@  static bool load_kernel(void)
 			       KERNEL_LOAD_BASE);
 			/* Hack for STB in Mambo, assume at least 4kb in mem */
 			kernel_size = SECURE_BOOT_HEADERS_SIZE;
+			kernel_entry = (uint64_t)KERNEL_LOAD_BASE;
 		}
 		if (stb_is_container(KERNEL_LOAD_BASE, kernel_size)) {
 			stb_container = KERNEL_LOAD_BASE;