* [PATCH] MIPS: Disable stack checks on MIPS kernels
@ 2017-01-29 3:24 Joshua Kinard
2017-02-14 10:08 ` James Hogan
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Kinard @ 2017-01-29 3:24 UTC (permalink / raw)
To: Ralf Baechle, Maciej W. Rozycki; +Cc: James Hogan, Linux/MIPS
From: Joshua Kinard <kumba@gentoo.org>
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>
---
arch/mips/Makefile | 15 +++++++++++++++
1 file changed, 15 insertions(+)
linux-mips-4.10-disable-stack-check.patch
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 1a6bac7b076f..6b2a30442105 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.
#
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: Disable stack checks on MIPS kernels
2017-01-29 3:24 [PATCH] MIPS: Disable stack checks on MIPS kernels Joshua Kinard
@ 2017-02-14 10:08 ` James Hogan
0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2017-02-14 10:08 UTC (permalink / raw)
To: Joshua Kinard; +Cc: Ralf Baechle, Maciej W. Rozycki, Linux/MIPS
[-- Attachment #1: Type: text/plain, Size: 2248 bytes --]
On Sat, Jan 28, 2017 at 10:24:16PM -0500, Joshua Kinard wrote:
> From: Joshua Kinard <kumba@gentoo.org>
>
> 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>
Applied
Thanks
James
> ---
> arch/mips/Makefile | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> linux-mips-4.10-disable-stack-check.patch
> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> index 1a6bac7b076f..6b2a30442105 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.
> #
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-14 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-29 3:24 [PATCH] MIPS: Disable stack checks on MIPS kernels Joshua Kinard
2017-02-14 10:08 ` James Hogan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).