diff mbox

[RFC,2/2] wl3501_cs: reduce stack size for KASAN

Message ID 20170710144425.2238584-2-arnd@arndb.de (mailing list archive)
State RFC
Delegated to: Kalle Valo
Headers show

Commit Message

Arnd Bergmann July 10, 2017, 2:44 p.m. UTC
Inlining functions with local variables can lead to excessive stack usage
with KASAN after a previous patch that modifies the outsb/insb helpers
on x86.

drivers/net/wireless/wl3501_cs.c: In function 'wl3501_rx_interrupt':
drivers/net/wireless/wl3501_cs.c:1103:1: error: the frame size of 2232 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Marking the two callers of insb/outb 'noinline' prevents the compiler
from adding up the stack usage for each of the local variables passed
into those, reducing the maximum stack frame size to 800 bytes with
KASAN again.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/wl3501_cs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Kalle Valo July 25, 2017, 12:52 p.m. UTC | #1
Arnd Bergmann <arnd@arndb.de> writes:

> Inlining functions with local variables can lead to excessive stack usage
> with KASAN after a previous patch that modifies the outsb/insb helpers
> on x86.
>
> drivers/net/wireless/wl3501_cs.c: In function 'wl3501_rx_interrupt':
> drivers/net/wireless/wl3501_cs.c:1103:1: error: the frame size of 2232 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>
> Marking the two callers of insb/outb 'noinline' prevents the compiler
> from adding up the stack usage for each of the local variables passed
> into those, reducing the maximum stack frame size to 800 bytes with
> KASAN again.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Arnd, based on the discussion I'm dropping. Please let me know if I
should take this still.
Arnd Bergmann July 25, 2017, 2:50 p.m. UTC | #2
On Tue, Jul 25, 2017 at 2:52 PM, Kalle Valo <kvalo@codeaurora.org> wrote:
> Arnd Bergmann <arnd@arndb.de> writes:
>
>> Inlining functions with local variables can lead to excessive stack usage
>> with KASAN after a previous patch that modifies the outsb/insb helpers
>> on x86.
>>
>> drivers/net/wireless/wl3501_cs.c: In function 'wl3501_rx_interrupt':
>> drivers/net/wireless/wl3501_cs.c:1103:1: error: the frame size of 2232 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>>
>> Marking the two callers of insb/outb 'noinline' prevents the compiler
>> from adding up the stack usage for each of the local variables passed
>> into those, reducing the maximum stack frame size to 800 bytes with
>> KASAN again.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Arnd, based on the discussion I'm dropping. Please let me know if I
> should take this still.

Thanks, that's good. The problem has become unreproducible and
I assume it's gone for good with the new x86 fix. In the unlikely
case some form of the problem comes back in another randconfig,
I'll post a new patch.

       Arnd
diff mbox

Patch

diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index acec0d9ec422..2cce22571b4c 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -242,8 +242,8 @@  static int wl3501_get_flash_mac_addr(struct wl3501_card *this)
  *
  * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
  */
-static void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src,
-			      int size)
+static noinline void wl3501_set_to_wla(struct wl3501_card *this,
+				       u16 dest, void *src, int size)
 {
 	/* switch to SRAM Page 0 */
 	wl3501_switch_page(this, (dest & 0x8000) ? WL3501_BSS_SPAGE1 :
@@ -264,8 +264,8 @@  static void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src,
  *
  * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
  */
-static void wl3501_get_from_wla(struct wl3501_card *this, u16 src, void *dest,
-				int size)
+static noinline void wl3501_get_from_wla(struct wl3501_card *this,
+					 u16 src, void *dest, int size)
 {
 	/* switch to SRAM Page 0 */
 	wl3501_switch_page(this, (src & 0x8000) ? WL3501_BSS_SPAGE1 :