blob: 0a1293be0b1608a4f364d5f1f5bef2557fd9f85f [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/kernel/panic.c
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 */
7
8/*
9 * This function is used through-out the kernel (including mm and fs)
10 * to indicate a major problem.
11 */
12#include <linux/debug_locks.h>
13#include <linux/sched/debug.h>
14#include <linux/interrupt.h>
15#include <linux/kgdb.h>
16#include <linux/kmsg_dump.h>
17#include <linux/kallsyms.h>
18#include <linux/notifier.h>
19#include <linux/vt_kern.h>
20#include <linux/module.h>
21#include <linux/random.h>
22#include <linux/ftrace.h>
23#include <linux/reboot.h>
24#include <linux/delay.h>
25#include <linux/kexec.h>
26#include <linux/sched.h>
27#include <linux/sysrq.h>
28#include <linux/init.h>
29#include <linux/nmi.h>
30#include <linux/console.h>
31#include <linux/bug.h>
32#include <linux/ratelimit.h>
33#include <linux/debugfs.h>
34#include <linux/sysfs.h>
35#include <asm/sections.h>
36
37#ifdef CONFIG_PXA_RAMDUMP
38#include <linux/ramdump.h>
39#endif
40
41#define PANIC_TIMER_STEP 100
42#define PANIC_BLINK_SPD 18
43
44int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE;
45static unsigned long tainted_mask =
46 IS_ENABLED(CONFIG_GCC_PLUGIN_RANDSTRUCT) ? (1 << TAINT_RANDSTRUCT) : 0;
47static int pause_on_oops;
48static int pause_on_oops_flag;
49static DEFINE_SPINLOCK(pause_on_oops_lock);
50bool crash_kexec_post_notifiers;
51int panic_on_warn __read_mostly;
52static unsigned int warn_limit __read_mostly;
53
54int panic_timeout = CONFIG_PANIC_TIMEOUT;
55EXPORT_SYMBOL_GPL(panic_timeout);
56
57#define PANIC_PRINT_TASK_INFO 0x00000001
58#define PANIC_PRINT_MEM_INFO 0x00000002
59#define PANIC_PRINT_TIMER_INFO 0x00000004
60#define PANIC_PRINT_LOCK_INFO 0x00000008
61#define PANIC_PRINT_FTRACE_INFO 0x00000010
62#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020
63unsigned long panic_print;
64
65ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
66
67EXPORT_SYMBOL(panic_notifier_list);
68
69#ifdef CONFIG_SYSCTL
70static struct ctl_table kern_panic_table[] = {
71 {
72 .procname = "warn_limit",
73 .data = &warn_limit,
74 .maxlen = sizeof(warn_limit),
75 .mode = 0644,
76 .proc_handler = proc_douintvec,
77 },
78 { }
79};
80
81static __init int kernel_panic_sysctls_init(void)
82{
83 register_sysctl_init("kernel", kern_panic_table);
84 return 0;
85}
86late_initcall(kernel_panic_sysctls_init);
87#endif
88
89static atomic_t warn_count = ATOMIC_INIT(0);
90
91#ifdef CONFIG_SYSFS
92static ssize_t warn_count_show(struct kobject *kobj, struct kobj_attribute *attr,
93 char *page)
94{
95 return sysfs_emit(page, "%d\n", atomic_read(&warn_count));
96}
97
98static struct kobj_attribute warn_count_attr = __ATTR_RO(warn_count);
99
100static __init int kernel_panic_sysfs_init(void)
101{
102 sysfs_add_file_to_group(kernel_kobj, &warn_count_attr.attr, NULL);
103 return 0;
104}
105late_initcall(kernel_panic_sysfs_init);
106#endif
107
108static long no_blink(int state)
109{
110 return 0;
111}
112
113/* Returns how long it waited in ms */
114long (*panic_blink)(int state);
115EXPORT_SYMBOL(panic_blink);
116
117/*
118 * Stop ourself in panic -- architecture code may override this
119 */
120void __weak panic_smp_self_stop(void)
121{
122 while (1)
123 cpu_relax();
124}
125
126/*
127 * Stop ourselves in NMI context if another CPU has already panicked. Arch code
128 * may override this to prepare for crash dumping, e.g. save regs info.
129 */
130void __weak nmi_panic_self_stop(struct pt_regs *regs)
131{
132 panic_smp_self_stop();
133}
134
135/*
136 * Stop other CPUs in panic. Architecture dependent code may override this
137 * with more suitable version. For example, if the architecture supports
138 * crash dump, it should save registers of each stopped CPU and disable
139 * per-CPU features such as virtualization extensions.
140 */
141void __weak crash_smp_send_stop(void)
142{
143 static int cpus_stopped;
144
145 /*
146 * This function can be called twice in panic path, but obviously
147 * we execute this only once.
148 */
149 if (cpus_stopped)
150 return;
151
152 /*
153 * Note smp_send_stop is the usual smp shutdown function, which
154 * unfortunately means it may not be hardened to work in a panic
155 * situation.
156 */
157 smp_send_stop();
158 cpus_stopped = 1;
159}
160
161atomic_t panic_cpu = ATOMIC_INIT(PANIC_CPU_INVALID);
162
163/*
164 * A variant of panic() called from NMI context. We return if we've already
165 * panicked on this CPU. If another CPU already panicked, loop in
166 * nmi_panic_self_stop() which can provide architecture dependent code such
167 * as saving register state for crash dump.
168 */
169void nmi_panic(struct pt_regs *regs, const char *msg)
170{
171 int old_cpu, cpu;
172
173 cpu = raw_smp_processor_id();
174 old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);
175
176 if (old_cpu == PANIC_CPU_INVALID)
177 panic("%s", msg);
178 else if (old_cpu != cpu)
179 nmi_panic_self_stop(regs);
180}
181EXPORT_SYMBOL(nmi_panic);
182
183static void panic_print_sys_info(void)
184{
185 if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
186 console_flush_on_panic(CONSOLE_REPLAY_ALL);
187
188 if (panic_print & PANIC_PRINT_TASK_INFO)
189 show_state();
190
191 if (panic_print & PANIC_PRINT_MEM_INFO)
192 show_mem(0, NULL);
193
194 if (panic_print & PANIC_PRINT_TIMER_INFO)
195 sysrq_timer_list_show();
196
197 if (panic_print & PANIC_PRINT_LOCK_INFO)
198 debug_show_all_locks();
199
200 if (panic_print & PANIC_PRINT_FTRACE_INFO)
201 ftrace_dump(DUMP_ALL);
202}
203
204void check_panic_on_warn(const char *origin)
205{
206 unsigned int limit;
207
208 if (panic_on_warn)
209 panic("%s: panic_on_warn set ...\n", origin);
210
211 limit = READ_ONCE(warn_limit);
212 if (atomic_inc_return(&warn_count) >= limit && limit)
213 panic("%s: system warned too often (kernel.warn_limit is %d)",
214 origin, limit);
215}
216
217/**
218 * panic - halt the system
219 * @fmt: The text string to print
220 *
221 * Display a message, then perform cleanups.
222 *
223 * This function never returns.
224 */
225void panic(const char *fmt, ...)
226{
227 static char buf[1024];
228 va_list args;
229 long i, i_next = 0, len;
230 int state = 0;
231 int old_cpu, this_cpu;
232 bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
233
234 if (panic_on_warn) {
235 /*
236 * This thread may hit another WARN() in the panic path.
237 * Resetting this prevents additional WARN() from panicking the
238 * system on this thread. Other threads are blocked by the
239 * panic_mutex in panic().
240 */
241 panic_on_warn = 0;
242 }
243
244 /*
245 * Disable local interrupts. This will prevent panic_smp_self_stop
246 * from deadlocking the first cpu that invokes the panic, since
247 * there is nothing to prevent an interrupt handler (that runs
248 * after setting panic_cpu) from invoking panic() again.
249 */
250 local_irq_disable();
251 preempt_disable_notrace();
252
253 /*
254 * It's possible to come here directly from a panic-assertion and
255 * not have preempt disabled. Some functions called from here want
256 * preempt to be disabled. No point enabling it later though...
257 *
258 * Only one CPU is allowed to execute the panic code from here. For
259 * multiple parallel invocations of panic, all other CPUs either
260 * stop themself or will wait until they are stopped by the 1st CPU
261 * with smp_send_stop().
262 *
263 * `old_cpu == PANIC_CPU_INVALID' means this is the 1st CPU which
264 * comes here, so go ahead.
265 * `old_cpu == this_cpu' means we came from nmi_panic() which sets
266 * panic_cpu to this CPU. In this case, this is also the 1st CPU.
267 */
268 this_cpu = raw_smp_processor_id();
269 old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
270
271 if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu)
272 panic_smp_self_stop();
273
274 console_verbose();
275 bust_spinlocks(1);
276 va_start(args, fmt);
277 len = vscnprintf(buf, sizeof(buf), fmt, args);
278 va_end(args);
279
280 if (len && buf[len - 1] == '\n')
281 buf[len - 1] = '\0';
282
283 pr_emerg("Kernel panic - not syncing: %s\n", buf);
284#ifdef CONFIG_DEBUG_BUGVERBOSE
285 /*
286 * Avoid nested stack-dumping if a panic occurs during oops processing
287 */
288 if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
289 dump_stack();
290#endif
291
292#ifdef CONFIG_PXA_RAMDUMP
293 /*
294 * Panic text is not available otherwise, at least
295 * not via kexec, so save it now.
296 */
297 ramdump_save_panic_text(buf);
298#endif
299
300 /*
301 * If kgdb is enabled, give it a chance to run before we stop all
302 * the other CPUs or else we won't be able to debug processes left
303 * running on them.
304 */
305 kgdb_panic(buf);
306
307 /*
308 * If we have crashed and we have a crash kernel loaded let it handle
309 * everything else.
310 * If we want to run this after calling panic_notifiers, pass
311 * the "crash_kexec_post_notifiers" option to the kernel.
312 *
313 * Bypass the panic_cpu check and call __crash_kexec directly.
314 */
315 if (!_crash_kexec_post_notifiers) {
316 printk_safe_flush_on_panic();
317 __crash_kexec(NULL);
318
319 /*
320 * Note smp_send_stop is the usual smp shutdown function, which
321 * unfortunately means it may not be hardened to work in a
322 * panic situation.
323 */
324 smp_send_stop();
325 } else {
326 /*
327 * If we want to do crash dump after notifier calls and
328 * kmsg_dump, we will need architecture dependent extra
329 * works in addition to stopping other CPUs.
330 */
331 crash_smp_send_stop();
332 }
333
334 /*
335 * Run any panic handlers, including those that might need to
336 * add information to the kmsg dump output.
337 */
338 atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
339
340 /* Call flush even twice. It tries harder with a single online CPU */
341 printk_safe_flush_on_panic();
342 kmsg_dump(KMSG_DUMP_PANIC);
343
344 /*
345 * If you doubt kdump always works fine in any situation,
346 * "crash_kexec_post_notifiers" offers you a chance to run
347 * panic_notifiers and dumping kmsg before kdump.
348 * Note: since some panic_notifiers can make crashed kernel
349 * more unstable, it can increase risks of the kdump failure too.
350 *
351 * Bypass the panic_cpu check and call __crash_kexec directly.
352 */
353 if (_crash_kexec_post_notifiers)
354 __crash_kexec(NULL);
355
356#ifdef CONFIG_VT
357 unblank_screen();
358#endif
359 console_unblank();
360
361 /*
362 * We may have ended up stopping the CPU holding the lock (in
363 * smp_send_stop()) while still having some valuable data in the console
364 * buffer. Try to acquire the lock then release it regardless of the
365 * result. The release will also print the buffers out. Locks debug
366 * should be disabled to avoid reporting bad unlock balance when
367 * panic() is not being callled from OOPS.
368 */
369 debug_locks_off();
370 console_flush_on_panic(CONSOLE_FLUSH_PENDING);
371
372 panic_print_sys_info();
373
374 if (!panic_blink)
375 panic_blink = no_blink;
376
377 if (panic_timeout > 0) {
378 /*
379 * Delay timeout seconds before rebooting the machine.
380 * We can't use the "normal" timers since we just panicked.
381 */
382 pr_emerg("Rebooting in %d seconds..\n", panic_timeout);
383
384 for (i = 0; i < panic_timeout * 1000; i += PANIC_TIMER_STEP) {
385 touch_nmi_watchdog();
386 if (i >= i_next) {
387 i += panic_blink(state ^= 1);
388 i_next = i + 3600 / PANIC_BLINK_SPD;
389 }
390 mdelay(PANIC_TIMER_STEP);
391 }
392 }
393 if (panic_timeout != 0) {
394 /*
395 * This will not be a clean reboot, with everything
396 * shutting down. But if there is a chance of
397 * rebooting the system it will be rebooted.
398 */
399 if (panic_reboot_mode != REBOOT_UNDEFINED)
400 reboot_mode = panic_reboot_mode;
401 emergency_restart();
402 }
403#ifdef __sparc__
404 {
405 extern int stop_a_enabled;
406 /* Make sure the user can actually press Stop-A (L1-A) */
407 stop_a_enabled = 1;
408 pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
409 "twice on console to return to the boot prom\n");
410 }
411#endif
412#if defined(CONFIG_S390)
413 disabled_wait();
414#endif
415 pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
416
417 /* Do not scroll important messages printed above */
418 suppress_printk = 1;
419
420 /*
421 * The final messages may not have been printed if in a context that
422 * defers printing (such as NMI) and irq_work is not available.
423 * Explicitly flush the kernel log buffer one last time.
424 */
425 console_flush_on_panic(CONSOLE_FLUSH_PENDING);
426
427 local_irq_enable();
428 for (i = 0; ; i += PANIC_TIMER_STEP) {
429 touch_softlockup_watchdog();
430 if (i >= i_next) {
431 i += panic_blink(state ^= 1);
432 i_next = i + 3600 / PANIC_BLINK_SPD;
433 }
434 mdelay(PANIC_TIMER_STEP);
435 }
436}
437
438EXPORT_SYMBOL(panic);
439
440/*
441 * TAINT_FORCED_RMMOD could be a per-module flag but the module
442 * is being removed anyway.
443 */
444const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
445 [ TAINT_PROPRIETARY_MODULE ] = { 'P', 'G', true },
446 [ TAINT_FORCED_MODULE ] = { 'F', ' ', true },
447 [ TAINT_CPU_OUT_OF_SPEC ] = { 'S', ' ', false },
448 [ TAINT_FORCED_RMMOD ] = { 'R', ' ', false },
449 [ TAINT_MACHINE_CHECK ] = { 'M', ' ', false },
450 [ TAINT_BAD_PAGE ] = { 'B', ' ', false },
451 [ TAINT_USER ] = { 'U', ' ', false },
452 [ TAINT_DIE ] = { 'D', ' ', false },
453 [ TAINT_OVERRIDDEN_ACPI_TABLE ] = { 'A', ' ', false },
454 [ TAINT_WARN ] = { 'W', ' ', false },
455 [ TAINT_CRAP ] = { 'C', ' ', true },
456 [ TAINT_FIRMWARE_WORKAROUND ] = { 'I', ' ', false },
457 [ TAINT_OOT_MODULE ] = { 'O', ' ', true },
458 [ TAINT_UNSIGNED_MODULE ] = { 'E', ' ', true },
459 [ TAINT_SOFTLOCKUP ] = { 'L', ' ', false },
460 [ TAINT_LIVEPATCH ] = { 'K', ' ', true },
461 [ TAINT_AUX ] = { 'X', ' ', true },
462 [ TAINT_RANDSTRUCT ] = { 'T', ' ', true },
463};
464
465/**
466 * print_tainted - return a string to represent the kernel taint state.
467 *
468 * For individual taint flag meanings, see Documentation/admin-guide/sysctl/kernel.rst
469 *
470 * The string is overwritten by the next call to print_tainted(),
471 * but is always NULL terminated.
472 */
473const char *print_tainted(void)
474{
475 static char buf[TAINT_FLAGS_COUNT + sizeof("Tainted: ")];
476
477 BUILD_BUG_ON(ARRAY_SIZE(taint_flags) != TAINT_FLAGS_COUNT);
478
479 if (tainted_mask) {
480 char *s;
481 int i;
482
483 s = buf + sprintf(buf, "Tainted: ");
484 for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
485 const struct taint_flag *t = &taint_flags[i];
486 *s++ = test_bit(i, &tainted_mask) ?
487 t->c_true : t->c_false;
488 }
489 *s = 0;
490 } else
491 snprintf(buf, sizeof(buf), "Not tainted");
492
493 return buf;
494}
495
496int test_taint(unsigned flag)
497{
498 return test_bit(flag, &tainted_mask);
499}
500EXPORT_SYMBOL(test_taint);
501
502unsigned long get_taint(void)
503{
504 return tainted_mask;
505}
506
507/**
508 * add_taint: add a taint flag if not already set.
509 * @flag: one of the TAINT_* constants.
510 * @lockdep_ok: whether lock debugging is still OK.
511 *
512 * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for
513 * some notewortht-but-not-corrupting cases, it can be set to true.
514 */
515void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
516{
517 if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off())
518 pr_warn("Disabling lock debugging due to kernel taint\n");
519
520 set_bit(flag, &tainted_mask);
521}
522EXPORT_SYMBOL(add_taint);
523
524static void spin_msec(int msecs)
525{
526 int i;
527
528 for (i = 0; i < msecs; i++) {
529 touch_nmi_watchdog();
530 mdelay(1);
531 }
532}
533
534/*
535 * It just happens that oops_enter() and oops_exit() are identically
536 * implemented...
537 */
538static void do_oops_enter_exit(void)
539{
540 unsigned long flags;
541 static int spin_counter;
542
543 if (!pause_on_oops)
544 return;
545
546 spin_lock_irqsave(&pause_on_oops_lock, flags);
547 if (pause_on_oops_flag == 0) {
548 /* This CPU may now print the oops message */
549 pause_on_oops_flag = 1;
550 } else {
551 /* We need to stall this CPU */
552 if (!spin_counter) {
553 /* This CPU gets to do the counting */
554 spin_counter = pause_on_oops;
555 do {
556 spin_unlock(&pause_on_oops_lock);
557 spin_msec(MSEC_PER_SEC);
558 spin_lock(&pause_on_oops_lock);
559 } while (--spin_counter);
560 pause_on_oops_flag = 0;
561 } else {
562 /* This CPU waits for a different one */
563 while (spin_counter) {
564 spin_unlock(&pause_on_oops_lock);
565 spin_msec(1);
566 spin_lock(&pause_on_oops_lock);
567 }
568 }
569 }
570 spin_unlock_irqrestore(&pause_on_oops_lock, flags);
571}
572
573/*
574 * Return true if the calling CPU is allowed to print oops-related info.
575 * This is a bit racy..
576 */
577int oops_may_print(void)
578{
579 return pause_on_oops_flag == 0;
580}
581
582/*
583 * Called when the architecture enters its oops handler, before it prints
584 * anything. If this is the first CPU to oops, and it's oopsing the first
585 * time then let it proceed.
586 *
587 * This is all enabled by the pause_on_oops kernel boot option. We do all
588 * this to ensure that oopses don't scroll off the screen. It has the
589 * side-effect of preventing later-oopsing CPUs from mucking up the display,
590 * too.
591 *
592 * It turns out that the CPU which is allowed to print ends up pausing for
593 * the right duration, whereas all the other CPUs pause for twice as long:
594 * once in oops_enter(), once in oops_exit().
595 */
596void oops_enter(void)
597{
598 tracing_off();
599 /* can't trust the integrity of the kernel anymore: */
600 debug_locks_off();
601 do_oops_enter_exit();
602}
603
604/*
605 * 64-bit random ID for oopses:
606 */
607static u64 oops_id;
608
609static int init_oops_id(void)
610{
611 if (!oops_id)
612 get_random_bytes(&oops_id, sizeof(oops_id));
613 else
614 oops_id++;
615
616 return 0;
617}
618late_initcall(init_oops_id);
619
620void print_oops_end_marker(void)
621{
622 init_oops_id();
623 pr_warn("---[ end trace %016llx ]---\n", (unsigned long long)oops_id);
624}
625
626/*
627 * Called when the architecture exits its oops handler, after printing
628 * everything.
629 */
630void oops_exit(void)
631{
632 do_oops_enter_exit();
633 print_oops_end_marker();
634 kmsg_dump(KMSG_DUMP_OOPS);
635}
636
637struct warn_args {
638 const char *fmt;
639 va_list args;
640};
641
642void __warn(const char *file, int line, void *caller, unsigned taint,
643 struct pt_regs *regs, struct warn_args *args)
644{
645 disable_trace_on_warning();
646
647 if (file)
648 pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n",
649 raw_smp_processor_id(), current->pid, file, line,
650 caller);
651 else
652 pr_warn("WARNING: CPU: %d PID: %d at %pS\n",
653 raw_smp_processor_id(), current->pid, caller);
654
655 if (args)
656 vprintk(args->fmt, args->args);
657
658 check_panic_on_warn("kernel");
659
660 print_modules();
661
662 if (regs)
663 show_regs(regs);
664 else
665 dump_stack();
666
667 print_irqtrace_events(current);
668
669 print_oops_end_marker();
670
671 /* Just a warning, don't kill lockdep. */
672 add_taint(taint, LOCKDEP_STILL_OK);
673}
674
675#ifndef __WARN_FLAGS
676void warn_slowpath_fmt(const char *file, int line, unsigned taint,
677 const char *fmt, ...)
678{
679 struct warn_args args;
680
681 pr_warn(CUT_HERE);
682
683 if (!fmt) {
684 __warn(file, line, __builtin_return_address(0), taint,
685 NULL, NULL);
686 return;
687 }
688
689 args.fmt = fmt;
690 va_start(args.args, fmt);
691 __warn(file, line, __builtin_return_address(0), taint, NULL, &args);
692 va_end(args.args);
693}
694EXPORT_SYMBOL(warn_slowpath_fmt);
695#else
696void __warn_printk(const char *fmt, ...)
697{
698 va_list args;
699
700 pr_warn(CUT_HERE);
701
702 va_start(args, fmt);
703 vprintk(fmt, args);
704 va_end(args);
705}
706EXPORT_SYMBOL(__warn_printk);
707#endif
708
709#ifdef CONFIG_BUG
710
711/* Support resetting WARN*_ONCE state */
712
713static int clear_warn_once_set(void *data, u64 val)
714{
715 generic_bug_clear_once();
716 memset(__start_once, 0, __end_once - __start_once);
717 return 0;
718}
719
720DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set,
721 "%lld\n");
722
723static __init int register_warn_debugfs(void)
724{
725 /* Don't care about failure */
726 debugfs_create_file_unsafe("clear_warn_once", 0200, NULL, NULL,
727 &clear_warn_once_fops);
728 return 0;
729}
730
731device_initcall(register_warn_debugfs);
732#endif
733
734#ifdef CONFIG_STACKPROTECTOR
735
736/*
737 * Called when gcc's -fstack-protector feature is used, and
738 * gcc detects corruption of the on-stack canary value
739 */
740__visible void __stack_chk_fail(void)
741{
742 panic("stack-protector: Kernel stack is corrupted in: %pB",
743 __builtin_return_address(0));
744}
745EXPORT_SYMBOL(__stack_chk_fail);
746
747#endif
748
749#ifdef CONFIG_ARCH_HAS_REFCOUNT
750void refcount_error_report(struct pt_regs *regs, const char *err)
751{
752 WARN_RATELIMIT(1, "refcount_t %s at %pB in %s[%d], uid/euid: %u/%u\n",
753 err, (void *)instruction_pointer(regs),
754 current->comm, task_pid_nr(current),
755 from_kuid_munged(&init_user_ns, current_uid()),
756 from_kuid_munged(&init_user_ns, current_euid()));
757}
758#endif
759
760core_param(panic, panic_timeout, int, 0644);
761core_param(panic_print, panic_print, ulong, 0644);
762core_param(pause_on_oops, pause_on_oops, int, 0644);
763core_param(panic_on_warn, panic_on_warn, int, 0644);
764core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
765
766static int __init oops_setup(char *s)
767{
768 if (!s)
769 return -EINVAL;
770 if (!strcmp(s, "panic"))
771 panic_on_oops = 1;
772 return 0;
773}
774early_param("oops", oops_setup);