From cc34635df59e4f5aa8ad80bc788e74f8cf197880 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Fri, 11 Oct 2019 15:27:42 +1100 Subject: [PATCH] core/init: Checksum romem after patching out traps Currently we checksum the read-only parts of skiboot's memory just before loading and booting petitboot. Commit 9ddc1a6bfaef ("core/util: trap based assertions") modifies the .text after this point since it needs to disable the trap instructions that we use to trigger an abort() before entering the kernel. We can fix this by moving the checksum to after the point where the traps are patched out. We could do the patching sooner, but since load_and_boot_kernel() is a fairly complex function it's perferable to keep boot-time assertion infrastructure active until just before we enter the kernel. Reported-by: Carol L Soto Tested-by: Carol L Soto Tested-by: Vasant Hegde Fixes: 9ddc1a6bfaef ("core/util: trap based assertions") Signed-off-by: Oliver O'Halloran --- core/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/init.c b/core/init.c index c2d7324622db..cc1fdbc4d0b0 100644 --- a/core/init.c +++ b/core/init.c @@ -85,6 +85,8 @@ struct debug_descriptor debug_descriptor = { #endif }; +static void checksum_romem(void); + static bool try_load_elf64_le(struct elf_hdr *header) { struct elf64_hdr *kh = (struct elf64_hdr *)header; @@ -621,6 +623,8 @@ void __noreturn load_and_boot_kernel(bool is_reboot) patch_traps(false); + checksum_romem(); + debug_descriptor.state_flags |= OPAL_BOOT_COMPLETE; cpu_give_self_os(); @@ -1320,8 +1324,6 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) prd_register_reserved_memory(); - checksum_romem(); - load_and_boot_kernel(false); }