mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
6a38ea1d7b
commit
b396097200
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue