[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9a5bd7c2-13ee-2517-48f6-e61a6dc9c076@csgroup.eu>
Date: Thu, 8 Sep 2022 06:00:24 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Michael Ellerman <mpe@...erman.id.au>,
Mathieu Malaterre <malat@...ian.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Segher Boessenkool <segher@...nel.crashing.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Paul Mackerras <paulus@...ba.org>,
Joel Stanley <joel@....id.au>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: [PATCH] powerpc/lib/xor_vmx: Relax frame size for clang
Le 08/09/2022 à 02:27, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@...roup.eu> writes:
>> Le 21/06/2019 à 10:58, Mathieu Malaterre a écrit :
>>> When building with clang-8 the frame size limit is hit:
>>>
>>> ../arch/powerpc/lib/xor_vmx.c:119:6: error: stack frame size of 1200 bytes in function '__xor_altivec_5' [-Werror,-Wframe-larger-than=]
>>>
>>> Follow the same approach as commit 9c87156cce5a ("powerpc/xmon: Relax
>>> frame size for clang") until a proper fix is implemented upstream in
>>> clang and relax requirement for clang.
>>
>> With Clang 14 I get the following errors, but only with KASAN selected.
>>
>> CC arch/powerpc/lib/xor_vmx.o
>> arch/powerpc/lib/xor_vmx.c:95:6: error: stack frame size (1040) exceeds
>> limit (1024) in '__xor_altivec_4' [-Werror,-Wframe-larger-than]
>> void __xor_altivec_4(unsigned long bytes,
>> ^
>> arch/powerpc/lib/xor_vmx.c:124:6: error: stack frame size (1312) exceeds
>> limit (1024) in '__xor_altivec_5' [-Werror,-Wframe-larger-than]
>> void __xor_altivec_5(unsigned long bytes,
>> ^
>
> That's a 32-bit build?
Yes, pmac32_defconfig
>
>> Is this patch still relevant ?
>
> The clang issue was closed because a different change fixed the issue:
>
> https://github.com/ClangBuiltLinux/linux/issues/563
>
>> Or should frame size be relaxed when KASAN is selected ? After all the
>> stack size is multiplied by 2 when we have KASAN, so maybe the warning
>> limit should be increased as well ?
>
> Yeah that would make some sense.
>
> On 64-bit the largest frame in that file is 1424, which is below the
> default 2048 byte limit.
>
> So maybe just increase it for 32-bit && KASAN.
>
> What would be nice is if the FRAME_WARN value could be calculated as a
> percentage of the THREAD_SHIFT, but that's not easily doable with the
> way things are structured in Kconfig.
>
Looking at it more deeply, I see strange things.
What is that frame size ? I thought it was the number of bytes r1 is
decremented at the begining of the function, but it seems not, at least
on GCC. It seems GCC substrats 112 bytes while clang doesn't.
I set CONFIG_FRAME_WARN to 8 and with GCC and without KASAN, I get no
warning, allthough I have:
00000000 <__xor_altivec_2>:
0: 94 21 ff f0 stwu r1,-16(r1)
00000078 <__xor_altivec_3>:
78: 94 21 ff f0 stwu r1,-16(r1)
0000010c <__xor_altivec_4>:
10c: 94 21 ff f0 stwu r1,-16(r1)
000001c4 <__xor_altivec_5>:
1c4: 94 21 ff e0 stwu r1,-32(r1)
With GCC and inline KASAN I get:
arch/powerpc/lib/xor_vmx.c: In function '__xor_altivec_2':
arch/powerpc/lib/xor_vmx.c:69:1: warning: the frame size of 96 bytes is
larger than 8 bytes [-Wframe-larger-than=]
arch/powerpc/lib/xor_vmx.c: In function '__xor_altivec_3':
arch/powerpc/lib/xor_vmx.c:93:1: warning: the frame size of 128 bytes is
larger than 8 bytes [-Wframe-larger-than=]
arch/powerpc/lib/xor_vmx.c: In function '__xor_altivec_4':
arch/powerpc/lib/xor_vmx.c:122:1: warning: the frame size of 80 bytes is
larger than 8 bytes [-Wframe-larger-than=]
arch/powerpc/lib/xor_vmx.c: In function '__xor_altivec_5':
arch/powerpc/lib/xor_vmx.c:156:1: warning: the frame size of 128 bytes
is larger than 8 bytes [-Wframe-larger-than=]
00000000 <__xor_altivec_2>:
0: 94 21 ff 30 stwu r1,-208(r1)
00000458 <__xor_altivec_3>:
458: 94 21 ff 00 stwu r1,-256(r1)
00000b94 <__xor_altivec_4>:
b94: 94 21 fe b0 stwu r1,-336(r1)
000015b8 <__xor_altivec_5>:
15b8: 94 21 fe 60 stwu r1,-416(r1)
With CLANG and without KASAN I get:
CC arch/powerpc/lib/xor_vmx.o
arch/powerpc/lib/xor_vmx.c:52:6: warning: stack frame size (144) exceeds
limit (8) in '__xor_altivec_2' [-Wframe-larger-than]
void __xor_altivec_2(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:71:6: warning: stack frame size (144) exceeds
limit (8) in '__xor_altivec_3' [-Wframe-larger-than]
void __xor_altivec_3(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:95:6: warning: stack frame size (160) exceeds
limit (8) in '__xor_altivec_4' [-Wframe-larger-than]
void __xor_altivec_4(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:124:6: warning: stack frame size (144)
exceeds limit (8) in '__xor_altivec_5' [-Wframe-larger-than]
void __xor_altivec_5(unsigned long bytes,
00000000 <__xor_altivec_2>:
0: 94 21 ff 70 stwu r1,-144(r1)
00000528 <__xor_altivec_3>:
528: 94 21 ff 70 stwu r1,-144(r1)
00000c4c <__xor_altivec_4>:
c4c: 94 21 ff 60 stwu r1,-160(r1)
000015a4 <__xor_altivec_5>:
15a4: 94 21 ff 70 stwu r1,-144(r1)
With CLANG and with inline KASAN I get:
arch/powerpc/lib/xor_vmx.c:52:6: warning: stack frame size (512) exceeds
limit (8) in '__xor_altivec_2' [-Wframe-larger-than]
void __xor_altivec_2(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:71:6: warning: stack frame size (768) exceeds
limit (8) in '__xor_altivec_3' [-Wframe-larger-than]
void __xor_altivec_3(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:95:6: warning: stack frame size (1040)
exceeds limit (8) in '__xor_altivec_4' [-Wframe-larger-than]
void __xor_altivec_4(unsigned long bytes,
arch/powerpc/lib/xor_vmx.c:124:6: warning: stack frame size (1312)
exceeds limit (8) in '__xor_altivec_5' [-Wframe-larger-than]
void __xor_altivec_5(unsigned long bytes,
00000000 <__xor_altivec_2>:
8: 94 21 fe 00 stwu r1,-512(r1)
00000a24 <__xor_altivec_3>:
a2c: 94 21 fd 00 stwu r1,-768(r1)
000019a4 <__xor_altivec_4>:
19ac: 94 21 fb f0 stwu r1,-1040(r1)
00002f20 <__xor_altivec_5>:
2f28: 94 21 fa e0 stwu r1,-1312(r1)
So it seems that GCC and CLANG don't warn on the same thing, is that
expected ? GCC substrats 112 bytes, which is the minimum frame size on a
ppc64, but here I'm building a ppc32 kernel, min frame size is 16.
And CLANG is still using stack a lot more than GCC.
Christophe
Powered by blists - more mailing lists