Weblog

All | General | Solaris
« softcall processing... | Main | UFS file system... »
20050712 Tuesday July 12, 2005

system crash file layout kernel memory corruption detected !! and root caused

Sometime back while working on a pet project (may be next blog), I studied the layout of
a system crash file and this blog is about that. This is applicable for crash files from
sun4u platform (but, things should not be very much different in x86/64 land, but I don't
bet on it).

In this document i am explaing the layout of the system crash file on the
swap disk and how it is present in the vmcore.* subsequent to running
a 'savecore'.
Use: 1. Getting to know the layout
2. How we can extract unix.* from vcore.* and thus avoid copying over
unix.* while downloading cores (Not a major gain, but for fun...)
3. How we can avoid kvm_* calls and do the vitual to physical translation
on our own and then read the appropriate location in vmcore.* (again
for fun...)

No sooner the system comes back after a crash, crash dump is avialable
on primary swap device and it starts at:

offset = (size of the device - 64k);
'offset' is truncated to get aligned on a 64k boundary

and grows upwards. At the offset, calculated as above, there will be a
dumphdr_t structure which describes the dump.

No need to know the name of the primary swap device, the following lines
do the job:

dumpfd=open("/dev/dump", O_RDONLY, 0444)
ioctl(dumpfd, DIOCGETDEV, dumpfile) <- this gets dump device into
"dumpfile"
dumpfd=open(dumpfile, O_RDONLY, 0444)

Seek to 64k:
llseek(dumpfd, -DUMP_OFFSET, SEEK_END) & -DUMP_OFFSET;

And read the dumphdr_t:

pread64(dumpfd, &dumphdr, sizeof(dumphdr_t), endoff);

dumphdr contains info to describe the various sections of crash dump,
their start points, their sizes and some more info like crash time, utsname...

sections:

1. dump_start of dumphdr denotes the beginning of crash and there will be a
blank page (size: 8192) to start with (Even this contains one copy of
dumphdr_t, so its not exactly blank :-))

2. Then starts the symbol table in compressed form (its no longer compressed !!)
which will subsequently become 'unix.*' upon running savecore. Its exact
size is available in dump_ksyms_size/dump_ksyms_csize of dumphdr.

3. This is followed by the page translation map. Its an array of structures
of type mem_vtop:

struct mem_vtop {
struct as *m_as;
void *m_va;
pfn_t m_pfn;
}

How does the system populate this? It walks through all the segements of
an address space (assuming we are dumping only kernel pages, then it will
just be 'kas') and for each pages of VA mapped, it will find out underlying
page frame number and updates the above structure. This is the key.
In our debuggers, whenever we try to access a VA, debugger just looks at
this map, finds out the PFN, seek to the appropriate page/offset and read
whatever is present there (So we should be able to write our own read
routines instead of using kvm_read() for fun).

How big is it? its determined by the 'dump_nvtop' member of dumphdr.
(size is: dump_nvtop*sizeof(mem_vtop_t))

4. This is followed by dumping all the Page Frame Numbers (PFN) of all the
memory pages in use, in an array form.

How big is this section? Its determined by the 'dump_npages' member of
dumphdr_t.
(size is: dump_npages*sizeof(pfn_t))

5. This is followed by the contents of all the PFNs noted above, in compressed
form. Each compressed buffer is preceded by the compressed buffer size
(which is a uint32_t).

Big picture:


| |
------------------------- ^ start
| | |
| | pagesize (8192)
| | |
ksyms start ------------------------- -
| | ^
| | |
| | dump_ksyms_csize/dump_ksyms_size
| | |
| | v
page xlation map------------------------- -
start | | |
| | |
| |
| | dump_nvtop * sizeof(mem_vtop_t)
| |
| | |
| | |
| | v
pfn start ------------------------- -
| | ^
| | |
| | |
| |
| | dump_npages * sizeof(pfn_t)
| |
| | |
| | |
Acutal dump strt------------------------- v
| |
| |
| |
| |
| |
------------------------- <--- this offset is 64k aligned
| dumphdr stored here |
| |
_________________________
| | ^
| | |
| | 64k
| | |
------------------------- v End of swap device



Layout of vmcore.*:
-------------------

1. First page will be a blank page.

2. Kernel symbol table is read from swap device into the vmcore.*, uncompress
it (nothing happens here, as it was not compressed in the first hand) and
then write to it unix.*;
Which means we don't need to pull over unix.* while copying over the crash
dumps, we can extract it from vmcore.* (some more fun....). All we need
to do is: open vmcore.*; seek by 8192; and then read dumphdr.dump_ksyms_size
bytes into unix.*

(Now the question is: as we don't have access to swap device, how do we
find out the value of dumphdr.dump_ksyms_size?

The thing is point-1 is wrong - First page is not exactly blank - but it
contains coredhr - so read dumphdr_t bytes from offset:0 and then get
corehdr.dump_ksyms_size bytes, populate unix.* with that many bytes from
vmcore.* - Now we have a unix.* !!

3. Pfn table is dumped next. As the above diagram indicates, we need to
dump (dump_npages * sizeof(pfn_t)) bytes from appropriate offset i.e
dumphdr.dump_pfn

4. Now we create the page transalation info by reading the contents from
swap device at offset: 'page xlation map start' - in swap device data
type is mem_vtop_t and in core file its: dump_map_t

struct dump_map {
offset_t dm_first;
offset_t dm_next;
offset_t dm_data;
struct as *dm_as;
uintptr_t dm_va;
}

There will be 'dump_nvtop' mem_vtop_t structures in swap device.
'dump_nvtop' can be higher than or equal or 'dump_npages' - as a page
could have been mapped at multiple VAes.

Now we read each mem_vtop_t, look at its PFN, then find out its location
in pfn_map (created in step 3) and update the 'dm_data' variable as
follows:

dm_data = (dump_data + (location * PAGESIZE))

For 'dump_data_start', please refer to the below figure.

5. Then the actual pages are dumped. These pages are stored in compressed
form. How they are stored in the dump device is: compressed size followed
by the compressed contents.
To extract them, something like this is done:

pread(dumpfd, &csize, sizeof (uint32_t), dumpoff);
^^^^^ <- this gets us the compressed size
dumpoff += sizeof (uint32_t); <- go past the data type

pread(dumpfd, inbuf, csize, dumpoff) <- read in the compressed buf;

decompress(inbuf, outbuf, csize, pagesize); <- uncompress it
^^^^^^^^ <- expected uncompressed size

write(corefd, outbuf, pagesize,corehdr.dump_data+x*pagesize) <- write
the uncompressed buf to the vmcore.* file

Big picture (vmcore.X):


offset: 0 --------------------------
| corehdr_t |^
| ||
| |8192
| ||
corehdr. | |v
dump_kyms --------------------------
| |^
| Kernel ||
| Symbols (A.K.A) ||
| unix.* |unix.* size aligned to page size
| ||
| ||
| |v
dump_pfn --------------------------
| |^
| Number of elements: ||
| (dump_npages) |pfn_table (PFNs of all dumped pages)
| || (aligned to page size)
| |v
dump_map --------------------------
| |^
| Array of dump_map_t ||
| structures ||
| (dump_nvtop) |Xlation map
| ||
| ||
| |v
dump_start --------------------------
| |^
| ||
| ||
| |Contents of Physical pages
| |are here
| ||
| ||
| |v
--------------------------

So given this picture how do we do the xlation given a VA:

1. First search for the VA in the tranlation map starting at: corehdr.dump_map
2. Get the 'dm_data' of the corresponding dump_map_t
3. Seek to that offset, and just read.


( Jul 12 2005, 11:50:47 PM PDT ) Permalink Comments [2]

Trackback URL: http://blogs.sun.com/sprakki/entry/system_crash_file_layout
Comments:

Thanks a lot for providing this information. I love to see Sun engineers write *this* kind of weblog.

Posted by johnhl on July 13, 2005 at 11:59 AM PDT #

对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 七夕情人站 360家具家居网 剧情网 育崽妈咪网 泡泡写真图库 狐谷娱乐 狐谷小游戏 上网就要去 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 黄色小说 裸体美女 韩国三级片 免费黄色电影下载 黄色小电影下载 激情免费电影 激情电影免费 免费成人电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 偷拍桌球室里的丰满少妇 乳沟深深 意外偷拍到的镜头 酒吧美女脱衣舞秀丁字裤 抓拍沙滩上没穿胸罩的MM 丝袜诱惑 波霸美少女视频 脱衣舞-夜总会艳舞07 色情男人看A片玩激情 宿舍里玩弄巨乳女学生 奴隶情人 女秘书办公室妩媚自拍 视频主持MM自拍性感热舞 诱人的脱衣舞表演 激情男女QQ视频热舞 美女与野兽 韩国三级明星写真 视频聊天室的风骚女室主 法国透明内衣秀 欧美性感AV女郎火辣自拍 一个聊天室MM的性感热舞 超性感AV女优室内激情 抓拍漂亮MM蹦床超级走光 美女记者前故意撕衫走光 全裸喂奶的真实镜头 性感少妇跳风骚脱衣舞 脱衣舞-夜总会艳舞06 网友自拍室友房内激情事 两洋妞超下流激情自拍 红衣爆乳妹浪情写真 石屋女子唤醒野性欲望 免费点歌 手机视频 手机彩图 热门铃声 劲爆DJ 求佛 秋天不回来 月亮之上 qq爱 不怕不怕 香水有毒 千里之外 大城小爱 老婆老婆我爱你 听妈妈的话 今天你要嫁给我 那一夜 狼爱上羊 隐形的翅膀 认真的雪 寂寞沙洲冷 一万个理由 不要再来伤害我 期待 飞舞 夜曲 爸爸妈妈 我不后悔 本草纲目 笔记 触电 号码 爱我别走 太美丽 127日 反转地球 对不起我的最爱 曹操 死了都要爱 真爱 不得不爱 玩美 香飘飘 美丽心情 吻别 花的嫁纱 莫斯科没有眼泪 千年之恋 爱如潮水 哎呀 发如雪 化蝶飞 蓝眼泪 飘雪 你的眼神 天下无双 婴儿 樱花草 七天七世纪 今夜你会不会来 大城小事 你怎么舍得我难过 十元人民币 天亮了 千千阙歌 借口 分手快乐 寓言 偏偏喜欢你 香水百合 两只小蜜蜂 上海滩 桃花朵朵开 遗失的美好 我们能不能不分手 爱上你我很快乐 一路上有你 快乐练习曲 天涯 高手 恋曲1990 江湖笑 大约在冬季 情画 爱我就别伤害我 放飞美丽 喜欢你 女人花 一生爱你千百回 你的样子 春泥 昨日重现 谢谢你的爱 一千零一夜 心雨 月亮惹的祸 说爱你 分飞 回头太难 哑巴新娘 曾经最美 西厢 希望 别怕我伤心 我只在乎你 你到底爱谁 爱很简单 当你孤单你会想起谁 心肝宝贝 一直很安静 光辉岁月 盖世英雄 冰菊舞 吉祥三宝 祝你一路顺风 欧若拉 水手 解脱 丝路 我说我爱你 安静 燕尾蝶 月光 一千个伤心的理由 一个人哭 爱情木瓜 我要的世界 无间道 梁祝 眉飞色舞 雨人 感恩的心 轨迹 红模仿 红色石头 折子戏 挪威的森林 戒不掉 童年 美丽的神话 猪都笑了 快乐崇拜 give me five 别说我的眼泪你无所谓 广岛之恋 我的果汁分你一半 让泪化作相思雨 精忠报国 双鱼座 秋天的童话 在他乡 虫儿飞 过火 我们都是好孩子 爱情 双截棍 完美世界 嘻唰唰 黑色幽默 假装 蜗牛 潘朵拉 爱如空气 容易受伤的女人 手放开 见习爱神 一剪梅 你的微笑 我不想说我是鸡 童话 无尽的爱 蓝莲花 我爱你你却爱着他 恋着多喜欢 大舌头 我要抱着你 绝口不提爱你 走出喜马拉雅 披着羊皮的狼 铁血丹心 从开始到现在 我不愿看见你再流泪 爱笑的眼睛 明天会更好 受了点伤 如果没有你 记事本 大地 都是你 如果爱 天空 说爱我 小薇 曾经的你 倒带 不痛 痛快 断了的弦 晴天 星光游乐园 真爱你的云 <a href="http://www.popyy.cn/music/

Posted by fdasfdsa on October 11, 2006 at 06:38 PM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

Calendar

RSS Feeds

Search

Links

Navigation

Referers