Commit b3960972 authored by Jason Yan's avatar Jason Yan Committed by Michael Ellerman

powerpc/fsl_booke/kaslr: clear the original kernel if randomized

The original kernel still exists in the memory, clear it now.
Signed-off-by: default avatarJason Yan <yanaijie@huawei.com>
Reviewed-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: default avatarDiana Craciun <diana.craciun@nxp.com>
Tested-by: default avatarDiana Craciun <diana.craciun@nxp.com>
Signed-off-by: default avatarScott Wood <oss@buserror.net>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 6a38ea1d
......@@ -148,8 +148,10 @@ extern void loadcam_multi(int first_idx, int num, int tmp_idx);
#ifdef CONFIG_RANDOMIZE_BASE
void kaslr_early_init(void *dt_ptr, phys_addr_t size);
void kaslr_late_init(void);
#else
static inline void kaslr_early_init(void *dt_ptr, phys_addr_t size) {}
static inline void kaslr_late_init(void) {}
#endif
struct tlbcam {
......
......@@ -269,6 +269,7 @@ notrace void __init relocate_init(u64 dt_ptr, phys_addr_t start)
kernstart_addr = start;
if (is_second_reloc) {
virt_phys_offset = PAGE_OFFSET - memstart_addr;
kaslr_late_init();
return;
}
......
......@@ -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);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment