^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * arch/ia64/kernel/crash.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Architecture specific (ia64) functions for kexec based crash dumps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Created by: Khalid Aziz <khalid.aziz@hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (C) 2005 Intel Corp Zou Nan hai <nanhai.zou@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/crash_dump.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/kexec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/elfcore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/sysctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/kdebug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/mca.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int kdump_status[NR_CPUS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static atomic_t kdump_cpu_frozen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) atomic_t kdump_in_progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int kdump_freeze_monarch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static int kdump_on_init = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int kdump_on_fatal_mca = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) extern void ia64_dump_cpu_regs(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static DEFINE_PER_CPU(struct elf_prstatus, elf_prstatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) crash_save_this_cpu(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned long cfm, sof, sol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct elf_prstatus *prstatus = &per_cpu(elf_prstatus, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) elf_greg_t *dst = (elf_greg_t *)&(prstatus->pr_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) memset(prstatus, 0, sizeof(*prstatus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) prstatus->pr_pid = current->pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ia64_dump_cpu_regs(dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) cfm = dst[43];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) sol = (cfm >> 7) & 0x7f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) sof = cfm & 0x7f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dst[46] = (unsigned long)ia64_rse_skip_regs((unsigned long *)dst[46],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) sof - sol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, prstatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) sizeof(*prstatus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) final_note(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) kdump_wait_cpu_freeze(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int cpu_num = num_online_cpus() - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int timeout = 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) while(timeout-- > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (atomic_read(&kdump_cpu_frozen) == cpu_num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) udelay(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) machine_crash_shutdown(struct pt_regs *pt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* This function is only called after the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * has paniced or is otherwise in a critical state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * The minimum amount of code to allow a kexec'd kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * to run successfully needs to happen here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * In practice this means shooting down the other cpus in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * an SMP system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) kexec_disable_iosapic();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * If kdump_on_init is set and an INIT is asserted here, kdump will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * be started again via INIT monarch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ia64_set_psr_mc(); /* mask MCA/INIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (atomic_inc_return(&kdump_in_progress) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) unw_init_running(kdump_cpu_freeze, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * Now this cpu is ready for kdump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * Stop all others by IPI or INIT. They could receive INIT from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * outside and might be INIT monarch, but only thing they have to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * do is falling into kdump_cpu_freeze().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * If an INIT is asserted here:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * - All receivers might be slaves, since some of cpus could already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * be frozen and INIT might be masked on monarch. In this case,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * all slaves will be frozen soon since kdump_in_progress will let
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * them into DIE_INIT_SLAVE_LEAVE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * - One might be a monarch, but INIT rendezvous will fail since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * at least this cpu already have INIT masked so it never join
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * to the rendezvous. In this case, all slaves and monarch will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * be frozen soon with no wait since the INIT rendezvous is skipped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * by kdump_in_progress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) kdump_smp_send_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* not all cpu response to IPI, send INIT to freeze them */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (kdump_wait_cpu_freeze()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) kdump_smp_send_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* wait again, don't go ahead if possible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) kdump_wait_cpu_freeze();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) machine_kdump_on_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) crash_save_vmcoreinfo();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) kexec_disable_iosapic();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) machine_kexec(ia64_kimage);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) kdump_cpu_freeze(struct unw_frame_info *info, void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int cpuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) cpuid = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) crash_save_this_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) current->thread.ksp = (__u64)info->sw - 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ia64_set_psr_mc(); /* mask MCA/INIT and stop reentrance */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) atomic_inc(&kdump_cpu_frozen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) kdump_status[cpuid] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) for (;;)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct ia64_mca_notify_die *nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct die_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (atomic_read(&kdump_in_progress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) case DIE_INIT_MONARCH_LEAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (!kdump_freeze_monarch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) case DIE_INIT_SLAVE_LEAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) case DIE_INIT_MONARCH_ENTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) case DIE_MCA_RENDZVOUS_LEAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unw_init_running(kdump_cpu_freeze, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (!kdump_on_init && !kdump_on_fatal_mca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!ia64_kimage) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (val == DIE_INIT_MONARCH_LEAVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) ia64_mca_printk(KERN_NOTICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) "%s: kdump not configured\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (val != DIE_INIT_MONARCH_LEAVE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) val != DIE_INIT_MONARCH_PROCESS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) val != DIE_MCA_MONARCH_LEAVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) nd = (struct ia64_mca_notify_die *)args->err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) case DIE_INIT_MONARCH_PROCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* Reason code 1 means machine check rendezvous*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (kdump_on_init && (nd->sos->rv_rc != 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (atomic_inc_return(&kdump_in_progress) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) kdump_freeze_monarch = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) case DIE_INIT_MONARCH_LEAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* Reason code 1 means machine check rendezvous*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (kdump_on_init && (nd->sos->rv_rc != 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) machine_kdump_on_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) case DIE_MCA_MONARCH_LEAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* *(nd->data) indicate if MCA is recoverable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (kdump_on_fatal_mca && !(*(nd->data))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (atomic_inc_return(&kdump_in_progress) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) machine_kdump_on_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* We got fatal MCA while kdump!? No way!! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #ifdef CONFIG_SYSCTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static struct ctl_table kdump_ctl_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) .procname = "kdump_on_init",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) .data = &kdump_on_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) .maxlen = sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) .proc_handler = proc_dointvec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) .procname = "kdump_on_fatal_mca",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) .data = &kdump_on_fatal_mca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) .maxlen = sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) .proc_handler = proc_dointvec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static struct ctl_table sys_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .procname = "kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .mode = 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .child = kdump_ctl_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) machine_crash_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* be notified before default_monarch_init_process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static struct notifier_block kdump_init_notifier_nb = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .notifier_call = kdump_init_notifier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .priority = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #ifdef CONFIG_SYSCTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) register_sysctl_table(sys_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) __initcall(machine_crash_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)