Re: [PATCH v3 5/6] powerpc/fsl_booke/64: clear the original kernel if randomized

From: Jason Yan
Date: Tue Feb 25 2020 - 21:44:26 EST




å 2020/2/20 21:49, Christophe Leroy åé:


Le 06/02/2020 Ã 03:58, Jason Yan a ÃcritÂ:
The original kernel still exists in the memory, clear it now.

No such problem with PPC32 ? Or is that common ?


PPC32 did this in relocate_init() in fsl_booke.c because PPC32 will not reach kaslr_early_init for the second pass after relocation.

Thanks,
Jason

Christophe


Signed-off-by: Jason Yan <yanaijie@xxxxxxxxxx>
Cc: Scott Wood <oss@xxxxxxxxxxxx>
Cc: Diana Craciun <diana.craciun@xxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Christophe Leroy <christophe.leroy@xxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Nicholas Piggin <npiggin@xxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
---
 arch/powerpc/mm/nohash/kaslr_booke.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c
index c6f5c1db1394..ed1277059368 100644
--- a/arch/powerpc/mm/nohash/kaslr_booke.c
+++ b/arch/powerpc/mm/nohash/kaslr_booke.c
@@ -378,8 +378,10 @@ notrace void __init kaslr_early_init(void *dt_ptr, phys_addr_t size)
ÂÂÂÂÂ unsigned int *__kaslr_offset = (unsigned int *)(KERNELBASE + 0x58);
ÂÂÂÂÂ unsigned int *__run_at_load = (unsigned int *)(KERNELBASE + 0x5c);
-ÂÂÂ if (*__run_at_load == 1)
+ÂÂÂ if (*__run_at_load == 1) {
+ÂÂÂÂÂÂÂ kaslr_late_init();
ÂÂÂÂÂÂÂÂÂ return;
+ÂÂÂ }
ÂÂÂÂÂ /* Setup flat device-tree pointer */
ÂÂÂÂÂ initial_boot_params = dt_ptr;


.