Commit 40d04110 authored by Marco Elver's avatar Marco Elver Committed by Paul E. McKenney
Browse files

x86, kcsan: Enable KCSAN for x86



This patch enables KCSAN for x86, with updates to build rules to not use
KCSAN for several incompatible compilation units.

Signed-off-by: default avatarMarco Elver <elver@google.com>
Acked-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent e75a6795
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -226,6 +226,7 @@ config X86
	select VIRT_TO_BUS
	select X86_FEATURE_NAMES		if PROC_FS
	select PROC_PID_ARCH_STATUS		if PROC_FS
	select HAVE_ARCH_KCSAN if X86_64

config INSTRUCTION_DECODER
	def_bool y
+2 −0
Original line number Diff line number Diff line
@@ -9,7 +9,9 @@
# Changed by many, many contributors over the years.
#

# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
KASAN_SANITIZE			:= n
KCSAN_SANITIZE			:= n
OBJECT_FILES_NON_STANDARD	:= y

# Kernel does not boot with kcov instrumentation here.
+2 −0
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
#	(see scripts/Makefile.lib size_append)
#	compressed vmlinux.bin.all + u32 size of vmlinux.bin.all

# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
KASAN_SANITIZE			:= n
KCSAN_SANITIZE			:= n
OBJECT_FILES_NON_STANDARD	:= y

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+3 −0
Original line number Diff line number Diff line
@@ -10,8 +10,11 @@ ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE
include $(srctree)/lib/vdso/Makefile

KBUILD_CFLAGS += $(DISABLE_LTO)

# Sanitizer runtimes are unavailable and cannot be linked here.
KASAN_SANITIZE			:= n
UBSAN_SANITIZE			:= n
KCSAN_SANITIZE			:= n
OBJECT_FILES_NON_STANDARD	:= y

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+5 −1
Original line number Diff line number Diff line
@@ -201,8 +201,12 @@ arch_test_and_change_bit(long nr, volatile unsigned long *addr)
	return GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(btc), *addr, c, "Ir", nr);
}

static __always_inline bool constant_test_bit(long nr, const volatile unsigned long *addr)
static __no_kcsan_or_inline bool constant_test_bit(long nr, const volatile unsigned long *addr)
{
	/*
	 * Because this is a plain access, we need to disable KCSAN here to
	 * avoid double instrumentation via instrumented bitops.
	 */
	return ((1UL << (nr & (BITS_PER_LONG-1))) &
		(addr[nr >> _BITOPS_LONG_SHIFT])) != 0;
}
Loading