Commit 08932a198345c80d20cfa055a45464cebb9ff93b

Authored by Nick Piggin
Committed by Linus Torvalds
1 parent b08b5ad947

uml: use generic BUG

Get UML to use the generic bug support rather than arch specific one.

If I insert an artificial bug right before loading init, I get this:

 Kernel panic - not syncing: Kernel mode signal 4

 EIP: 0023:[<0819d501>] CPU: 0 Not tainted ESP: 002b:f7fd4fbc EFLAGS: 00000246
    Not tainted
    EAX: 00000000 EBX: 00007870 ECX: 00000013 EDX: 00007870
    ESI: 0000786d EDI: 00000011 EBP: f7fd4fd8 DS: 002b ES: 002b
    08273bec:  [<0806e814>] show_regs+0x104/0x106
    08273c08:  [<08058927>] panic_exit+0x2c/0x4b
    08273c18:  [<08080ee7>] notifier_call_chain+0x32/0x5b
    08273c38:  [<08080fbd>] __atomic_notifier_call_chain+0x30/0x32
    08273c54:  [<08080fee>] atomic_notifier_call_chain+0x2f/0x31
    08273c70:  [<08073b88>] panic+0x75/0x131
    08273c94:  [<080586c7>] relay_signal+0x87/0x95
    08273cb0:  [<0806b9ee>] sig_handler_common_skas+0x9e/0x120
    08273cd8:  [<08067738>] sig_handler+0x28/0x4f
    08273cec:  [<0806792e>] handle_signal+0x53/0x89
    08273d0c:  [<08069f60>] hard_handler+0x18/0x28
    08273d1c:  [<ffffe500>] transitions+0xf7d598b8/0xfffffff0

With this patch in place, this is how it looks:

 BUG: failure at init/main.c:779/init_post()!
 Kernel panic - not syncing: BUG!

 EIP: 0023:[<081a65d1>] CPU: 0 Not tainted ESP: 002b:f7f0dfbc EFLAGS: 00000246
    Not tainted
    EAX: 00000000 EBX: 000069db ECX: 00000013 EDX: 000069db
    ESI: 000069d8 EDI: 00000011 EBP: f7f0dfd8 DS: 002b ES: 002b
    098efedc:  [<0806e9a4>] show_regs+0x104/0x106
    098efef8:  [<080589c7>] panic_exit+0x2c/0x4b
    098eff08:  [<080818d7>] notifier_call_chain+0x32/0x5b
    098eff28:  [<080819ad>] __atomic_notifier_call_chain+0x30/0x32
    098eff44:  [<080819de>] atomic_notifier_call_chain+0x2f/0x31
    098eff60:  [<08073f28>] panic+0x75/0x131
    098eff84:  [<080541d5>] init_post+0xcd/0xe8
    098eff9c:  [<08048ad4>] kernel_init+0x8e/0x9a
    098effb4:  [<08066dee>] run_kernel_thread+0x41/0x53
    098effe0:  [<08058e75>] new_thread_handler+0x62/0x8b
    098efffc:  [<a55a5a5a>] 0xa55a5a5a

[ jdike - added BUG_TABLE to linker script ]

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 3 additions and 1 deletions Inline Diff

include/asm-um/bug.h
1 #ifndef __UM_BUG_H 1 #ifndef __UM_BUG_H
2 #define __UM_BUG_H 2 #define __UM_BUG_H
3 3
4 #include <asm/arch/bug.h> 4 #include <asm-generic/bug.h>
5 5
6 #endif 6 #endif
7 7
include/asm-um/common.lds.S
1 #include <asm-generic/vmlinux.lds.h> 1 #include <asm-generic/vmlinux.lds.h>
2 2
3 .fini : { *(.fini) } =0x9090 3 .fini : { *(.fini) } =0x9090
4 _etext = .; 4 _etext = .;
5 PROVIDE (etext = .); 5 PROVIDE (etext = .);
6 6
7 . = ALIGN(4096); 7 . = ALIGN(4096);
8 _sdata = .; 8 _sdata = .;
9 PROVIDE (sdata = .); 9 PROVIDE (sdata = .);
10 10
11 RODATA 11 RODATA
12 12
13 .unprotected : { *(.unprotected) } 13 .unprotected : { *(.unprotected) }
14 . = ALIGN(4096); 14 . = ALIGN(4096);
15 PROVIDE (_unprotected_end = .); 15 PROVIDE (_unprotected_end = .);
16 16
17 . = ALIGN(4096); 17 . = ALIGN(4096);
18 .note : { *(.note.*) } 18 .note : { *(.note.*) }
19 __start___ex_table = .; 19 __start___ex_table = .;
20 __ex_table : { *(__ex_table) } 20 __ex_table : { *(__ex_table) }
21 __stop___ex_table = .; 21 __stop___ex_table = .;
22 22
23 BUG_TABLE
24
23 __uml_setup_start = .; 25 __uml_setup_start = .;
24 .uml.setup.init : { *(.uml.setup.init) } 26 .uml.setup.init : { *(.uml.setup.init) }
25 __uml_setup_end = .; 27 __uml_setup_end = .;
26 28
27 __uml_help_start = .; 29 __uml_help_start = .;
28 .uml.help.init : { *(.uml.help.init) } 30 .uml.help.init : { *(.uml.help.init) }
29 __uml_help_end = .; 31 __uml_help_end = .;
30 32
31 __uml_postsetup_start = .; 33 __uml_postsetup_start = .;
32 .uml.postsetup.init : { *(.uml.postsetup.init) } 34 .uml.postsetup.init : { *(.uml.postsetup.init) }
33 __uml_postsetup_end = .; 35 __uml_postsetup_end = .;
34 36
35 __setup_start = .; 37 __setup_start = .;
36 .init.setup : { *(.init.setup) } 38 .init.setup : { *(.init.setup) }
37 __setup_end = .; 39 __setup_end = .;
38 40
39 . = ALIGN(32); 41 . = ALIGN(32);
40 __per_cpu_start = . ; 42 __per_cpu_start = . ;
41 .data.percpu : { *(.data.percpu) } 43 .data.percpu : { *(.data.percpu) }
42 __per_cpu_end = . ; 44 __per_cpu_end = . ;
43 45
44 __initcall_start = .; 46 __initcall_start = .;
45 .initcall.init : { 47 .initcall.init : {
46 INITCALLS 48 INITCALLS
47 } 49 }
48 __initcall_end = .; 50 __initcall_end = .;
49 51
50 __con_initcall_start = .; 52 __con_initcall_start = .;
51 .con_initcall.init : { *(.con_initcall.init) } 53 .con_initcall.init : { *(.con_initcall.init) }
52 __con_initcall_end = .; 54 __con_initcall_end = .;
53 55
54 __uml_initcall_start = .; 56 __uml_initcall_start = .;
55 .uml.initcall.init : { *(.uml.initcall.init) } 57 .uml.initcall.init : { *(.uml.initcall.init) }
56 __uml_initcall_end = .; 58 __uml_initcall_end = .;
57 __init_end = .; 59 __init_end = .;
58 60
59 SECURITY_INIT 61 SECURITY_INIT
60 62
61 __exitcall_begin = .; 63 __exitcall_begin = .;
62 .exitcall : { *(.exitcall.exit) } 64 .exitcall : { *(.exitcall.exit) }
63 __exitcall_end = .; 65 __exitcall_end = .;
64 66
65 __uml_exitcall_begin = .; 67 __uml_exitcall_begin = .;
66 .uml.exitcall : { *(.uml.exitcall.exit) } 68 .uml.exitcall : { *(.uml.exitcall.exit) }
67 __uml_exitcall_end = .; 69 __uml_exitcall_end = .;
68 70
69 . = ALIGN(4); 71 . = ALIGN(4);
70 __alt_instructions = .; 72 __alt_instructions = .;
71 .altinstructions : { *(.altinstructions) } 73 .altinstructions : { *(.altinstructions) }
72 __alt_instructions_end = .; 74 __alt_instructions_end = .;
73 .altinstr_replacement : { *(.altinstr_replacement) } 75 .altinstr_replacement : { *(.altinstr_replacement) }
74 /* .exit.text is discard at runtime, not link time, to deal with references 76 /* .exit.text is discard at runtime, not link time, to deal with references
75 from .altinstructions and .eh_frame */ 77 from .altinstructions and .eh_frame */
76 .exit.text : { *(.exit.text) } 78 .exit.text : { *(.exit.text) }
77 .exit.data : { *(.exit.data) } 79 .exit.data : { *(.exit.data) }
78 80
79 __preinit_array_start = .; 81 __preinit_array_start = .;
80 .preinit_array : { *(.preinit_array) } 82 .preinit_array : { *(.preinit_array) }
81 __preinit_array_end = .; 83 __preinit_array_end = .;
82 __init_array_start = .; 84 __init_array_start = .;
83 .init_array : { *(.init_array) } 85 .init_array : { *(.init_array) }
84 __init_array_end = .; 86 __init_array_end = .;
85 __fini_array_start = .; 87 __fini_array_start = .;
86 .fini_array : { *(.fini_array) } 88 .fini_array : { *(.fini_array) }
87 __fini_array_end = .; 89 __fini_array_end = .;
88 90
89 . = ALIGN(4096); 91 . = ALIGN(4096);
90 __initramfs_start = .; 92 __initramfs_start = .;
91 .init.ramfs : { *(.init.ramfs) } 93 .init.ramfs : { *(.init.ramfs) }
92 __initramfs_end = .; 94 __initramfs_end = .;
93 95
94 /* Sections to be discarded */ 96 /* Sections to be discarded */
95 /DISCARD/ : { 97 /DISCARD/ : {
96 *(.exitcall.exit) 98 *(.exitcall.exit)
97 } 99 }
98 100
99 101