[Skiboot] [RFC PATCH 3/6] core/init: Move check for STB header into unconditional path

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


Almost the same check for a STB header is performed in both the case
where we have a kernel-base-address in the device tree and when we do
not. Reduce this duplication and move the test into the unconditional
path.

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

diff --git a/core/init.c b/core/init.c
index 5e9306126204..8a39e9823db9 100644
--- a/core/init.c
+++ b/core/init.c
@@ -398,25 +398,21 @@ static bool load_kernel(void)
 		}
 		/* 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)) {
-			stb_container = (void *)kernel_entry;
-			kh = (struct elf_hdr *) (kernel_entry + SECURE_BOOT_HEADERS_SIZE);
-		} else
-			kh = (struct elf_hdr *) (kernel_entry);
 	} 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;
-			kernel_entry = (uint64_t)KERNEL_LOAD_BASE;
 		}
-		if (stb_is_container(KERNEL_LOAD_BASE, kernel_size)) {
-			stb_container = KERNEL_LOAD_BASE;
-			kh = (struct elf_hdr *) (KERNEL_LOAD_BASE + SECURE_BOOT_HEADERS_SIZE);
-		} else
-			kh = (struct elf_hdr *) (KERNEL_LOAD_BASE);
+	}
 
+	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);
 	}
 
 	prlog(PR_DEBUG,
-- 
2.17.1



More information about the Skiboot mailing list