[Skiboot] [RFC PATCH 4/6] core/init: Go back to using zero for preloaded kernels of unknown size

Jordan Niethe jniethe5 at gmail.com
Wed Dec 18 15:49:09 AEDT 2019


Previously a kernel_size of zero was used for preloaded kernels of
unknown size. As a hack for test STB in Mambo this was changed to
instead be set to SECURE_BOOT_HEADERS_SIZE. In the log we print out:

  INIT: Kernel loaded, size: %zu bytes (0 = unknown preload)

It seems more confusing to change this message to print out:
  ... (4096 = unknown preload) ...

So go back to using zero for an unknown preload size, but when we are
going to check for a stb container - use the SECURE_BOOT_HEADERS_SIZE
instead.

Signed-off-by: Jordan Niethe <jniethe5 at gmail.com>
---
 core/init.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/core/init.c b/core/init.c
index 8a39e9823db9..96c770f03476 100644
--- a/core/init.c
+++ b/core/init.c
@@ -396,19 +396,18 @@ static bool load_kernel(void)
 			memcpy_null(NULL, old_vectors, EXCEPTION_VECTORS_END);
 			sync_icache();
 		}
-		/* Hack for STB in Mambo, assume at least 4kb in mem */
-		kernel_size = SECURE_BOOT_HEADERS_SIZE;
+		kernel_size = 0;
 	} else {
 		kernel_entry = (uint64_t)KERNEL_LOAD_BASE;
 		if (!kernel_size) {
 			printf("INIT: Assuming kernel at %p\n",
 			       KERNEL_LOAD_BASE);
-			/* Hack for STB in Mambo, assume at least 4kb in mem */
-			kernel_size = SECURE_BOOT_HEADERS_SIZE;
 		}
 	}
 
-	if (stb_is_container((void *)kernel_entry, kernel_size)) {
+	/* Hack for STB in Mambo: Assume 4kb for unknown kernel size */
+	if (stb_is_container((void *)kernel_entry, kernel_size ?
+			     kernel_size : SECURE_BOOT_HEADERS_SIZE)) {
 		stb_container = (void *)kernel_entry;
 		kh = (struct elf_hdr *) (kernel_entry + SECURE_BOOT_HEADERS_SIZE);
 	} else {
-- 
2.17.1



More information about the Skiboot mailing list