diff mbox series

[RFC,1/6] core/init: Check for STB container for kernel preloaded at 0

Message ID 20191218044911.26983-2-jniethe5@gmail.com
State Changes Requested
Headers show
Series A few kernel loading tidy ups | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Jordan Niethe Dec. 18, 2019, 4:49 a.m. UTC
Preloading a kernel at address 0 is intended for binary files with no
headers. We do not check for a STB header in this case, but there is no
real harm in doing so. When there is no STB header the code will
function as before. Move the check for a STB header to be be
unconditionally performed. This helps with a future tidy up.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
 core/init.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/core/init.c b/core/init.c
index ade91e07ba5b..80222c6a9fc6 100644
--- a/core/init.c
+++ b/core/init.c
@@ -395,16 +395,15 @@  static bool load_kernel(void)
 			cpu_set_sreset_enable(false);
 			memcpy_null(NULL, old_vectors, EXCEPTION_VECTORS_END);
 			sync_icache();
-		} else {
-			/* Hack for STB in Mambo, assume at least 4kb in mem */
-			if (!kernel_size)
-				kernel_size = SECURE_BOOT_HEADERS_SIZE;
-			if (stb_is_container((void*)kernel_entry, kernel_size)) {
-				stb_container = (void*)kernel_entry;
-				kh = (struct elf_hdr *) (kernel_entry + SECURE_BOOT_HEADERS_SIZE);
-			} else
-				kh = (struct elf_hdr *) (kernel_entry);
 		}
+		/* Hack for STB in Mambo, assume at least 4kb in mem */
+		if (!kernel_size)
+			kernel_size = SECURE_BOOT_HEADERS_SIZE;
+		if (stb_is_container((void *)kernel_entry, kernel_size)) {
+			stb_container = (void *)kernel_entry;
+			kh = (struct elf_hdr *) (kernel_entry + SECURE_BOOT_HEADERS_SIZE);
+		} else
+			kh = (struct elf_hdr *) (kernel_entry);
 	} else {
 		if (!kernel_size) {
 			printf("INIT: Assuming kernel at %p\n",