Re: [RFC PATCH 06/10] powerpc/fsl_booke/32: implement KASLR infrastructure
flat view
From: Christophe Leroy <hidden>
Date: 2019-07-29 11:16:25
Also in:
lkml
Le 17/07/2019 à 10:06, Jason Yan a écrit :
This patch add support to boot kernel from places other than KERNELBASE. Since CONFIG_RELOCATABLE has already supported, what we need to do is map or copy kernel to a proper place and relocate. Freescale Book-E parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1 entries are not suitable to map the kernel directly in a randomized region, so we chose to copy the kernel to a proper place and restart to relocate. The offset of the kernel was not randomized yet(a fixed 64M is set). We will randomize it in the next patch. Signed-off-by: Jason Yan <yanaijie@huawei.com> Cc: Diana Craciun <redacted> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Christophe Leroy <redacted> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <redacted> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Kees Cook <redacted> --- arch/powerpc/Kconfig | 11 +++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/early_32.c | 2 +- arch/powerpc/kernel/fsl_booke_entry_mapping.S | 13 ++- arch/powerpc/kernel/head_fsl_booke.S | 15 +++- arch/powerpc/kernel/kaslr_booke.c | 83 +++++++++++++++++++ arch/powerpc/mm/mmu_decl.h | 6 ++ arch/powerpc/mm/nohash/fsl_booke.c | 7 +- 8 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 arch/powerpc/kernel/kaslr_booke.c
[...]
quoted hunk ↗ jump to hunk
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index dae8e9177574..754ae1e69f92 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h@@ -148,6 +148,12 @@ extern void reloc_kernel_entry(void *fdt, int addr); extern void loadcam_entry(unsigned int index); extern void loadcam_multi(int first_idx, int num, int tmp_idx); +#ifdef CONFIG_RANDOMIZE_BASE +extern void kaslr_early_init(void *dt_ptr, phys_addr_t size);
No superflous 'extern' keyword. Christophe
quoted hunk ↗ jump to hunk
+#else +static inline void kaslr_early_init(void *dt_ptr, phys_addr_t size) {} +#endif + struct tlbcam { u32 MAS0; u32 MAS1;