aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/nohash/kaslr_booke.c
diff options
context:
space:
mode:
authorJason Yan <yanaijie@huawei.com>2019-09-20 17:45:42 +0800
committerMichael Ellerman <mpe@ellerman.id.au>2019-11-13 19:27:44 +1100
commitb39609720069f5a6eed2b3e3f618c23587021ff5 (patch)
treefdc9e2385223bbf0eea7b07051b28ded0b190885 /arch/powerpc/mm/nohash/kaslr_booke.c
parentpowerpc/fsl_booke/32: randomize the kernel image offset (diff)
downloadlinux-dev-b39609720069f5a6eed2b3e3f618c23587021ff5.tar.xz
linux-dev-b39609720069f5a6eed2b3e3f618c23587021ff5.zip
powerpc/fsl_booke/kaslr: clear the original kernel if randomized
The original kernel still exists in the memory, clear it now. Signed-off-by: Jason Yan <yanaijie@huawei.com> Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr> Reviewed-by: Diana Craciun <diana.craciun@nxp.com> Tested-by: Diana Craciun <diana.craciun@nxp.com> Signed-off-by: Scott Wood <oss@buserror.net> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to '')
-rw-r--r--arch/powerpc/mm/nohash/kaslr_booke.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c
index 7b238fc2c8a9..aa1b60c782e7 100644
--- a/arch/powerpc/mm/nohash/kaslr_booke.c
+++ b/arch/powerpc/mm/nohash/kaslr_booke.c
@@ -381,3 +381,14 @@ notrace void __init kaslr_early_init(void *dt_ptr, phys_addr_t size)
reloc_kernel_entry(dt_ptr, kernstart_virt_addr);
}
+
+void __init kaslr_late_init(void)
+{
+ /* If randomized, clear the original kernel */
+ if (kernstart_virt_addr != KERNELBASE) {
+ unsigned long kernel_sz;
+
+ kernel_sz = (unsigned long)_end - kernstart_virt_addr;
+ memzero_explicit((void *)KERNELBASE, kernel_sz);
+ }
+}