From: Laura Abbott <labbott@redhat.com>
To: linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Will Deacon <will.deacon@arm.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: CONFIG_OPTIMIZE_INLINING breaks atomic64 test on arm64
Date: Tue, 28 May 2019 17:42:04 -0400 [thread overview]
Message-ID: <ba33029c-64f6-6908-a098-b543f0851fb7@redhat.com> (raw)
Hi,
CONFIG_OPTIMIZE_INLINING is a selectable option on arm64 now. It currently
triggers a bug on the CONFIG_ATOMIC64_SELFTEST:
[ 4.521551] ------------[ cut here ]------------
[ 4.521763] kernel BUG at lib/atomic64_test.c:220!
[ 4.522059] Internal error: Oops - BUG: 0 [#1] SMP
[ 4.522456] Modules linked in:
[ 4.522860] Process swapper/0 (pid: 1, stack limit = 0x(____ptrval____))
[ 4.523287] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.2.0-rc1 #6
[ 4.523462] Hardware name: linux,dummy-virt (DT)
[ 4.523779] pstate: a0000005 (NzCv daif -PAN -UAO)
[ 4.524231] pc : test_atomic64+0x1270/0x13a4
[ 4.524392] lr : test_atomic64+0x1258/0x13a4
[ 4.524571] sp : ffff000011f2fd60
[ 4.524755] x29: ffff000011f2fd60 x28: 0000000000000000
[ 4.525397] x27: 0000000000000000 x26: ffff000010d105c4
[ 4.525660] x25: ffff000010de10a0 x24: 0000000000000006
[ 4.525821] x23: aaa31337c001d00e x22: bbb42448e223f22f
[ 4.526032] x21: aaa31337c001d00c x20: 999202269ddfadeb
[ 4.526180] x19: aaa31337c001d00d x18: 0000000000000001
[ 4.526324] x17: 0000000000000000 x16: 1111111122222221
[ 4.526466] x15: ffff000010b838f0 x14: ffff80003fcf28c8
[ 4.526609] x13: 0000000000000000 x12: 0000000000000004
[ 4.526765] x11: 0000000000000000 x10: 0000000000000c80
[ 4.526940] x9 : 0000000000000000 x8 : ffff800020f12b00
[ 4.527090] x7 : deadbeefdeafcafe x6 : aaa31337c001d00d
[ 4.527234] x5 : ffff000011f2fda0 x4 : deadbeefdeafcafe
[ 4.527378] x3 : aaa31337c001d00d x2 : 1111111122222222
[ 4.527522] x1 : 1111111122222221 x0 : ffff000011f2fda0
[ 4.527759] Call trace:
[ 4.527923] test_atomic64+0x1270/0x13a4
[ 4.528047] test_atomics_init+0x10/0x28
[ 4.528162] do_one_initcall+0x54/0x230
[ 4.528273] kernel_init_freeable+0x1cc/0x278
[ 4.528397] kernel_init+0x18/0x108
[ 4.528510] ret_from_fork+0x10/0x18
[ 4.528827] Code: f2c22221 f2e22221 eb01001f 54000040 (d4210000)
[ 4.529647] ---[ end trace e08e679056f5b7ee ]---
Snippet of assembly from test_atomic64:
ffff000010de64cc: d2844442 mov x2, #0x2222 // #8738
ffff000010de64d0: 910103e0 add x0, sp, #0x40
ffff000010de64d4: f2a44442 movk x2, #0x2222, lsl #16
ffff000010de64d8: f2c22222 movk x2, #0x1111, lsl #32
ffff000010de64dc: f2e22222 movk x2, #0x1111, lsl #48
ffff000010de64e0: f90023e2 str x2, [sp, #64]
ffff000010de64e4: 97daa73b bl ffff0000104901d0 <arch_atomic64_dec_if_positive>
ffff000010de64e8: d2844421 mov x1, #0x2221 // #8737
ffff000010de64ec: f2a44441 movk x1, #0x2222, lsl #16
ffff000010de64f0: f2c22221 movk x1, #0x1111, lsl #32
ffff000010de64f4: f2e22221 movk x1, #0x1111, lsl #48
ffff000010de64f8: eb01001f cmp x0, x1
ffff000010de64fc: 54000040 b.eq ffff000010de6504 <test_atomic64+0x1274> // b.none
ffff000010de6500: d4210000 brk #0x800
The value returned from arch_atomic64_dec_if_positive looks like
a stack value
ffff0000104901d0 <arch_atomic64_dec_if_positive>:
ffff0000104901d0: a9bf7bfd stp x29, x30, [sp, #-16]!
ffff0000104901d4: aa0003e1 mov x1, x0
ffff0000104901d8: 910003fd mov x29, sp
ffff0000104901dc: 9412c9d5 bl ffff000010942930 <__ll_sc_arch_atomic64_dec_if_positive>
ffff0000104901e0: d503201f nop
ffff0000104901e4: d503201f nop
ffff0000104901e8: d503201f nop
ffff0000104901ec: d503201f nop
ffff0000104901f0: d503201f nop
ffff0000104901f4: d503201f nop
ffff0000104901f8: aa0103e0 mov x0, x1
ffff0000104901fc: a8c17bfd ldp x29, x30, [sp], #16
ffff000010490200: d65f03c0 ret
...which seems to be coming from this buggy looking code.
I can generate this with just defconfig + CONFIG_OPTIMIZE_INLINING + CONFIG_ATOMIC64_SELFTEST
on gcc8 and gcc9. This is also incredibly easy to work around and I expect
there are other issues with CONFIG_OPTIMIZE_INLINING but I figured I'd
report this for good measure.
Thanks,
Laura
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2019-05-28 21:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 21:42 Laura Abbott [this message]
2019-05-29 11:21 ` CONFIG_OPTIMIZE_INLINING breaks atomic64 test on arm64 Mark Rutland
2019-05-29 11:28 ` Mark Rutland
2019-05-29 11:29 ` Will Deacon
2019-05-29 11:53 ` Russell King - ARM Linux admin
2019-06-11 15:50 ` Will Deacon
2019-06-11 16:13 ` Laura Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba33029c-64f6-6908-a098-b543f0851fb7@redhat.com \
--to=labbott@redhat.com \
--cc=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=will.deacon@arm.com \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).