Commit c7b9ed7c authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/64e: KASAN Full support for BOOK3E/64



We now have memory organised in a way that allows
implementing KASAN.

Unlike book3s/64, book3e always has translation active so the only
thing needed to use KASAN is to setup an early zero shadow mapping
just after setting a stack pointer and before calling early_setup().

The memory layout is now as follows

   +------------------------+  Kernel virtual map end (0xc000200000000000)
   |                        |
   |    16TB of KASAN map   |
   |                        |
   +------------------------+  Kernel KASAN shadow map start
   |                        |
   |    16TB of IO map      |
   |                        |
   +------------------------+  Kernel IO map start
   |                        |
   |    16TB of vmemmap     |
   |                        |
   +------------------------+  Kernel vmemmap start
   |                        |
   |    16TB of vmap        |
   |                        |
   +------------------------+  Kernel virt start (0xc000100000000000)
   |                        |
   |    64TB of linear mem  |
   |                        |
   +------------------------+  Kernel linear (0xc.....)

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0bef8beda27baf71e3b9e8b13e620fba6e19499b.1656427701.git.christophe.leroy@csgroup.eu
parent 059c1893
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ config PPC
	select HAVE_ARCH_JUMP_LABEL_RELATIVE
	select HAVE_ARCH_KASAN			if PPC32 && PPC_PAGE_SHIFT <= 14
	select HAVE_ARCH_KASAN			if PPC_RADIX_MMU
	select HAVE_ARCH_KASAN			if PPC_BOOK3E_64
	select HAVE_ARCH_KASAN_VMALLOC		if HAVE_ARCH_KASAN
	select HAVE_ARCH_KFENCE			if PPC_BOOK3S_32 || PPC_8xx || 40x
	select HAVE_ARCH_KGDB
@@ -254,6 +255,7 @@ config PPC
	select IOMMU_HELPER			if PPC64
	select IRQ_DOMAIN
	select IRQ_FORCED_THREADING
	select KASAN_VMALLOC			if KASAN && MODULES
	select MMU_GATHER_PAGE_SIZE
	select MMU_GATHER_RCU_TABLE_FREE
	select MODULES_USE_ELF_RELA
+2 −1
Original line number Diff line number Diff line
@@ -375,4 +375,5 @@ config KASAN_SHADOW_OFFSET
	hex
	depends on KASAN
	default 0xe0000000 if PPC32
	default 0xa80e000000000000 if PPC64
	default 0xa80e000000000000 if PPC_BOOK3S_64
	default 0xa8001c0000000000 if PPC_BOOK3E_64
+12 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@

#define KASAN_SHADOW_SCALE_SHIFT	3

#ifdef CONFIG_MODULES
#if defined(CONFIG_MODULES) && defined(CONFIG_PPC32)
#define KASAN_KERN_START	ALIGN_DOWN(PAGE_OFFSET - SZ_256M, SZ_256M)
#else
#define KASAN_KERN_START	PAGE_OFFSET
@@ -39,6 +39,17 @@
 * c00e000000000000 << 3 + a80e000000000000 = c00fc00000000000
 */
#define KASAN_SHADOW_END 0xc00fc00000000000UL

#else

/*
 * The shadow ends before the highest accessible address
 * because we don't need a shadow for the shadow.
 * But it doesn't hurt to have a shadow for the shadow,
 * keep shadow end aligned eases things.
 */
#define KASAN_SHADOW_END 0xc000200000000000UL

#endif

#ifdef CONFIG_KASAN
+3 −0
Original line number Diff line number Diff line
@@ -965,6 +965,9 @@ start_here_multiplatform:
	 * and SLB setup before we turn on relocation.
	 */

#ifdef CONFIG_KASAN
	bl	kasan_early_init
#endif
	/* Restore parameters passed from prom_init/kexec */
	mr	r3,r31
	LOAD_REG_ADDR(r12, DOTSYM(early_setup))
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ obj-$(CONFIG_PPC32) += init_32.o
obj-$(CONFIG_PPC_8xx)		+= 8xx.o
obj-$(CONFIG_PPC_BOOK3S_32)	+= book3s_32.o
obj-$(CONFIG_PPC_BOOK3S_64)	+= init_book3s_64.o
obj-$(CONFIG_PPC_BOOK3E_64)	+= init_book3e_64.o
Loading