diff mbox series

[2/2] core/init: Checksum romem after patching out traps

Message ID 20191011042742.2555-2-oohall@gmail.com
State Accepted
Headers show
Series [1/2] core/init: Don't checksum MPIPL data areas | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (1785745d5a7eaefd7d0c135f2a3b0f5d86aefec5)
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

Oliver O'Halloran Oct. 11, 2019, 4:27 a.m. UTC
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 <clsoto@us.ibm.com>
Fixes: 9ddc1a6bfaef ("core/util: trap based assertions")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 core/init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Vasant Hegde Oct. 11, 2019, 10:16 a.m. UTC | #1
On 10/11/19 9:57 AM, Oliver O'Halloran wrote:
> 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 <clsoto@us.ibm.com>
> Fixes: 9ddc1a6bfaef ("core/util: trap based assertions")
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Looks good to me and it fixed fast-reboot issue.

Tested-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>


-Vasant
Carol L Soto Oct. 11, 2019, 3:24 p.m. UTC | #2
"Vasant Hegde" <hegdevasant@linux.vnet.ibm.com> wrote on 10/11/2019
05:16:46 AM:

> From: "Vasant Hegde" <hegdevasant@linux.vnet.ibm.com>
> To: "Oliver O'Halloran" <oohall@gmail.com>, skiboot@lists.ozlabs.org
> Cc: Carol L Soto/Poughkeepsie/IBM@IBMUS
> Date: 10/11/2019 05:16 AM
> Subject: Re: [Skiboot] [PATCH 2/2] core/init: Checksum romem after
> patching out traps
>
> On 10/11/19 9:57 AM, Oliver O'Halloran wrote:
> > 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 <clsoto@us.ibm.com>
> > Fixes: 9ddc1a6bfaef ("core/util: trap based assertions")
> > Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>
> Looks good to me and it fixed fast-reboot issue.
>
> Tested-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
>
>
> -Vasant

It fixed the issue. thanks
Tested-by:  Carol L Soto <clsoto@us.ibm.com>
diff mbox series

Patch

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);
 }