Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frame-larger-than in arch/powerpc/xmon/xmon.c #252

Open
shenki opened this issue Oct 30, 2018 · 10 comments
Open

frame-larger-than in arch/powerpc/xmon/xmon.c #252

shenki opened this issue Oct 30, 2018 · 10 comments
Labels
-Wframe-larger-than= [ARCH] powerpc This bug impacts ARCH=powerpc [WORKAROUND] Applied This bug has an applied workaround

Comments

@shenki
Copy link
Member

shenki commented Oct 30, 2018

clang-7 and clang-8 (8.0.0-svn345470-1~exp1+0~20181028082208.133~1.gbpf10f36) result in this build error when building the ppc64 kernel:

arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576 bytes in function 'xmon_core'
      [-Wframe-larger-than=]
static int xmon_core(struct pt_regs *regs, int fromipi)

Note that this is an error, as arch/powerpc builds with -Werror turned on.

@shenki shenki added [BUG] Untriaged Something isn't working [ARCH] powerpc This bug impacts ARCH=powerpc -Wframe-larger-than= labels Oct 30, 2018
@shenki
Copy link
Member Author

shenki commented Oct 30, 2018

@rnav did some digging and found out why xmon_core ends up so large:

Looks like it's to do with xmon_printf()
clang seems to be saving addresses to those in .rodata.str1.1 section on the stack

            798: R_PPC64_TOC16_HA    .rodata.str1.1+0x134e
     79c:    80 07 41 fa     std     r18,1920(r1)
     7a0:    00 00 54 3a     addi    r18,r20,0
            7a0: R_PPC64_TOC16_LO    .rodata.str1.1+0x185d
     7a4:    00 00 80 3a     li      r20,0
     7a8:    30 03 81 f8     std     r4,816(r1)
     7ac:    00 00 82 3c     addis   r4,r2,0
            7ac: R_PPC64_TOC16_HA    .rodata.str1.1+0x136f
     7b0:    28 03 81 f8     std     r4,808(r1)
     7b4:    00 00 82 3c     addis   r4,r2,0
            7b4: R_PPC64_TOC16_HA    .rodata.str1.1+0x1390
     7b8:    20 03 81 f8     std     r4,800(r1)
     7bc:    00 00 82 3c     addis   r4,r2,0
            7bc: R_PPC64_TOC16_HA    .rodata.str1.1+0x13b1
     7c0:    78 07 41 fa     std     r18,1912(r1)
     7c4:    18 03 81 f8     std     r4,792(r1)
     7c8:    00 00 82 3c     addis   r4,r2,0
            7c8: R_PPC64_TOC16_HA    .rodata.str1.1+0x13d2
     7cc:    10 03 81 f8     std     r4,784(r1)
     7d0:    00 00 82 3c     addis   r4,r2,0
            7d0: R_PPC64_TOC16_HA    .rodata.str1.1+0x13f3
     7d4:    08 03 81 f8     std     r4,776(r1)
     7d8:    00 00 82 3c     addis   r4,r2,0
            7d8: R_PPC64_TOC16_HA    .rodata.str1.1+0x1423
     7dc:    88 07 61 f8     std     r3,1928(r1)
     7e0:    00 00 7d 38     addi    r3,r29,0
> objdump -s -j .rodata.str1.1 ./xmon.o

<snip>

 1320 20202074 72617020 3d202534 6c780a00     trap = %4lx..
 1330 64617220 3d20252e 31366c78 20202064  dar = %.16lx   d
 1340 73697372 203d2025 2e386c78 0a006d73  sisr = %.8lx..ms
 1350 72202020 203d2025 2e31366c 78202073  r    = %.16lx  s
 1360 70726730 203d2025 2e31366c 780a0070  prg0 = %.16lx..p
 1370 76722020 20203d20 252e3136 6c782020  vr    = %.16lx  
 1380 73707267 31203d20 252e3136 6c780a00  sprg1 = %.16lx..
 1390 64656320 2020203d 20252e31 366c7820  dec    = %.16lx 
 13a0 20737072 6732203d 20252e31 366c780a   sprg2 = %.16lx.
 13b0 00737020 20202020 3d20252e 31366c78  .sp     = %.16lx
 13c0 20207370 72673320 3d20252e 31366c78    sprg3 = %.16lx
 13d0 0a00746f 63202020 203d2025 2e31366c  ..toc    = %.16l
 13e0 78202064 61722020 203d2025 2e31366c  x  dar   = %.16l
 13f0 780a0073 72723020 20203d20 252e3136  x..srr0   = %.16
 1400 6c782020 73727231 20203d20 252e3136  lx  srr1  = %.16
 1410 6c782064 73697372 20203d20 252e386c  lx dsisr  = %.8l
 1420 780a0064 73637220 20203d20 252e3136  x..dscr   = %.16
 1430 6c782020 70707220 20203d20 252e3136  lx  ppr   = %.16
 1440 6c782070 69722020 20203d20 252e386c  lx pir    = %.8l
 1450 780a0061 6d722020 20203d20 252e3136  x..amr    = %.16
 1460 6c782020 75616d6f 72203d20 252e3136  lx  uamor = %.16

Clang:

       printf("Invalid number.\n");
    1ab0:    80 07 61 e8     ld      r3,1920(r1)
    1ab4:    01 00 00 48     bl      1ab4 <xmon_core+0x1a00>
            1ab4: R_PPC64_REL24    xmon_printf
    1ab8:    00 00 00 60     nop

GCC:

    printf("Invalid number.\n");
    6200:    00 00 62 3c     addis   r3,r2,0
            6200: R_PPC64_TOC16_HA    .rodata.str1.8+0x2420
    6204:    00 00 63 38     addi    r3,r3,0
            6204: R_PPC64_TOC16_LO    .rodata.str1.8+0x2420
    6208:    01 00 00 48     bl      6208 <xmon_core+0x1b98>
            6208: R_PPC64_REL24    xmon_printf
    620c:    00 00 00 60     nop

@shenki
Copy link
Member Author

shenki commented Oct 31, 2018

Kernel patch posted: https://patchwork.ozlabs.org/patch/991235/

This is a workaround. I think this should be fixed in clang though before we can consider this resolved.

fengguang pushed a commit to 0day-ci/linux that referenced this issue Oct 31, 2018
When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
mpe pushed a commit to linuxppc/linux that referenced this issue Oct 31, 2018
When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
@tpimh tpimh added the low priority This bug is not critical and not a priority label Oct 31, 2018
nathanchance pushed a commit that referenced this issue May 7, 2019
[BUG]
When accessing a file on a crafted image, btrfs can crash in block layer:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
  PGD 136501067 P4D 136501067 PUD 124519067 PMD 0
  CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.0.0-rc8-default #252
  RIP: 0010:end_bio_extent_readpage+0x144/0x700
  Call Trace:
   <IRQ>
   blk_update_request+0x8f/0x350
   blk_mq_end_request+0x1a/0x120
   blk_done_softirq+0x99/0xc0
   __do_softirq+0xc7/0x467
   irq_exit+0xd1/0xe0
   call_function_single_interrupt+0xf/0x20
   </IRQ>
  RIP: 0010:default_idle+0x1e/0x170

[CAUSE]
The crafted image has a tricky corruption, the INODE_ITEM has a
different type against its parent dir:

        item 20 key (268 INODE_ITEM 0) itemoff 2808 itemsize 160
                generation 13 transid 13 size 1048576 nbytes 1048576
                block group 0 mode 121644 links 1 uid 0 gid 0 rdev 0
                sequence 9 flags 0x0(none)

This mode number 0120000 means it's a symlink.

But the dir item think it's still a regular file:

        item 8 key (264 DIR_INDEX 5) itemoff 3707 itemsize 32
                location key (268 INODE_ITEM 0) type FILE
                transid 13 data_len 0 name_len 2
                name: f4
        item 40 key (264 DIR_ITEM 51821248) itemoff 1573 itemsize 32
                location key (268 INODE_ITEM 0) type FILE
                transid 13 data_len 0 name_len 2
                name: f4

For symlink, we don't set BTRFS_I(inode)->io_tree.ops and leave it
empty, as symlink is only designed to have inlined extent, all handled
by tree block read.  Thus no need to trigger btrfs_submit_bio_hook() for
inline file extent.

However end_bio_extent_readpage() expects tree->ops populated, as it's
reading regular data extent.  This causes NULL pointer dereference.

[FIX]
This patch fixes the problem in two ways:

- Verify inode mode against its dir item when looking up inode
  So in btrfs_lookup_dentry() if we find inode mode mismatch with dir
  item, we error out so that corrupted inode will not be accessed.

- Verify inode mode when getting extent mapping
  Only regular file should have regular or preallocated extent.
  If we found regular/preallocated file extent for symlink or
  the rest, we error out before submitting the read bio.

With this fix that crafted image can be rejected gracefully:

  BTRFS critical (device loop0): inode mode mismatch with dir: inode mode=0121644 btrfs type=7 dir type=1

Reported-by: Yoon Jungyeon <jungyeon@gatech.edu>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=202763
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 28, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 28, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 29, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 29, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 30, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mrchapp pushed a commit to mrchapp/linux that referenced this issue Nov 30, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Whissi pushed a commit to Whissi/linux-stable that referenced this issue Dec 1, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Whissi pushed a commit to Whissi/linux-stable that referenced this issue Dec 1, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
isjerryxiao pushed a commit to isjerryxiao/Amlogic_s905-kernel that referenced this issue Dec 1, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
acervenky pushed a commit to acervenky/quax_raphael-q that referenced this issue Dec 9, 2019
[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kmou424 pushed a commit to kmou424/sena_kernel_violet-sm6150 that referenced this issue Dec 14, 2019
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista-2.6 that referenced this issue Dec 28, 2019
Source: Kernel.org
MR: 101655
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-4.19.y
ChangeID: 57aab8f0a33d5eab59d2108de0644f209941f39e
Description:

[ Upstream commit 9c87156 ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
freeza-inc pushed a commit to freeza-inc/bm-galaxy-note10-sd855-pie that referenced this issue Dec 29, 2019
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista-2.4 that referenced this issue Jan 4, 2020
Source: Kernel.org
MR: 101571
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable  linux-4.19.y
ChangeID: f1b3512388a7778cec40b5f892290257726e8c23
Description:

[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
freeza-inc pushed a commit to freeza-inc/bm-galaxy-note10-sd855-Q that referenced this issue Jan 25, 2020
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
@nickdesaulniers nickdesaulniers added [WORKAROUND] Applied This bug has an applied workaround and removed low priority This bug is not critical and not a priority labels Feb 8, 2020
kartikbhalla12 pushed a commit to kartikbhalla12/HyperX-X2 that referenced this issue Apr 4, 2020
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
miraclestars pushed a commit to miraclestars/android_kernel_samsung_sm8250 that referenced this issue Aug 12, 2020
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
TenSeventy7 pushed a commit to FreshROMs/android_kernel_samsung_exynos9610_mint that referenced this issue May 12, 2021
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Dark-Matter7232 pushed a commit to Dark-Matter7232/The-Cosmic-Staff that referenced this issue Jul 24, 2021
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sergoops pushed a commit to sergoops/kernel_realme_sm6150 that referenced this issue Aug 31, 2021
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
TenSeventy7 pushed a commit to FreshROMs/android_kernel_samsung_exynos9610_mint that referenced this issue Sep 2, 2021
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
krazey pushed a commit to krazey/android_kernel_motorola_exynos9610 that referenced this issue May 3, 2022
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
krazey pushed a commit to krazey/android_kernel_motorola_exynos9610 that referenced this issue May 4, 2022
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Meghthedev pushed a commit to SamsungM30s/android_kernel_samsung_m30s that referenced this issue May 9, 2023
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
@nickdesaulniers
Copy link
Member

Still unable to repro.

llvm-11:

$ git revert 9c87156
<comment out building vdso code in arch/powerpc/kernel/vdso/Makefile>
$ make CROSS_COMPILE=powerpc64le-linux-gnu- ARCH=powerpc LLVM=1 LLVM_IAS=0 -j128 defconfig arch/powerpc/xmon/xmon.o
$

llvm-18:

$ git revert 9c87156
$ make ARCH=powerpc LLVM=1 -j128 defconfig arch/powerpc/xmon/xmon.o

I'm also unable to reproduce the reported disassembly with clang-11+. Even tried on godbolt: https://godbolt.org/z/bqhjoWsTa

@nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers added [PATCH] Submitted A patch has been submitted for review unreproducible Not or no longer reproducible and removed [BUG] Untriaged Something isn't working labels Aug 17, 2023
@nickdesaulniers nickdesaulniers self-assigned this Aug 17, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 17, 2023
This reverts commit 9c87156.

I have not been able to reproduce the reported -Wframe-larger-than=
warning (or disassembly) with clang-11 or clang-18.

I don't know precisely when this was fixed in llvm, but it may be time
to revert this.

Closes: ClangBuiltLinux#252
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 21, 2023
This reverts commit 9c87156.

I have not been able to reproduce the reported -Wframe-larger-than=
warning (or disassembly) with clang-11 or clang-18.

I don't know precisely when this was fixed in llvm, but it may be time
to revert this.

Closes: ClangBuiltLinux#252
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230817-ppc_xmon-v1-1-8cc2d51b9995@google.com
@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Aug 23, 2023
@nathanchance
Copy link
Member

Unfortunately, it seems that there was some poor code generation with LLVM 12 and 13, as reported by CI (11 and 14 appear clean).

LLVM 12:

arch/powerpc/xmon/xmon.c:489:12: error: stack frame size of 2064 bytes in function 'xmon_core' [-Werror,-Wframe-larger-than=]
static int xmon_core(struct pt_regs *regs, volatile int fromipi)
           ^
1 error generated.

LLVM 13:

arch/powerpc/xmon/xmon.c:489:12: error: stack frame size (2096) exceeds limit (2048) in function 'xmon_core' [-Werror,-Wframe-larger-than]
static int xmon_core(struct pt_regs *regs, volatile int fromipi)
           ^
1 error generated.

Realistically, I think we can just ignore this and enable CONFIG_PPC_DISABLE_WERROR=y in CI for powernv_defconfig or maybe send something like

diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 2a54fadbeaf5..cb8e3f92bcf6 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -2,6 +2,8 @@

 config PPC_DISABLE_WERROR
        bool "Don't build arch/powerpc code with -Werror"
+       # There are a few known warnings for clang versions older than 14.0.0
+       default y if CC_IS_CLANG && CLANG_VERSION < 140000
        help
          This option tells the compiler NOT to build the code under
          arch/powerpc with the -Werror flag (which means warnings

since we still see/workaround #1445 as well.

Meghthedev pushed a commit to Meghthedev/kernel_samsung_m30s that referenced this issue Aug 25, 2023
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
@nickdesaulniers
Copy link
Member

kbuild test robot found a randconfig that breaks with clang-14: https://lore.kernel.org/llvm/202308260344.Vc4Giuk7-lkp@intel.com/

@nickdesaulniers nickdesaulniers removed the unreproducible Not or no longer reproducible label Aug 25, 2023
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Aug 28, 2023

akiyks pushed a commit to akiyks/linux that referenced this issue Aug 30, 2023
This is a manual revert of commit 7f3c5d0 ("Revert "powerpc/xmon:
Relax frame size for clang"") but using ccflags-$(CONFIG_CC_IS_CLANG)
which is shorter.

Turns out that this is reproducible still under specific compiler
versions (mea culpa: I did not test every supported version of clang),
and even a few randconfigs bots found.

We'll have to revisit this again in the future, for now back this out.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: ClangBuiltLinux#252 (comment)
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/llvm/202308260344.Vc4Giuk7-lkp@intel.com/
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230828-ppc_rerevert-v2-1-46b71a3656c6@google.com
@nickdesaulniers
Copy link
Member

clang-13:

$ git revert 90bae4d99beb1f31d8bde7
$ make CROSS_COMPILE=powerpc64le-linux-gnu- ARCH=powerpc LLVM=1 LLVM_IAS=0 -j128 defconfig arch/powerpc/xmon/xmon.o
arch/powerpc/xmon/xmon.c:490:12: error: stack frame size (2080) exceeds limit (2048) in function 'xmon_core' [-Werror,-Wframe-larger-than]
static int xmon_core(struct pt_regs *regs, volatile int fromipi)
           ^

Looking at xmon_core in LLVM IR, these look sus:

%struct.arch_hw_breakpoint = type { i64, i16, i16, i16, i8, i8 }                
...
define internal fastcc signext i32 @xmon_core(%struct.pt_regs* %regs, i32 signext %fromipi) unnamed_addr #0 {
...
  %null_brk.i.i568 = alloca %struct.arch_hw_breakpoint, align 8                 
...
%tmp.i.i = alloca [64 x i8], align 1
...
  %null_brk.i.i = alloca %struct.arch_hw_breakpoint, align 8        
...
 %recurse_jmp = alloca [23 x i64], align 8            

The two arch_hw_breakpoint do have lifetime markers, tmp does not. recurse_jmp has lifetime markers, but is effectively the entirety of the function. I wonder if the lifetime of recurse_jmp can be manually reduced (by moving its definition into a reduced scope?

In #39 (comment), I have a better idea of some of the issues in clang that are resulting in excessive stack usage, and how better to debug these kinds of issues in the future.

I think we'll leave this workaround in the kernel for now. I'll keep this issue open for now; once #39 is fixed, then it might be worthwhile to either:

  • update the in kernel workaround to be and older only
  • revert 90bae4d if we drop support for these older releases of clang with known stack size issues
  • try moving recurse_jmp to a reduced scope.

I suspect the former suggestion will make it easier to know when precisely to do the latter. For now, I'll leave this open until #39 fixes are landed in clang, as I'd like to eliminate those sources first.

@nickdesaulniers nickdesaulniers removed the [PATCH] Accepted A submitted patch has been accepted upstream label Oct 13, 2023
@nickdesaulniers nickdesaulniers removed their assignment Oct 13, 2023
LMAO-armv8 pushed a commit to LMAO-armv8/kernel_samsung_m31 that referenced this issue Nov 17, 2023
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Shas45558 pushed a commit to Shas45558/shas-dream-oc-mt6768 that referenced this issue Dec 26, 2023
[ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ]

When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: ClangBuiltLinux/linux#252
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wframe-larger-than= [ARCH] powerpc This bug impacts ARCH=powerpc [WORKAROUND] Applied This bug has an applied workaround
Projects
None yet
Development

No branches or pull requests

4 participants