powerpc: Avoid broken GCC __attribute__((optimize))
authorArd Biesheuvel <ardb@kernel.org>
Wed, 28 Oct 2020 08:04:33 +0000 (09:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:15 +0000 (11:53 +0100)
commitb1a0097b8298f03e5885fa580053520435fd3209
tree5abf2b3ebe849d956e668ac7d90fc095ea804379
parent6014c6ed74f1aa61da6286bfd6738950200333a8
powerpc: Avoid broken GCC __attribute__((optimize))

[ Upstream commit a7223f5bfcaeade4a86d35263493bcda6c940891 ]

Commit 7053f80d9696 ("powerpc/64: Prevent stack protection in early
boot") introduced a couple of uses of __attribute__((optimize)) with
function scope, to disable the stack protector in some early boot
code.

Unfortunately, and this is documented in the GCC man pages [0],
overriding function attributes for optimization is broken, and is only
supported for debug scenarios, not for production: the problem appears
to be that setting GCC -f flags using this method will cause it to
forget about some or all other optimization settings that have been
applied.

So the only safe way to disable the stack protector is to disable it
for the entire source file.

[0] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Fixes: 7053f80d9696 ("powerpc/64: Prevent stack protection in early boot")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
[mpe: Drop one remaining use of __nostackprotector, reported by snowpatch]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201028080433.26799-1-ardb@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/paca.c
arch/powerpc/kernel/setup.h
arch/powerpc/kernel/setup_64.c