summaryrefslogtreecommitdiffstats
path: root/arch/mips/Makefile
diff options
context:
space:
mode:
authorJoshua Kinard <kumba@gentoo.org>2017-01-28 22:24:16 -0500
committerJames Hogan <james.hogan@imgtec.com>2017-02-14 09:00:23 +0000
commit573deec09436c9136fff6d78e0325e052a1ad6be (patch)
treef85723490be8ef015f86c7a7e374ec99aae35dba /arch/mips/Makefile
parent93e502b3c2d44dcb964141cbf82930282de8e40b (diff)
downloadlinux-573deec09436c9136fff6d78e0325e052a1ad6be.tar.bz2
MIPS: Disable stack checks on MIPS kernels
Disable stack checking on MIPS kernels. Some distribution toolchains might pass the -fstack-check option to gcc. This results in a store-doubleword instruction being emitted at the top of all functions that checks the available stack space. E.g., a80000000001d740 <per_cpu_init>: a80000000001d740: ffa0bfc0 sd zero,-16448(sp) a80000000001d744: 2405ffc9 li a1,-55 a80000000001d748: 67bdffc0 daddiu sp,sp,-64 Generally, this is undesirable, and especially on the SGI IP27 platform, it will trigger a NULL pointer dereference in '_raw_spin_lock_irq' during early init. Signed-off-by: Joshua Kinard <kumba@gentoo.org> Suggested-by: James Hogan <james.hogan@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: "Maciej W. Rozycki" <macro@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/15132/ Signed-off-by: James Hogan <james.hogan@imgtec.com>
Diffstat (limited to 'arch/mips/Makefile')
-rw-r--r--arch/mips/Makefile15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 6ea306b28ae9..8ef9c02747fa 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -131,6 +131,21 @@ cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.
cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \
-fno-omit-frame-pointer
+
+# Some distribution-specific toolchains might pass the -fstack-check
+# option during the build, which adds a simple stack-probe at the beginning
+# of every function. This stack probe is to ensure that there is enough
+# stack space, else a SEGV is generated. This is not desirable for MIPS
+# as kernel stacks are small, placed in unmapped virtual memory, and do not
+# grow when overflowed. Especially on SGI IP27 platforms, this check will
+# lead to a NULL pointer dereference in _raw_spin_lock_irq.
+#
+# In disassembly, this stack probe appears at the top of a function as:
+# sd zero,<offset>(sp)
+# Where <offset> is a negative value.
+#
+cflags-y += -fno-stack-check
+
#
# CPU-dependent compiler/assembler options for optimization.
#