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

From: Jason Yan
Date: Sun Mar 29 2020 - 22:22:56 EST


The original kernel still exists in the memory, clear it now.

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 24ad34641869..6c46f24cc53d 100644
--- a/arch/powerpc/mm/nohash/kaslr_booke.c
+++ b/arch/powerpc/mm/nohash/kaslr_booke.c
@@ -382,8 +382,10 @@ notrace void __init kaslr_early_init(void *dt_ptr, phys_addr_t size)
unsigned long kernel_sz;

if (IS_ENABLED(CONFIG_PPC64)) {
- if (__run_at_load == 1)
+ if (__run_at_load == 1) {
+ kaslr_late_init();
return;
+ }

/* Get the first memblock size */
early_get_first_memblock_info(dt_ptr, &size);
--
2.17.2