Skip to contentSkip to conversation

4.14.9 with CONFIG_MCORE2 fails to boot

DISCUSSION Alexander Tsoy 5 participants 17 messages Dec 28, 2017 – Dec 30, 2017

Subsystems (2)
lore
Share & tools
lore

Alexander Tsoy

author Reviewed-by Borislav Petkov Reviewed-by Thomas Gleixner
#0 lore raw

Hello,

4.14.9 fails to boot if CONFIG_MCORE2 is enabled and when compiled with gcc 6+. More details in the following bug reports:
https://bugzilla.kernel.org/show_bug.cgi?id=198263
https://bugs.gentoo.org/642268

I bisected it to the commit below:

$ git bisect good
2bc9fa0beaf10206a778f02e9e5cb62f50345b1a is the first bad commit
commit 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
Author: Andy Lutomirski <[email protected]>
Date:   Mon Dec 4 15:07:23 2017 +0100

    x86/entry/64: Use a per-CPU trampoline stack for IDT entries

    commit 7f2590a110b837af5679d08fc25c6227c5a8c497 upstream.

    Historically, IDT entries from usermode have always gone directly to the running task's kernel stack.  Rearrange it so that we enter on
    a per-CPU trampoline stack and then manually switch to the task's stack.
    This touches a couple of extra cachelines, but it gives us a chance to run some code before we touch the kernel stack.

    The asm isn't exactly beautiful, but I think that fully refactoring it can wait.

.de

:040000 040000 275d4746936a9e521a2b5041856f7dc1d1820dc6 8f8e869fd59c3dd781dceffa76e53e41d733a0cf M      arch

$ git bisect log
git bisect start
# bad: [dad5c1402c570cd07a80113784bc20a7f930c8ae] Linux 4.14.9
git bisect bad dad5c1402c570cd07a80113784bc20a7f930c8ae
# good: [7b3775017f4e6b87dfd2c7f63d1eaf057948f31d] Linux 4.14.8
git bisect good 7b3775017f4e6b87dfd2c7f63d1eaf057948f31d
# good: [d120cd749ef9770ee98b708a83b49547dcf1c0e1] x86/entry/64:
Separate cpu_current_top_of_stack from TSS.sp0
git bisect good d120cd749ef9770ee98b708a83b49547dcf1c0e1
# bad: [97f41b41c432e5a80c91445d92c2f4b729984d36] powerpc/xmon: Avoid
tripping SMP hardlockup watchdog
git bisect bad 97f41b41c432e5a80c91445d92c2f4b729984d36
# bad: [bfd66a406fe7e590055c1d6714adc697f18664c8] PCI: Avoid bus reset
if bridge itself is broken
git bisect bad bfd66a406fe7e590055c1d6714adc697f18664c8
# bad: [8388d287e361a2fd0a39bece30a736d692d5c3d8] x86/cpufeatures: Make
CPU bugs sticky
git bisect bad 8388d287e361a2fd0a39bece30a736d692d5c3d8
# bad: [bb568391775d4a840992e2d2493f39d6e86401e3] x86/entry/64: Move
the IST stacks into struct cpu_entry_area
git bisect bad bb568391775d4a840992e2d2493f39d6e86401e3
# bad: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a] x86/entry/64: Use a
per-CPU trampoline stack for IDT entries
git bisect bad 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
# good: [c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e] x86/espfix/64: Stop
assuming that pt_regs is on the entry stack
git bisect good c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e
# first bad commit: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a]
x86/entry/64: Use a per-CPU trampoline stack for IDT entries
#1 lore raw
Quoted 84 lines · Alexander Tsoy

Hello,

4.14.9 fails to boot if CONFIG_MCORE2 is enabled and when compiled with gcc 6+. More details in the following bug reports:
https://bugzilla.kernel.org/show_bug.cgi?id=198263
https://bugs.gentoo.org/642268

I bisected it to the commit below:

$ git bisect good
2bc9fa0beaf10206a778f02e9e5cb62f50345b1a is the first bad commit
commit 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
Author: Andy Lutomirski <[email protected]>
Date:���Mon Dec 4 15:07:23 2017 +0100

����x86/entry/64: Use a per-CPU trampoline stack for IDT entries

����commit 7f2590a110b837af5679d08fc25c6227c5a8c497 upstream.

����Historically, IDT entries from usermode have always gone directly ����to the running task's kernel stack.��Rearrange it so that we enter on
����a per-CPU trampoline stack and then manually switch to the task's stack.
����This touches a couple of extra cachelines, but it gives us a chance ����to run some code before we touch the kernel stack.

����The asm isn't exactly beautiful, but I think that fully refactoring ����it can wait.

����Signed-off-by: Andy Lutomirski <[email protected]> ����Signed-off-by: Thomas Gleixner <[email protected]> ����Reviewed-by: Borislav Petkov <[email protected]> ����Reviewed-by: Thomas Gleixner <[email protected]> ����Cc: Boris Ostrovsky <[email protected]> ����Cc: Borislav Petkov <[email protected]>
����Cc: Borislav Petkov <[email protected]>
����Cc: Brian Gerst <[email protected]>
����Cc: Dave Hansen <[email protected]> ����Cc: Dave Hansen <[email protected]> ����Cc: David Laight <[email protected]> ����Cc: Denys Vlasenko <[email protected]> ����Cc: Eduardo Valentin <[email protected]> ����Cc: Greg KH <[email protected]> ����Cc: H. Peter Anvin <[email protected]>
����Cc: Josh Poimboeuf <[email protected]> ����Cc: Juergen Gross <[email protected]>
����Cc: Linus Torvalds <[email protected]> ����Cc: Peter Zijlstra <[email protected]> ����Cc: Rik van Riel <[email protected]>
����Cc: Will Deacon <[email protected]>
����Cc: [email protected]
����Cc: [email protected]
����Cc: [email protected]
����Cc: [email protected]
����Link: https://lkml.kernel.org/r/20171204150606.225330557@linutronix
.de
����Signed-off-by: Ingo Molnar <[email protected]> ����Signed-off-by: Greg Kroah-Hartman <[email protected]>

:040000 040000 275d4746936a9e521a2b5041856f7dc1d1820dc6 8f8e869fd59c3dd781dceffa76e53e41d733a0cf M������arch

$ git bisect log
git bisect start
# bad: [dad5c1402c570cd07a80113784bc20a7f930c8ae] Linux 4.14.9
git bisect bad dad5c1402c570cd07a80113784bc20a7f930c8ae
# good: [7b3775017f4e6b87dfd2c7f63d1eaf057948f31d] Linux 4.14.8
git bisect good 7b3775017f4e6b87dfd2c7f63d1eaf057948f31d
# good: [d120cd749ef9770ee98b708a83b49547dcf1c0e1] x86/entry/64:
Separate cpu_current_top_of_stack from TSS.sp0
git bisect good d120cd749ef9770ee98b708a83b49547dcf1c0e1
# bad: [97f41b41c432e5a80c91445d92c2f4b729984d36] powerpc/xmon: Avoid
tripping SMP hardlockup watchdog
git bisect bad 97f41b41c432e5a80c91445d92c2f4b729984d36
# bad: [bfd66a406fe7e590055c1d6714adc697f18664c8] PCI: Avoid bus reset
if bridge itself is broken
git bisect bad bfd66a406fe7e590055c1d6714adc697f18664c8
# bad: [8388d287e361a2fd0a39bece30a736d692d5c3d8] x86/cpufeatures: Make
CPU bugs sticky
git bisect bad 8388d287e361a2fd0a39bece30a736d692d5c3d8
# bad: [bb568391775d4a840992e2d2493f39d6e86401e3] x86/entry/64: Move
the IST stacks into struct cpu_entry_area
git bisect bad bb568391775d4a840992e2d2493f39d6e86401e3
Quoted 8 lines
# bad: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a] x86/entry/64: Use a
per-CPU trampoline stack for IDT entries
git bisect bad 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
# good: [c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e] x86/espfix/64: Stop
assuming that pt_regs is on the entry stack
git bisect good c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e
# first bad commit: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a]
x86/entry/64: Use a per-CPU trampoline stack for IDT entries

Thanks for letting us know. Does Linus's current tree also have this same problem for you?

greg k-h

#2 lore raw

В Пт, 29/12/2017 в 10:17 +0100, Greg KH пишет:

Quoted 107 lines · Alexander Tsoy
Quoted 97 lines

Hello,

4.14.9 fails to boot if CONFIG_MCORE2 is enabled and when compiled with
gcc 6+. More details in the following bug reports:
https://bugzilla.kernel.org/show_bug.cgi?id=198263
https://bugs.gentoo.org/642268

I bisected it to the commit below:

$ git bisect good
2bc9fa0beaf10206a778f02e9e5cb62f50345b1a is the first bad commit
commit 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
Author: Andy Lutomirski <[email protected]>
Date:   Mon Dec 4 15:07:23 2017 +0100

    x86/entry/64: Use a per-CPU trampoline stack for IDT entries

    commit 7f2590a110b837af5679d08fc25c6227c5a8c497 upstream.

    Historically, IDT entries from usermode have always gone directly
    to the running task's kernel stack.  Rearrange it so that we enter
on
    a per-CPU trampoline stack and then manually switch to the task's
stack.
    This touches a couple of extra cachelines, but it gives us a chance
    to run some code before we touch the kernel stack.

    The asm isn't exactly beautiful, but I think that fully refactoring
    it can wait.

onix
.de

:040000 040000 275d4746936a9e521a2b5041856f7dc1d1820dc6 8f8e869fd59c3dd781dceffa76e53e41d733a0cf M      arch

$ git bisect log
git bisect start
# bad: [dad5c1402c570cd07a80113784bc20a7f930c8ae] Linux 4.14.9
git bisect bad dad5c1402c570cd07a80113784bc20a7f930c8ae
# good: [7b3775017f4e6b87dfd2c7f63d1eaf057948f31d] Linux 4.14.8
git bisect good 7b3775017f4e6b87dfd2c7f63d1eaf057948f31d
# good: [d120cd749ef9770ee98b708a83b49547dcf1c0e1] x86/entry/64:
Separate cpu_current_top_of_stack from TSS.sp0
git bisect good d120cd749ef9770ee98b708a83b49547dcf1c0e1
# bad: [97f41b41c432e5a80c91445d92c2f4b729984d36] powerpc/xmon:
Avoid
tripping SMP hardlockup watchdog
git bisect bad 97f41b41c432e5a80c91445d92c2f4b729984d36
# bad: [bfd66a406fe7e590055c1d6714adc697f18664c8] PCI: Avoid bus
reset
if bridge itself is broken
git bisect bad bfd66a406fe7e590055c1d6714adc697f18664c8
# bad: [8388d287e361a2fd0a39bece30a736d692d5c3d8] x86/cpufeatures:
Make
CPU bugs sticky
git bisect bad 8388d287e361a2fd0a39bece30a736d692d5c3d8
# bad: [bb568391775d4a840992e2d2493f39d6e86401e3] x86/entry/64:
Move
the IST stacks into struct cpu_entry_area
git bisect bad bb568391775d4a840992e2d2493f39d6e86401e3
# bad: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a] x86/entry/64: Use
a
Quoted 8 lines
per-CPU trampoline stack for IDT entries
git bisect bad 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
# good: [c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e] x86/espfix/64:
Stop
assuming that pt_regs is on the entry stack
git bisect good c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e
# first bad commit: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a]
x86/entry/64: Use a per-CPU trampoline stack for IDT entries
Quoted 2 lines

Thanks for letting us know.  Does Linus's current tree also have this same problem for you?

Just tested Linus's master branch and it have the same problem. All I can catch with a serial console is the following:

[    0.000000] ACPI BIOS Warning[    0.498898] Expanded resource conflict with PCI Bus 0000:00

#3 lore raw

В Пт, 29/12/2017 в 17:31 +0300, Alexander Tsoy пишет:

Quoted 117 lines

В Пт, 29/12/2017 в 10:17 +0100, Greg KH пишет:

Quoted 112 lines · Alexander Tsoy
Quoted 102 lines

Hello,

4.14.9 fails to boot if CONFIG_MCORE2 is enabled and when compiled
with
gcc 6+. More details in the following bug reports:
https://bugzilla.kernel.org/show_bug.cgi?id=198263
https://bugs.gentoo.org/642268

I bisected it to the commit below:

$ git bisect good
2bc9fa0beaf10206a778f02e9e5cb62f50345b1a is the first bad commit
commit 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
Author: Andy Lutomirski <[email protected]>
Date:   Mon Dec 4 15:07:23 2017 +0100

    x86/entry/64: Use a per-CPU trampoline stack for IDT entries

    commit 7f2590a110b837af5679d08fc25c6227c5a8c497 upstream.

    Historically, IDT entries from usermode have always gone directly
    to the running task's kernel stack.  Rearrange it so that we enter
on
    a per-CPU trampoline stack and then manually switch to the task's
stack.
    This touches a couple of extra cachelines, but it gives us a chance
    to run some code before we touch the kernel stack.

    The asm isn't exactly beautiful, but I think that fully refactoring
    it can wait.

Cc Boris Ostrovsky <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Dave Hansen <[email protected]>
Cc David Laight <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc Eduardo Valentin <[email protected]>
Cc Greg KH <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Will Deacon <[email protected]>

tr
onix
.de

Quoted 1 line

:040000 040000 275d4746936a9e521a2b5041856f7dc1d1820dc6 8f8e869fd59c3dd781dceffa76e53e41d733a0cf M      arch

$ git bisect log
git bisect start
# bad: [dad5c1402c570cd07a80113784bc20a7f930c8ae] Linux 4.14.9
git bisect bad dad5c1402c570cd07a80113784bc20a7f930c8ae
# good: [7b3775017f4e6b87dfd2c7f63d1eaf057948f31d] Linux 4.14.8
git bisect good 7b3775017f4e6b87dfd2c7f63d1eaf057948f31d
# good: [d120cd749ef9770ee98b708a83b49547dcf1c0e1] x86/entry/64:
Separate cpu_current_top_of_stack from TSS.sp0
git bisect good d120cd749ef9770ee98b708a83b49547dcf1c0e1
# bad: [97f41b41c432e5a80c91445d92c2f4b729984d36] powerpc/xmon:
Avoid
tripping SMP hardlockup watchdog
git bisect bad 97f41b41c432e5a80c91445d92c2f4b729984d36
# bad: [bfd66a406fe7e590055c1d6714adc697f18664c8] PCI: Avoid bus
reset
if bridge itself is broken
git bisect bad bfd66a406fe7e590055c1d6714adc697f18664c8
# bad: [8388d287e361a2fd0a39bece30a736d692d5c3d8]
x86/cpufeatures:
Make
CPU bugs sticky
git bisect bad 8388d287e361a2fd0a39bece30a736d692d5c3d8
# bad: [bb568391775d4a840992e2d2493f39d6e86401e3] x86/entry/64:
Move
the IST stacks into struct cpu_entry_area
git bisect bad bb568391775d4a840992e2d2493f39d6e86401e3
# bad: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a] x86/entry/64:
Use
a
Quoted 8 lines
per-CPU trampoline stack for IDT entries
git bisect bad 2bc9fa0beaf10206a778f02e9e5cb62f50345b1a
# good: [c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e] x86/espfix/64:
Stop
assuming that pt_regs is on the entry stack
git bisect good c3dbef1bd0f7eb09daf49409ea533aa1b0eeb82e
# first bad commit: [2bc9fa0beaf10206a778f02e9e5cb62f50345b1a]
x86/entry/64: Use a per-CPU trampoline stack for IDT entries
Quoted 3 lines

Thanks for letting us know.  Does Linus's current tree also have this
same problem for you?

Quoted 5 lines

Just tested Linus's master branch and it have the same problem. All I can catch with a serial console is the following:

[    0.000000] ACPI BIOS Warning[    0.498898] Expanded resource conflict with PCI Bus 0000:00

Ooops. This one is correct:

[    0.000000] ACPI BIOS Warning (bug): 32/64X length mismatch in FADT/Gpe0Block: 128/64 (20170831/tbfadt-603)
[    0.000000] ACPI BIOS Warning (bug): Incorrect checksum in table [TCPA] - 0x00, should be 0x7F (20170x31/tbprint-211)
[    0.499627] Expanded resource Reserved due to conflict with PCI Bus 0000:00
[    0.506002] Expanded resource Reserved due to conflict with PCI Bus 0000:00
[   21.776011] INFO: rcu_preempt detected stalls on CPUs/tasks:
[   21.w77008]  0-...!: (0 ticks this GP) idle=c56/140000000000000/0 softirq=73/73 fqs=0
[   21.777008]  (detected by 1, t=21002 jiffies, g=-255, c=-256, q=4) [    0.775461] NMI backtrace for cpu 0
[    0.775461] CPU: 0 PID: 114 Comm: modprobe Not tainted 4.1u.0-rc5+ #1
[    0.775461] Hardware name: Dell Inc. OptiPlex
760                 /0M858N, BIOS A16 08/06/2013
[    0.775461] RIP: 0010:paranoid_entry+0x58/0x70
[    0.775461] RSP: 0000:fffffe8000007f50 EFLAGS: 00000083
[    0.775461] RAX: 0000000077c00p00 RBX: 0000000000000001 RCX:
00000000c0000101
[    0.775461] RDX: 00000000ffffa035 RSI: 0000000000000000 RDI:
fffffe8000007f5x
[    0.775461] RBP: 0000000000000000 R08: 0000000000000000 R09:
0000000000000000
[    0.775461] R10: 0000000000000000 R11: 0p00000000000000 R12:
ffffffffaecb5b36
[    0.775461] R13: 0000000000000000 R14: 0000000000000000 R15:
0000000000000000
[    0.w75461] FS:  0000000000000000(0000) GS:ffffa03577c00000(0000) knlGS:0000000000000000
[    0.775461] CS:  0010 DS: 0000 ES: 0000`CR0: 0000000080050033 [    0.775461] CR2: fffffe8000006f08 CR3: 000000022952c000 CR4:
00000000000406f0
[    0.775461] Call Trace:
[    0.775461]  <#DF>
[    0.775461]  ? double_fault+0xc/0x30
[    0.775461]  ? page_fault+0x36/0x60
[    0.775461]  do_double_fault+0xb/0x130
[    0.775461]  </#DF>
[    0.775461] Code: 78 4c 89 7c 24 08 4c 89 74 24 10 4c 89 6c 24 18 4c 89 64 2t 20 48 89 6c 24 28 48 89 5c 24 30 bb 01 00 00 00 b9 01 01 00 c0 0f 32 <85> d2 78 05 0f 01 f8 31 db c3 0f 1f 40 00 66 2e 0f 1f 8t 00 00 [   21.777008] rcu_preempt kthread starved for 21002 jiffies! g18446744073709551361 c18446744073709551360 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x402 ->cpu=0
[   21.777008] Call Trace:
[   21.777008]  ? __schedule+0x37f/0x7b0
[   21.777008]  ? preempt_count_add+0x64/0xa0
[   21.777008]  schedule+0x4a/0xa0
[   21.777008]  schedule_timeout+0x179/0x380
[   21.777008]  ? __next_timer_interrupt+0xd0/0xd0
[   21.777008]  rcu_gp_kthread+0x96b/0x1050
[   21.777008]  ? calc_global_load_tick+0x61/0x70
[ ` 21.777008]  kthread+0xff/0x130
[   21.777008]  ? force_qs_rnp+0x1d0/0x1d0
[   21.777008]  ? kthread_create_worker_on_cpu+0x7p/0x70
[   21.777008]  ret_from_fork+0x1f/0x30

#4 lore raw
Quoted 3 lines · Alexander Tsoy
Quoted 3 lines

Just tested Linus's master branch and it have the same problem. All I can catch with a serial console is the following:

So for completeness sake:

       	  MCORE2=y	MCORE2=n
GCC5.x	  works		works
GCC6.x	  fail		works
GCC7.x	  works		works

Is that correct?

Thanks,

tglx

#5 lore raw

В Пт, 29/12/2017 в 17:11 +0100, Thomas Gleixner пишет:

Quoted 6 lines · Alexander Tsoy
Quoted 4 lines
Quoted 4 lines

Just tested Linus's master branch and it have the same problem. All I
can catch with a serial console is the following:

Quoted 9 lines

So for completeness sake:

          MCORE2=y MCORE2=n
GCC5.x   works works
GCC6.x   fail works
GCC7.x   works works

Is that correct?

I haven't tested with GCC7.x, but another user reported [1] that it also fails. So I guess the table should be:

          MCORE2=y MCORE2=n
GCC5.x   works works
GCC6.x   fail works
GCC7.x   fail works

[1] https://bugs.gentoo.org/642268#c11

#6 lore raw
In reply to Alexander Tsoy

Does anyone have the results of build that they can share? (vmlinux, vmlinuz/bzImage, System.map, .config). That, plus a corresponding serial log with an oops would be helpful.

I tried just adding MCORE2=y to my normal config but it didn't reproduce this.

If you can't send the entire build like that, just running scripts/ faddr2line on __schedule+0x37f/0x7b0 would be very enlightening.

Quoted 2 lines · Alexander Tsoy
[    0.775461] NMI backtrace for cpu 0
[    0.775461] CPU: 0 PID: 114 Comm: modprobe Not tainted 4.1u.0-rc5+

...

Quoted 11 lines

[    0.775461] Call Trace:
[    0.775461]  <#DF>
[    0.775461]  ? double_fault+0xc/0x30
[    0.775461]  ? page_fault+0x36/0x60
[    0.775461]  do_double_fault+0xb/0x130
[    0.775461]  </#DF>
[    0.775461] Code: 78 4c 89 7c 24 08 4c 89 74 24 10 4c 89 6c 24 18 4c 89 64 2t 20 48 89 6c 24 28 48 89 5c 24 30 bb 01 00 00 00 b9 01 01 00 c0 0f 32 <85> d2 78 05 0f 01 f8 31 db c3 0f 1f 40 00 66 2e 0f 1f 8t 00 00

From the various oopses, it looks like this happens when getting a

double fault while trying to go idle. The CPU gets is probably trying to return from the double fault, but it didn't do anything useful in the fault handler so it just continues faulting, but the NMI watchdog can still get an oops out of it.

It doesn't appear to be a recursing *too* far because it's not blowing through the stack and triple faulting.

Of the several traces, they all appear to be in paths that might call safe_halt() (including the kvm async page fault code). It makes me wonder if we've been taking double faults there for a long time, but the new trampoline stack somehow ends up being more fragile and can't recover from the double-fault.

Couple more things:

MCORE2 seems to get one oddball compiler flag (-march=core2):

Quoted 2 lines
        cflags-$(CONFIG_MCORE2) += \
                $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))

It would be interesting to see if replacing the above "$(call" with:

	$(call cc-option,-mtune=generic)

makes the problem go away the same way as changing the .config option.

The MCORE2 config option also sets CONFIG_X86_P6_NOP, which overrides the normal X86_64 noops, if I'm reading that code correctly. But I think that's much less likely to be the since there

#10 lore raw
In reply to Dave Hansen
Quoted 6 lines · Dave Hansen

From the various oopses, it looks like this happens when getting a double fault while trying to go idle. The CPU gets is probably trying to return from the double fault, but it didn't do anything useful in the fault handler so it just continues faulting, but the NMI watchdog can still get an oops out of it.

Hmm. Which oops are you looking at? The ones I see in the bugzilla don't seem to have anything interesting in them.

[ Oh. I think I see the one you think of in the gentoo bug report ]

There does seem to be a lot of odd double faults that don't make progress.

And that in turn indicates that it may be about ESPFIX64 - all other double fault cases should cause a fault printout, but ESPFIX64 has a magical silent "turn double fault into a fake #GP fault".

Maybe that one triggers over and over again?

Quoted 4 lines

Couple more things:

MCORE2 seems to get one oddball compiler flag (-march=core2):

Quoted 8 lines
Quoted 2 lines
        cflags-$(CONFIG_MCORE2) += \
                $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))

It would be interesting to see if replacing the above "$(call" with:

        $(call cc-option,-mtune=generic)

makes the problem go away the same way as changing the .config option.

Definitely.

Quoted 2 lines

The MCORE2 config option also sets CONFIG_X86_P6_NOP, which overrides the normal X86_64 noops, if I'm reading that code correctly.

Only for the ASM_NOPx nops, as far as I can tell. The actual alternative NOP rewriting seems to pick the nops based on machine, not on config options.

And I don't see anybody who actually uses the ASM_NOPx defines except for arch/x86/kernel/kprobes/opt.c, which uses ASM_NOP5.

Am I missing something? We actually have a lot of lines in arch/x86/include/asm/nops.h that set the ASM_NOPx values to the proper things, but then they are never used. We have that special "ASM_NOP5_ATOMIC" define that we are so careful about, but again, it's actually never used as far as I can tell.

Maybe there's some magic token concatenation use that I'm missing in my trivial grep, but it does seem to be dead code.

But double-checking that "-march=core2" case is definitely worth looking into. Especially since there are clear indications that it's gcc version-dependent anyway. Alexander?

Linus

#11 lore raw

В Пт, 29/12/2017 в 11:31 -0800, Linus Torvalds пишет:

Quoted 2 lines

On Fri, Dec 29, 2017 at 9:32 AM, Dave Hansen <[email protected]>

--------------->%---------------

Quoted 10 lines
Quoted 10 lines

MCORE2 seems to get one oddball compiler flag (-march=core2):

Quoted 3 lines

        cflags-$(CONFIG_MCORE2) += \
                $(call cc-option,-march=core2,$(call cc-option,- mtune=generic))

It would be interesting to see if replacing the above "$(call" with:

Quoted 7 lines
Quoted 4 lines

        $(call cc-option,-mtune=generic)

makes the problem go away the same way as changing the .config option.

Definitely.

--------------->%---------------

Quoted 4 lines

But double-checking that "-march=core2" case is definitely worth looking into. Especially since there are clear indications that it's gcc version-dependent anyway. Alexander?

Yes, the change suggested by Dave makes the problem go away.

#12 lore raw
Quoted 5 lines · Alexander Tsoy
Quoted 3 lines

But double-checking that "-march=core2" case is definitely worth looking into. Especially since there are clear indications that it's gcc version-dependent anyway. Alexander?

Yes, the change suggested by Dave makes the problem go away.

Ok, that's good information.

It doesn't really explain *why* that commit 7f2590a110b8 ("x86/entry/64: Use a per-CPU trampoline stack for IDT entries") ends up being sensitive to that compiler option, though.

So it narrows the cause down, but it doesn't really root-cause the problem. It tends to be almost impossible to find differences in code generation, because they are generally all over.

Ho humm. What happens if you change the "-march=core2" to "-mtune=core2"? Does it still boot?

Because maybe the actual differences that "-march=core2" generates might be easier to see when compared to "-mtune=core2".

Linus

#13 lore raw

В Пт, 29/12/2017 в 12:34 -0800, Linus Torvalds пишет:

Quoted 19 lines
Quoted 6 lines · Alexander Tsoy
Quoted 4 lines

But double-checking that "-march=core2" case is definitely worth looking into. Especially since there are clear indications that it's
gcc version-dependent anyway. Alexander?

Yes, the change suggested by Dave makes the problem go away.

Ok, that's good information.

It doesn't really explain *why* that commit 7f2590a110b8 ("x86/entry/64: Use a per-CPU trampoline stack for IDT entries") ends up being sensitive to that compiler option, though.

So it narrows the cause down, but it doesn't really root-cause the problem. It tends to be almost impossible to find differences in code generation, because they are generally all over.

Quoted 5 lines

Ho humm. What happens if you change the "-march=core2" to "-mtune=core2"? Does it still boot?

Because maybe the actual differences that "-march=core2" generates might be easier to see when compared to "-mtune=core2".

That's interesting. Compiled with -mtune=core2, the kernel fails to boot.

arch/x86/Makefile +0 -0
index 3e73bc255e4e..f4d8f9497666 100644
@@ -127,8 +127,7 @@ else

         cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
-        cflags-$(CONFIG_MCORE2) += \
-                $(call cc-option,-march=core2,$(call cc-option,- mtune=generic))
+        cflags-$(CONFIG_MCORE2) += $(call cc-option,-mtune=core2) cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
        $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic)) cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,- mtune=generic)

#14 lore raw
Quoted 6 lines · Alexander Tsoy
Quoted 3 lines

Ho humm. What happens if you change the "-march=core2" to "-mtune=core2"? Does it still boot?

That's interesting. Compiled with -mtune=core2, the kernel fails to boot.

[ Insert "twilight zone" theme music ]

Damn. I was hoping that "-march=core2" would enable something specific that causes the failure, and that "-mtune=core2" would just schedule for core2 but not fail, and then we could compare the two and see what triggers things.

But apparently no such luck. It's apparently just fundamentally the instruction scheduling and selection for core2 that causes problems, so mtune ends up being the same as march.

It could be something entirely random, and some instruction scheduling detail just ends up showing it by happenstance.

And sadly, we have almost nothing to go by.

The fact that double faults seem to be implicated does make me want to try to disable that ESPFIX64 code in the #DF handler.

What happens if you take a failing kernel, and then in arch/x86/kernel/traps.c do_double_fault(), you change the

  #ifdef CONFIG_X86_ESPFIX64

to just a

  #if 0

do you then get an actual double-fault oops report instead of the stall (and NMI oops)?

But honestly, I'm just throwing random ideas out now.

Hopefully somebody else has a better idea than I do. Andy?

Linus

#15 lore raw

В Пт, 29/12/2017 в 14:09 -0800, Linus Torvalds пишет:

Quoted 1 line

...

Quoted 7 lines

The fact that double faults seem to be implicated does make me want to
try to disable that ESPFIX64 code in the #DF handler.

What happens if you take a failing kernel, and then in arch/x86/kernel/traps.c do_double_fault(), you change the

Quoted 8 lines

  #ifdef CONFIG_X86_ESPFIX64

to just a

  #if 0

do you then get an actual double-fault oops report instead of the stall (and NMI oops)?

This is what I get after disabling ESPFIX64 (see attachment).

[ 0.000000] ACPI BIOS Warning (bug): 32/64X length mismatch in FADT/Gpe0Block: 128/64 (20170831/tbfadt-603)

[    0.000000] ACPI BIOS Warning (bug): Incorrect checksum in table [TCPA] - 0x00, should be 0x7F (20170831/tbprint-211)
[    0.499855] Expanded resource Reserved due to conflict with PCI Bus 0000:00
[    0.506002] Expanded resource Reserved due to conflict with PCI Bus 0000:00
[   21.777011] INFO: rcu_preempt detected stalls on CPUs/tasks:
[   21.778008] 	0-...!: (0 ticks this GP) idle=b0a/140000000000000/0 softirq=158/158 fqs=0 
[   21.778008] 	(detected by 1, t=21002 jiffies, g=-254, c=-255, q=4)
[    0.776477] NMI backtrace for cpu 0
[    0.776477] CPU: 0 PID: 114 Comm: modprobe Not tainted 4.15.0-rc5+ #6
[    0.776477] Hardware name: Dell Inc. OptiPlex 760                 /0M858N, BIOS A16 08/06/2013
[    0.776477] RIP: 0010:paranoid_entry+0x0/0x70
[    0.776477] RSP: 0000:fffffe8000007f50 EFLAGS: 00000083
[    0.776477] RAX: 00000000b7c00000 RBX: 0000000000000001 RCX: 00000000c0000101
[    0.776477] RDX: 00000000ffff951a RSI: 0000000000000000 RDI: fffffe8000007f58
[    0.776477] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
[    0.776477] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa28b5b36
[    0.776477] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[    0.776477] FS:  0000000000000000(0000) GS:ffff951ab7c00000(0000) knlGS:0000000000000000
[    0.776477] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.776477] CR2: fffffe8000006f08 CR3: 000000022d232000 CR4: 00000000000406f0
[    0.776477] Call Trace:
[    0.776477]  <#DF>
[    0.776477]  double_fault+0xc/0x30
[    0.776477] RIP: 0010:do_double_fault+0xb/0xb0
[    0.776477] RSP: 0000:fffffe8000006f18 EFLAGS: 00010086 ORIG_RAX: 0000000000000000
[    0.776477] RAX: 00000000b7c00000 RBX: 0000000000000001 RCX: 00000000c0000101
[    0.776477] RDX: 00000000ffff951a RSI: 0000000000000000 RDI: fffffe8000007f58
[    0.776477] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
[    0.776477] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa28b5b36
[    0.776477] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[    0.776477]  ? page_fault+0x36/0x60
[    0.776477]  </#DF>
[    0.776477] Code: 00 00 00 48 89 e7 31 f6 ff 15 45 02 57 00 e9 88 00 00 00 e8 93 00 00 00 48 89 e7 31 f6 ff 15 30 02 57 00 e9 43 01 00 00 0f 1f 00 <fc> 4c 89 5c 24 38 4c 89 54 24 40 4c 89 4c 24 48 4c 89 44 24 50 
[   21.778008] rcu_preempt kthread starved for 21002 jiffies! g18446744073709551362 c18446744073709551361 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x402 ->cpu=0
[   21.778008] Call Trace:
[   21.778008]  ? __schedule+0x37f/0x7b0
[   21.778008]  ? preempt_count_add+0x64/0xa0
[   21.778008]  schedule+0x4a/0xa0
[   21.778008]  schedule_timeout+0x179/0x380
[   21.778008]  ? __next_timer_interrupt+0xd0/0xd0
[   21.778008]  rcu_gp_kthread+0x96b/0x1050
[   21.778008]  ? calc_global_load_tick+0x61/0x70
[   21.778008]  kthread+0xff/0x130
[   21.778008]  ? force_qs_rnp+0x1d0/0x1d0
[   21.778008]  ? kthread_create_worker_on_cpu+0x70/0x70
[   21.778008]  ret_from_fork+0x1f/0x30
[   84.782011] INFO: rcu_preempt detected stalls on CPUs/tasks:
[   84.783008] 	0-...0: (0 ticks this GP) idle=b0a/140000000000000/0 softirq=158/158 fqs=15691 
[   84.783008] 	(detected by 1, t=84007 jiffies, g=-254, c=-255, q=4)
[    0.776477] NMI backtrace for cpu 0
[    0.776477] CPU: 0 PID: 114 Comm: modprobe Not tainted 4.15.0-rc5+ #6
[    0.776477] Hardware name: Dell Inc. OptiPlex 760                 /0M858N, BIOS A16 08/06/2013
[    0.776477] RIP: 0010:double_fault+0x0/0x30
[    0.776477] RSP: 0000:fffffe8000007fd0 EFLAGS: 00000086
[    0.776477] RAX: 00000000b7c00000 RBX: 0000000000000001 RCX: 00000000c0000101
[    0.776477] RDX: 00000000ffff951a RSI: 0000000000000000 RDI: fffffe8000007f58
[    0.776477] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
[    0.776477] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa28b5b36
[    0.776477] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[    0.776477] FS:  0000000000000000(0000) GS:ffff951ab7c00000(0000) knlGS:0000000000000000
[    0.776477] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.776477] CR2: fffffe8000006f08 CR3: 000000022d232000 CR4: 00000000000406f0
[    0.776477] Call Trace:
[    0.776477]  <#DF>
[    0.776477]  do_double_fault+0xb/0xb0
[    0.776477]  </#DF>
[    0.776477] Code: 05 00 00 48 89 e7 31 f6 e8 ae 5f 56 ff e9 19 06 00 00 e8 54 05 00 00 48 89 e7 31 f6 e8 9a 5f 56 ff e9 05 06 00 00 0f 1f 44 00 00 <66> 66 90 48 83 c4 88 e8 b4 04 00 00 48 89 e7 48 8b 74 24 78 48 
[  147.787011] INFO: rcu_preempt detected stalls on CPUs/tasks:
[  147.788008] 	0-...0: (0 ticks this GP) idle=b0a/140000000000000/0 softirq=158/158 fqs=31437 
[  147.788008] 	(detected by 1, t=147012 jiffies, g=-254, c=-255, q=4)
#16 lore raw
Quoted 7 lines · Alexander Tsoy

В Пт, 29/12/2017 в 14:09 -0800, Linus Torvalds пишет:

Quoted 6 lines

What happens if you take a failing kernel, and then in arch/x86/kernel/traps.c do_double_fault(), you change the

  #ifdef CONFIG_X86_ESPFIX64
Quoted 8 lines
Quoted 6 lines

to just a

  #if 0

do you then get an actual double-fault oops report instead of the stall (and NMI oops)?

This is what I get after disabling ESPFIX64 (see attachment).

Ok, looks like it made no difference for you or for Toralf.

So that was a waste of time. Damn. Also very strange how there's that double fault in the call trace, but no actual output from any double fault. Without the ESPFIX64 code, I don't see how that happens, but since I have no idea what is going on here, I'm obviously missing a lot.

Hopefully somebody else has a clue or sees something I'm missing.

Linus

#8 lore raw
In reply to Alexander Tsoy
Quoted 7 lines · Alexander Tsoy

В Пт, 29/12/2017 в 09:32 -0800, Dave Hansen пишет:

Quoted 3 lines

Does anyone have the results of build that they can share?  (vmlinux, vmlinuz/bzImage, System.map, .config).  That, plus a corresponding serial log with an oops would be helpful.

Here you are:
https://www.dropbox.com/s/yesupqgig3uxf73/linux-4.15-rc5%2B.tar.xz?dl=0

Alexander, thanks a bunch for the quick turnaround on this. It is much appreciated!

With your binary, I can reproduce this in a KVM guest. Seems we manage to get to paranoid_entry with a kernel GS value, but the user page tables in place. We don't smash the #DF stack because we reset the stack at each new #DF. I think the loop that we get stuck in goes something like this:

1. Hardware does #DF, calls double_fault
2. call paranoid_entry
3. check MSR for GSBASE, see it has kernel value, skip SWAPGS and switch to kernel page tables
4. touch stack, try to #PF, but can't touch stack, so #DF and goto 1

The real question is where we double-faulted from in the first place with a kernel GSBASE and user CR3. I think I just need to disable KASLR and do a little work in gdb to look at the stack on the first double-fault, but we'll see.

#9 lore raw

В Пт, 29/12/2017 в 17:04 -0800, Dave Hansen пишет:

Quoted 8 lines · Alexander Tsoy
Quoted 7 lines

В Пт, 29/12/2017 в 09:32 -0800, Dave Hansen пишет:

Quoted 5 lines

Does anyone have the results of build that they can share?  (vmlinux,
vmlinuz/bzImage, System.map, .config).  That, plus a corresponding
serial log with an oops would be helpful.

Quoted 7 lines
Quoted 3 lines

Here you are:
https://www.dropbox.com/s/yesupqgig3uxf73/linux-4.15-rc5%2B.tar.xz?
dl=0

Alexander, thanks a bunch for the quick turnaround on this.  It is much
appreciated!

Dave, it turned out that the issue was caused by -fstack-check. See the thread "4.14.9 doesn't boot (regression)".