Skip to content

Commit f072015

Browse files
chleroympe
authored andcommitted
powerpc: disable KASAN instrumentation on early/critical files.
All files containing functions run before kasan_early_init() is called must have KASAN instrumentation disabled. For those file, branch profiling also have to be disabled otherwise each if () generates a call to ftrace_likely_update(). Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent b4abe38 commit f072015

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

arch/powerpc/kernel/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ CFLAGS_REMOVE_btext.o = $(CC_FLAGS_FTRACE)
3131
CFLAGS_REMOVE_prom.o = $(CC_FLAGS_FTRACE)
3232
endif
3333

34+
KASAN_SANITIZE_early_32.o := n
35+
KASAN_SANITIZE_cputable.o := n
36+
KASAN_SANITIZE_prom_init.o := n
37+
KASAN_SANITIZE_btext.o := n
38+
39+
ifdef CONFIG_KASAN
40+
CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING
41+
CFLAGS_cputable.o += -DDISABLE_BRANCH_PROFILING
42+
CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING
43+
CFLAGS_btext.o += -DDISABLE_BRANCH_PROFILING
44+
endif
45+
3446
obj-y := cputable.o ptrace.o syscalls.o \
3547
irq.o align.o signal_32.o pmc.o vdso.o \
3648
process.o systbl.o idle.o \

arch/powerpc/lib/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
88
CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE)
99
CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE)
1010

11+
KASAN_SANITIZE_code-patching.o := n
12+
KASAN_SANITIZE_feature-fixups.o := n
13+
14+
ifdef CONFIG_KASAN
15+
CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
16+
CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
17+
endif
18+
1119
obj-y += alloc.o code-patching.o feature-fixups.o
1220

1321
ifndef CONFIG_KASAN

arch/powerpc/mm/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
77

8+
KASAN_SANITIZE_ppc_mmu_32.o := n
9+
10+
ifdef CONFIG_KASAN
11+
CFLAGS_ppc_mmu_32.o += -DDISABLE_BRANCH_PROFILING
12+
endif
13+
814
obj-y := fault.o mem.o pgtable.o mmap.o \
915
init_$(BITS).o pgtable_$(BITS).o \
1016
pgtable-frag.o \

arch/powerpc/platforms/powermac/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
CFLAGS_bootx_init.o += -fPIC
33
CFLAGS_bootx_init.o += $(call cc-option, -fno-stack-protector)
44

5+
KASAN_SANITIZE_bootx_init.o := n
6+
7+
ifdef CONFIG_KASAN
8+
CFLAGS_bootx_init.o += -DDISABLE_BRANCH_PROFILING
9+
endif
10+
511
ifdef CONFIG_FUNCTION_TRACER
612
# Do not trace early boot code
713
CFLAGS_REMOVE_bootx_init.o = $(CC_FLAGS_FTRACE)

arch/powerpc/purgatory/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
3+
KASAN_SANITIZE := n
4+
25
targets += trampoline.o purgatory.ro kexec-purgatory.c
36

47
LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined

arch/powerpc/xmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
77
GCOV_PROFILE := n
88
KCOV_INSTRUMENT := n
99
UBSAN_SANITIZE := n
10+
KASAN_SANITIZE := n
1011

1112
# Disable ftrace for the entire directory
1213
ORIG_CFLAGS := $(KBUILD_CFLAGS)

0 commit comments

Comments
 (0)