본문 바로가기

카테고리 없음

[리눅스커널] kdump 분석 내용 정리 !

// webos

 
커널 컨피그 추가
 
CONFIG_KEXEC=y
CONFIG_SYSFS=y
CONFIG_DEBUG_INFO=Y
 
dump-capture kernel config options
 
CONFIG_CRASH_DUMP=y
CONFIG_PROC_VMCORE=y
CONFIG_AUTO_ZRELADDR=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=/home/austindh.kim/busybox/_install
 
bootargs
: bootloader command mode
 
set bootopts crashkernel=128M@0x20000000
 
 
kexec-tools (static) 
: version - 2.0.11-rc1
: kexec
: kdump
: vmcore-dmesg
 
commands
: KEXEC
 
kexec -d -l /boot/Image --append="vmalloc=1288M console=ttyAMA0,115200n81 rootwait 1 maxcpus=1 reset_devices rdinit=/sbin/init"
kexec -e  
: KDUMP
 
kexec -d -p /boot/Image4 --append="root=/dev/ram0 rw rdinit=/sbin/init vmalloc=1288M console=ttyAMA0,115200n81 1 irqpoll maxcpus=1 reset_devices"
echo c > /proc/sysrq-trigger
 
>>
 
static void __init reserve_crashkernel(void)
{
unsigned long long crash_size, crash_base;
unsigned long long total_mem;
int ret;
 
total_mem = get_total_mem();
ret = parse_crashkernel(boot_command_line, total_mem,
&crash_size, &crash_base);
if (ret)
return;
 
int __init parse_crashkernel(char *cmdline,
     unsigned long long system_ram,
     unsigned long long *crash_size,
     unsigned long long *crash_base)
{
return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base,
"crashkernel=", NULL);
}
 
static int __init __parse_crashkernel(char *cmdline,
     unsigned long long system_ram,
     unsigned long long *crash_size,
     unsigned long long *crash_base,
     const char *name,
     const char *suffix)
{
char *first_colon, *first_space;
char *ck_cmdline;
 
BUG_ON(!crash_size || !crash_base);
*crash_size = 0;
*crash_base = 0;
 
ck_cmdline = get_last_crashkernel(cmdline, name, suffix);
 
if (!ck_cmdline)
return -EINVAL;
 
ck_cmdline += strlen(name);
 
if (suffix)
return parse_crashkernel_suffix(ck_cmdline, crash_size,
suffix);
/*
 * if the commandline contains a ':', then that's the extended
 * syntax -- if not, it must be the classic syntax
 */
first_colon = strchr(ck_cmdline, ':');
first_space = strchr(ck_cmdline, ' ');
if (first_colon && (!first_space || first_colon < first_space))
return parse_crashkernel_mem(ck_cmdline, system_ram,
crash_size, crash_base);
 
return parse_crashkernel_simple(ck_cmdline, crash_size, crash_base);
}
 
static int __init parse_crashkernel_mem(char *cmdline,
unsigned long long system_ram,
unsigned long long *crash_size,
unsigned long long *crash_base)
{
char *cur = cmdline, *tmp;
 
/* for each entry of the comma-separated list */
do {
unsigned long long start, end = ULLONG_MAX, size;
 
/* get the start of the range */
start = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (*cur != '-') {
pr_warn("crashkernel: '-' expected\n");
return -EINVAL;
}
cur++;
 
/* if no ':' is here, than we read the end */
if (*cur != ':') {
end = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (end <= start) {
pr_warn("crashkernel: end <= start\n");
return -EINVAL;
}
}
 
if (*cur != ':') {
pr_warn("crashkernel: ':' expected\n");
return -EINVAL;
}
cur++;
 
size = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (size >= system_ram) {
pr_warn("crashkernel: invalid size\n");
return -EINVAL;
}
 
/* match ? */
if (system_ram >= start && system_ram < end) {
*crash_size = size;
break;
}
} while (*cur++ == ',');
 
if (*crash_size > 0) {
while (*cur && *cur != ' ' && *cur != '@')
cur++;
if (*cur == '@') {
cur++;
*crash_base = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("Memory value expected after '@'\n");
return -EINVAL;
}
}
} else
pr_info("crashkernel size resulted in zero bytes\n");
 
return 0;
}
 
>>