Skip to content

Commit

Permalink
core/init: Checksum romem after patching out traps
Browse files Browse the repository at this point in the history
Currently we checksum the read-only parts of skiboot's memory just
before loading and booting petitboot. Commit 9ddc1a6
("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 <clsoto@us.ibm.com>
Tested-by: Carol L Soto <clsoto@us.ibm.com>
Tested-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Fixes: 9ddc1a6 ("core/util: trap based assertions")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
oohal committed Oct 13, 2019
1 parent a4e0f63 commit cc34635
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/init.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1320,8 +1324,6 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)

prd_register_reserved_memory();

checksum_romem();

load_and_boot_kernel(false);
}

Expand Down

0 comments on commit cc34635

Please sign in to comment.