[Skiboot] [PATCH] core/init: Assert when kernel not found

Vaidyanathan Srinivasan svaidy at linux.vnet.ibm.com
Wed Feb 28 21:52:59 AEDT 2018


* Michael Neuling <mikey at neuling.org> [2018-02-28 20:11:20]:

> If the kernel doesn't load out of flash or there is nothing at
> KERNEL_LOAD_BASE, we end up with an esoteric message as we try to
> branch to out of skiboot into nothing
> 
>   [    0.007197688,3] INIT: ELF header not found. Assuming raw binary.
>   [    0.014035267,5] INIT: Starting kernel at 0x0, fdt at 0x3044ad90 13029
>   [    0.014042254,3] ***********************************************
>   [    0.014069947,3] Fatal Exception 0xe40 at 0000000000000000
>   [    0.014085574,3] CFAR : 00000000300051c4
>   [    0.014090118,3] SRR0 : 0000000000000000 SRR1 : 0000000000000000
>   [    0.014096243,3] HSRR0: 0000000000000000 HSRR1: 9000000000001000
>   [    0.014102546,3] DSISR: 00000000         DAR  : 0000000000000000
>   [    0.014108538,3] LR   : 00000000300144c8 CTR  : 0000000000000000
>   [    0.014114756,3] CR   : 40002202         XER  : 00000000
>   [    0.014120301,3] GPR00: 000000003001447c GPR16: 0000000000000000
> 
> This improves the message and asserts in this case:
> 
>   [    0.007197688,3] INIT: ELF header not found. Assuming raw binary.
>   [    0.007202901,3] INIT: Raw binary is zeros, can't execute!
>   [    0.007207770,0] Assert fail: core/init.c:412:0
>   [    0.007213993,0] Aborting!

Good idea.
 
> Signed-off-by: Michael Neuling <mikey at neuling.org>

Reviewed-by: Vaidyanathan Srinivasan <svaidy at linux.vnet.ibm.com>

> ---
>  core/init.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/core/init.c b/core/init.c
> index 5633a9d38f..ac64a544b3 100644
> --- a/core/init.c
> +++ b/core/init.c
> @@ -405,6 +405,13 @@ static bool load_kernel(void)
>  
>  	if (kh->ei_ident != ELF_IDENT) {
>  		prerror("INIT: ELF header not found. Assuming raw binary.\n");
> +
> +		/* Check there is something there before we branch to it */
> +		if (*(uint32_t *)kh == 0) {
> +			prerror("INIT: Raw binary is zeros, can't execute!\n");
> +			assert(0);
> +		}
> +

Can we move this check before start_kernel and after the following
print:

INIT: Starting kernel at 0xxxxx, fdt....

We would have let all skiboot boot routines complete and just stop at
a point we are about to execute kernel and get the original e40 exception
message.

--Vaidy



More information about the Skiboot mailing list