博文

目前显示的是 四月, 2013的博文

Understanding Kdump (How to make crashnote)

图片
crashnote contains register status when crash happens. In kernel, this data is stored “note_buf_t __percpu *crash_notes”. include/linux/kexec.h typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4]; crashnote is also one part of /proc/vmcore. At first, crashnotes[] address, got by reading sys/devices/system/cpu/cpu0/crash_notes, is stored as one program header, which could be got from “elfcorehdr”. Making crash_notes is done by crash_save_cpu(). crash_kexec->machine_crash_shutdown->crash_save_cpu: 1206 void crash_save_cpu(struct pt_regs *regs, int cpu) 1207 { 1208         struct elf_prstatus prstatus; 1209         u32 *buf; 1210 1211         if ((cpu < 0) || (cpu >= nr_cpu_ids)) 1212                 return; 1213 1214      ...

Understanding Kdump (How to make vmcoreinfo_note)

图片
vmcoreinfo_note contains crash kernel general information, include os version, page size etc.. In kernel, vmcoreinfo_note is stored on vmcoreinfo_note[]. And, vmcoreinfo_note is one part of /proc/vmcore, which is used for debugging with capture kernel brings up. In blog " Understanding Kdump (Loading Part) ", one program header including vmcoreinfo_note's address and length was referenced, and this program header could be got from "elfcorehdr". vmcoreinfo_note[]'s address and length could be got by reading /sys/kernel/vmcoreinfo. When kexec is configured, this function will be triggered with kernel brings up. 1458 static int __init crash_save_vmcoreinfo_init(void) 1459 { 1460         VMCOREINFO_OSRELEASE(init_uts_ns.name.release); 1461         VMCOREINFO_PAGESIZE(PAGE_SIZE); 1462 1463         VMCOREINFO_SYMBOL(init_uts_ns); 1464   ...

Understanding Kdump (Executing Part)

Capture kernel brings up when panic happens. The specific location in source code and the routine will be analyzed in this blog. 69 void panic(const char *fmt, ...)  70 {  71         static DEFINE_SPINLOCK(panic_lock);  72         static char buf[1024];  73         va_list args;  74         long i, i_next = 0;  75         int state = 0;  76  77         /*  78          * It's possible to come here directly from a panic-assertion and  79          * not have preempt disabled. Some functions called from here want  80          * preempt to be ...

Unstanding Kdump (Loading Part)

图片
Table of Contents 1. Introduction 2. Routine of User Mode 3. Routine of Kernel Mode 1. Introduction kdump, based on kexec, is to debug Linux Kernel. Currently, kdump and kexec are integration in kexec-tools program .  After compiling the program, please use "build/sbin/kexec" and "-l" parameter to execute kexec function. Instead, "-p" parameter is for kdump. More difference between kexec and kdump lists below. 1. kexec's second kernel will overwrite first kernel. 2. If you want to use kdump, you should build the first kernel with "crashkernel=x@y" in cmdline. After second kernel bring up, you will found the cmdline is added, by kexec-tools, two parameters: "-mem=A" and "-elfcorehdr=B". "-mem" means the second kernel's available memory size. "-elfcorehdr" tell to kdump where could be got debug information. Now, let's analyze the kdump load routine simply. 2. Rout...