--- zzzz-none-000/linux-4.4.271/kernel/panic.c 2021-06-03 06:22:09.000000000 +0000 +++ maple-fsgw-759/linux-4.4.271/kernel/panic.c 2023-12-20 10:37:38.000000000 +0000 @@ -25,9 +25,21 @@ #include #include +#define CREATE_TRACE_POINTS +#include + +#if defined(CONFIG_AVM_FASTIRQ) +#include +#include +#endif +#include + #define PANIC_TIMER_STEP 100 #define PANIC_BLINK_SPD 18 +// Enable for debugging... +// #define AVM_PANIC_DEBUG + int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE; static unsigned long tainted_mask; static int pause_on_oops; @@ -76,7 +88,34 @@ va_list args; long i, i_next = 0; int state = 0; + struct pt_regs *pregs = NULL; + + printk_avm_console_bend(0); +#if defined(CONFIG_AVM_FASTIRQ) + if (avm_is_rte_crash_handling_enabled()) { + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + switch (avm_rte_panic(buf)) { + case AVM_RTE_DIE_CALL_DIE: + pregs = collect_pregs(); + die(buf, pregs, 0); + break; + case AVM_RTE_DIE_TRIGGER_WD: + __set_ICDISPR(get_wdt_int(), 1, 0); + while (1) + ; + break; + case AVM_RTE_DIE_CONTINUE: + break; + } + } +#endif + + /* kernel crash handling */ + + trace_kernel_panic(0); /* * Disable local interrupts. This will prevent panic_smp_self_stop * from deadlocking the first cpu that invokes the panic, since @@ -122,6 +161,18 @@ if (!crash_kexec_post_notifiers) crash_kexec(NULL); +#if defined(AVM_PANIC_DEBUG) + /*--- der notifier will auch noch was dumpen! ---*/ + atomic_notifier_call_chain(&panic_notifier_list, 0, buf); + kmsg_dump(KMSG_DUMP_PANIC); + + /* + * Note smp_send_stop is the usual smp shutdown function, which + * unfortunately means it may not be hardened to work in a panic + * situation. + */ + smp_send_stop(); +#else /* * Note smp_send_stop is the usual smp shutdown function, which * unfortunately means it may not be hardened to work in a panic @@ -136,6 +187,7 @@ atomic_notifier_call_chain(&panic_notifier_list, 0, buf); kmsg_dump(KMSG_DUMP_PANIC); +#endif/*--- #if defined(AVM_PANIC_DEBUG) ---*/ /* * If you doubt kdump always works fine in any situation, @@ -155,7 +207,7 @@ * buffer. Try to acquire the lock then release it regardless of the * result. The release will also print the buffers out. Locks debug * should be disabled to avoid reporting bad unlock balance when - * panic() is not being callled from OOPS. + * panic() is not being called from OOPS. */ debug_locks_off(); console_flush_on_panic(); @@ -179,6 +231,9 @@ mdelay(PANIC_TIMER_STEP); } } + + trace_kernel_panic_late(0); + if (panic_timeout != 0) { /* * This will not be a clean reboot, with everything @@ -241,6 +296,7 @@ { TAINT_UNSIGNED_MODULE, 'E', ' ' }, { TAINT_SOFTLOCKUP, 'L', ' ' }, { TAINT_LIVEPATCH, 'K', ' ' }, + { TAINT_ALLOC_FAIL, 'Z', ' ' }, }; /** @@ -504,6 +560,9 @@ */ __visible void __stack_chk_fail(void) { +#ifdef CONFIG_CC_STACKPROTECTOR_BUG_ON_FAIL + BUG(); +#endif panic("stack-protector: Kernel stack is corrupted in: %p\n", __builtin_return_address(0)); }