Changeset View
Changeset View
Standalone View
Standalone View
lib/libkvm/kvm_minidump_i386.c
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | _i386_minidump_freevtop(kvm_t *kd) | ||||
free(vm); | free(vm); | ||||
kd->vmst = NULL; | kd->vmst = NULL; | ||||
} | } | ||||
static int | static int | ||||
_i386_minidump_initvtop(kvm_t *kd) | _i386_minidump_initvtop(kvm_t *kd) | ||||
{ | { | ||||
struct vmstate *vmst; | struct vmstate *vmst; | ||||
off_t off, sparse_off; | off_t off, dump_avail_off, sparse_off; | ||||
vmst = _kvm_malloc(kd, sizeof(*vmst)); | vmst = _kvm_malloc(kd, sizeof(*vmst)); | ||||
if (vmst == NULL) { | if (vmst == NULL) { | ||||
_kvm_err(kd, kd->program, "cannot allocate vm"); | _kvm_err(kd, kd->program, "cannot allocate vm"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
kd->vmst = vmst; | kd->vmst = vmst; | ||||
if (pread(kd->pmfd, &vmst->hdr, sizeof(vmst->hdr), 0) != | if (pread(kd->pmfd, &vmst->hdr, sizeof(vmst->hdr), 0) != | ||||
sizeof(vmst->hdr)) { | sizeof(vmst->hdr)) { | ||||
_kvm_err(kd, kd->program, "cannot read dump header"); | _kvm_err(kd, kd->program, "cannot read dump header"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (strncmp(MINIDUMP_MAGIC, vmst->hdr.magic, sizeof(vmst->hdr.magic)) != 0) { | if (strncmp(MINIDUMP_MAGIC, vmst->hdr.magic, sizeof(vmst->hdr.magic)) != 0) { | ||||
_kvm_err(kd, kd->program, "not a minidump for this platform"); | _kvm_err(kd, kd->program, "not a minidump for this platform"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
vmst->hdr.version = le32toh(vmst->hdr.version); | vmst->hdr.version = le32toh(vmst->hdr.version); | ||||
if (vmst->hdr.version != MINIDUMP_VERSION) { | if (vmst->hdr.version != MINIDUMP_VERSION && vmst->hdr.version != 1) { | ||||
_kvm_err(kd, kd->program, "wrong minidump version. expected %d got %d", | _kvm_err(kd, kd->program, "wrong minidump version. expected %d got %d", | ||||
MINIDUMP_VERSION, vmst->hdr.version); | MINIDUMP_VERSION, vmst->hdr.version); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
vmst->hdr.msgbufsize = le32toh(vmst->hdr.msgbufsize); | vmst->hdr.msgbufsize = le32toh(vmst->hdr.msgbufsize); | ||||
vmst->hdr.bitmapsize = le32toh(vmst->hdr.bitmapsize); | vmst->hdr.bitmapsize = le32toh(vmst->hdr.bitmapsize); | ||||
vmst->hdr.ptesize = le32toh(vmst->hdr.ptesize); | vmst->hdr.ptesize = le32toh(vmst->hdr.ptesize); | ||||
vmst->hdr.kernbase = le32toh(vmst->hdr.kernbase); | vmst->hdr.kernbase = le32toh(vmst->hdr.kernbase); | ||||
vmst->hdr.paemode = le32toh(vmst->hdr.paemode); | vmst->hdr.paemode = le32toh(vmst->hdr.paemode); | ||||
vmst->hdr.dumpavailsize = vmst->hdr.version == MINIDUMP_VERSION ? | |||||
le32toh(vmst->hdr.dumpavailsize) : 0; | |||||
/* Skip header and msgbuf */ | /* Skip header and msgbuf */ | ||||
off = I386_PAGE_SIZE + i386_round_page(vmst->hdr.msgbufsize); | dump_avail_off = I386_PAGE_SIZE + i386_round_page(vmst->hdr.msgbufsize); | ||||
/* Skip dump_avail */ | |||||
off = dump_avail_off + i386_round_page(vmst->hdr.dumpavailsize); | |||||
sparse_off = off + i386_round_page(vmst->hdr.bitmapsize) + | sparse_off = off + i386_round_page(vmst->hdr.bitmapsize) + | ||||
i386_round_page(vmst->hdr.ptesize); | i386_round_page(vmst->hdr.ptesize); | ||||
if (_kvm_pt_init(kd, vmst->hdr.bitmapsize, off, sparse_off, | if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, | ||||
I386_PAGE_SIZE, sizeof(uint32_t)) == -1) { | vmst->hdr.bitmapsize, off, sparse_off, I386_PAGE_SIZE, | ||||
sizeof(uint32_t)) == -1) { | |||||
return (-1); | return (-1); | ||||
} | } | ||||
off += i386_round_page(vmst->hdr.bitmapsize); | off += i386_round_page(vmst->hdr.bitmapsize); | ||||
if (_kvm_pmap_init(kd, vmst->hdr.ptesize, off) == -1) { | if (_kvm_pmap_init(kd, vmst->hdr.ptesize, off) == -1) { | ||||
return (-1); | return (-1); | ||||
} | } | ||||
off += i386_round_page(vmst->hdr.ptesize); | off += i386_round_page(vmst->hdr.ptesize); | ||||
▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines |