--- crash-4.0-3.20/memory.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/memory.c 2007-03-15 13:25:25.000000000 -0500 @@ -659,8 +659,17 @@ vt->dump_free_pages = dump_free_pages_zones_v1; } else if (VALID_STRUCT(zone)) { - MEMBER_OFFSET_INIT(zone_free_pages, - "zone", "free_pages"); + MEMBER_OFFSET_INIT(zone_vm_stat, "zone", "vm_stat"); + MEMBER_OFFSET_INIT(zone_free_pages, "zone", "free_pages"); + if (INVALID_MEMBER(zone_free_pages) && + VALID_MEMBER(zone_vm_stat)) { + long nr_free_pages = 0; + if (!enumerator_value("NR_FREE_PAGES", &nr_free_pages)) + error(WARNING, + "cannot determine NR_FREE_PAGES enumerator\n"); + ASSIGN_OFFSET(zone_free_pages) = OFFSET(zone_vm_stat) + + (nr_free_pages * sizeof(long)); + } MEMBER_OFFSET_INIT(zone_free_area, "zone", "free_area"); MEMBER_OFFSET_INIT(zone_zone_pgdat, @@ -3098,7 +3107,8 @@ if (DO_REF_SEARCH(ref)) { if (VM_REF_CHECK_DECVAL(ref, - SWP_OFFSET(paddr))) { + THIS_KERNEL_VERSION >= LINUX(2,6,0) ? + __swp_offset(paddr) : SWP_OFFSET(paddr))) { if (DO_REF_DISPLAY(ref)) display = TRUE; else { @@ -11094,8 +11104,12 @@ if (!pte) return NULL; - sprintf(buf, "%s OFFSET: %lld", - get_swapdev(SWP_TYPE(pte), swapdev), SWP_OFFSET(pte)); + if (THIS_KERNEL_VERSION >= LINUX(2,6,0)) + sprintf(buf, "%s OFFSET: %lld", + get_swapdev(__swp_type(pte), swapdev), __swp_offset(pte)); + else + sprintf(buf, "%s OFFSET: %llx", + get_swapdev(SWP_TYPE(pte), swapdev), SWP_OFFSET(pte)); return buf; } --- crash-4.0-3.20/help.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/help.c 2007-03-16 14:32:49.000000000 -0500 @@ -5150,7 +5150,7 @@ "Copyright (C) 2004, 2005, 2006 IBM Corporation", "Copyright (C) 1999-2006 Hewlett-Packard Co", "Copyright (C) 2005, 2006 Fujitsu Limited", -"Copyright (C) 2006 VA Linux Systems Japan K.K.", +"Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.", "Copyright (C) 2005 NEC Corporation", "Copyright (C) 1999, 2002 Silicon Graphics, Inc.", "Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.", --- crash-4.0-3.20/task.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/task.c 2007-03-14 10:16:31.000000000 -0500 @@ -370,8 +370,11 @@ set_context(NO_TASK, active_pid); tt->this_task = pid_to_task(active_pid); } - else + else { + please_wait("determining panic task"); set_context(get_panic_context(), NO_PID); + please_wait_done(); + } sort_context_array(); --- crash-4.0-3.20/kernel.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/kernel.c 2007-03-12 12:37:45.000000000 -0500 @@ -470,7 +470,7 @@ { char buf[BUFSIZE]; ulong linux_banner; - int argc; + int argc, len; char *arglist[MAXARGS]; char *p1, *p2; struct syment *sp; @@ -498,7 +498,8 @@ error(WARNING, "cannot read linux_banner string\n"); if (ACTIVE()) { - if (strlen(kt->proc_version) && !STREQ(buf, kt->proc_version)) { + len = strlen(kt->proc_version) - 1; + if ((len > 0) && (strncmp(buf, kt->proc_version, len) != 0)) { if (CRASHDEBUG(1)) { fprintf(fp, "/proc/version:\n%s", kt->proc_version); --- crash-4.0-3.20/x86.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/x86.c 2007-03-15 14:31:29.000000000 -0500 @@ -2512,7 +2512,7 @@ MKSTR(&physpage))); pseudo_physpage += (PAGEOFFSET(vaddr) | - (page_table_entry & _PAGE_NX)); + (page_table_entry & (_PAGE_NX|machdep->pageoffset))); fprintf(fp, " PAGE: %s\n\n", mkstring(buf, VADDR_PRLEN, RJUST|LONGLONG_HEX, @@ -4423,7 +4423,7 @@ off_t offset; if (!symbol_exists("phys_to_machine_mapping")) { - xd->flags |= XC_CORE_NO_P2MM; + xd->flags |= XC_CORE_NO_P2M; return TRUE; } --- crash-4.0-3.20/ppc.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/ppc.c 2007-03-16 14:31:39.000000000 -0500 @@ -51,6 +51,9 @@ void ppc_init(int when) { + uint cpu_features; + ulong cur_cpu_spec; + switch (when) { case PRE_SYMTAB: @@ -140,6 +143,16 @@ if (THIS_KERNEL_VERSION >= LINUX(2,6,0)) machdep->hz = 1000; } + if (symbol_exists("cur_cpu_spec")) { + get_symbol_data("cur_cpu_spec", sizeof(void *), &cur_cpu_spec); + readmem(cur_cpu_spec + MEMBER_OFFSET("cpu_spec", "cpu_user_features"), + KVADDR, &cpu_features, sizeof(uint), "cpu user features", + FAULT_ON_ERROR); + if (cpu_features & CPU_BOOKE) + machdep->flags |= CPU_BOOKE; + } + else + machdep->flags |= CPU_BOOKE; machdep->section_size_bits = _SECTION_SIZE_BITS; machdep->max_physmem_bits = _MAX_PHYSMEM_BITS; break; @@ -285,7 +298,11 @@ page_middle = (ulong *)pgd_pte; - page_table = page_middle + (BTOP(vaddr) & (PTRS_PER_PTE - 1)); + if (machdep->flags & CPU_BOOKE) + page_table = page_middle + (BTOP(vaddr) & (PTRS_PER_PTE - 1)); + else + page_table = ((page_middle & machdep->pagemask) + machdep->kvbase) + + (BTOP(vaddr) & (PTRS_PER_PTE-1)); if (verbose) fprintf(fp, " PMD: %lx => %lx\n",(ulong)page_middle, @@ -369,7 +386,11 @@ page_middle = (ulong *)pgd_pte; - page_table = page_middle + (BTOP(kvaddr) & (PTRS_PER_PTE-1)); + if (machdep->flags & CPU_BOOKE) + page_table = page_middle + (BTOP(kvaddr) & (PTRS_PER_PTE - 1)); + else + page_table = ((page_middle & machdep->pagemask) + machdep->kvbase) + + (BTOP(kvaddr) & (PTRS_PER_PTE-1)); if (verbose) fprintf(fp, " PMD: %lx => %lx\n", (ulong)page_middle, --- crash-4.0-3.20/ia64.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/ia64.c 2007-03-15 08:16:14.000000000 -0500 @@ -3893,7 +3893,7 @@ ia64_xendump_p2m_create(struct xendump_data *xd) { if (!symbol_exists("phys_to_machine_mapping")) { - xd->flags |= XC_CORE_NO_P2MM; + xd->flags |= XC_CORE_NO_P2M; return TRUE; } @@ -4009,7 +4009,7 @@ if (symbol_exists("unw_init_frame_info")) { machdep->flags |= NEW_UNWIND; if (MEMBER_EXISTS("unw_frame_info", "pt")) { - if (MEMBER_EXISTS("pt_regs", "ar_csd")) { + if (MEMBER_EXISTS("cpu_user_regs", "ar_csd")) { machdep->flags |= NEW_UNW_V3; ms->unwind_init = unwind_init_v3; ms->unwind = unwind_v3; --- crash-4.0-3.20/x86_64.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/x86_64.c 2007-03-15 13:25:20.000000000 -0500 @@ -929,6 +929,8 @@ if (verbose) fprintf(fp, " PTE: %lx => %lx\n", (ulong)ptep, pte); if (!(pte & (_PAGE_PRESENT))) { + *paddr = pte; + if (pte && verbose) { fprintf(fp, "\n"); x86_64_translate_pte(pte, 0, 0); @@ -1067,6 +1069,8 @@ if (verbose) fprintf(fp, " PTE: %lx => %lx [machine]\n", (ulong)ptep, pte); if (!(pte & (_PAGE_PRESENT))) { + *paddr = pte; + if (pte && verbose) { fprintf(fp, "\n"); x86_64_translate_pte(pte, 0, 0); @@ -1196,6 +1200,8 @@ if (verbose) fprintf(fp, " PTE: %lx => %lx [machine]\n", (ulong)ptep, pte); if (!(pte & (_PAGE_PRESENT))) { + *paddr = pte; + if (pte && verbose) { fprintf(fp, "\n"); x86_64_translate_pte(pte, 0, 0); @@ -1300,6 +1306,8 @@ if (verbose) fprintf(fp, " PTE: %lx => %lx\n", (ulong)ptep, pte); if (!(pte & (_PAGE_PRESENT))) { + *paddr = pte; + if (pte && verbose) { fprintf(fp, "\n"); x86_64_translate_pte(pte, 0, 0); @@ -4516,7 +4524,7 @@ off_t offset; if (!symbol_exists("phys_to_machine_mapping")) { - xd->flags |= XC_CORE_NO_P2MM; + xd->flags |= XC_CORE_NO_P2M; return TRUE; } --- crash-4.0-3.20/symbols.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/symbols.c 2007-02-26 14:33:41.000000000 -0500 @@ -6414,6 +6414,8 @@ OFFSET(zone_pages_low)); fprintf(fp, " zone_pages_high: %ld\n", OFFSET(zone_pages_high)); + fprintf(fp, " zone_vm_stat: %ld\n", + OFFSET(zone_vm_stat)); fprintf(fp, " neighbour_next: %ld\n", OFFSET(neighbour_next)); --- crash-4.0-3.20/xendump.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/xendump.c 2007-03-14 10:18:32.000000000 -0500 @@ -29,10 +29,29 @@ static void xen_dump_vmconfig(FILE *); -static void xc_core_p2m_create(void); +static void xc_core_create_pfn_tables(void); static ulong xc_core_pfn_to_page_index(ulong); static int xc_core_pfn_valid(ulong); +static void xendump_print(char *fmt, ...); + +static int xc_core_elf_verify(char *); +static void xc_core_elf_dump(void); +static char *xc_core_elf_mfn_to_page(ulong, char *); +static int xc_core_elf_mfn_to_page_index(ulong); +static ulong xc_core_elf_pfn_valid(ulong); +static ulong xc_core_elf_pfn_to_page_index(ulong); +static void xc_core_dump_Elf32_Ehdr(Elf32_Ehdr *); +static void xc_core_dump_Elf64_Ehdr(Elf64_Ehdr *); +static void xc_core_dump_Elf32_Shdr(Elf32_Off offset, int); +static void xc_core_dump_Elf64_Shdr(Elf64_Off offset, int); +static char *xc_core_strtab(uint32_t, char *); +static void xc_core_dump_elfnote(off_t, size_t, int); +static void xc_core_elf_pfn_init(void); + +#define ELFSTORE 1 +#define ELFREAD 0 + /* * Determine whether a file is a xendump creation, and if TRUE, * initialize the xendump_data structure. @@ -80,6 +99,9 @@ xcp = (struct xc_core_header *)buf; + if (xc_core_elf_verify(buf)) + return TRUE; + if ((xcp->xch_magic != XC_CORE_MAGIC) && (xcp->xch_magic != XC_CORE_MAGIC_HVM)) return FALSE; @@ -101,7 +123,7 @@ BCOPY(xcp, &xd->xc_core.header, sizeof(struct xc_core_header)); - xd->flags |= (XENDUMP_LOCAL | XC_CORE); + xd->flags |= (XENDUMP_LOCAL | XC_CORE_ORIG | XC_CORE_P2M_CREATE); if (xc_core_mfns(XC_CORE_64BIT_HOST, stderr)) xd->flags |= XC_CORE_64BIT_HOST; @@ -135,8 +157,8 @@ off_t offset; int redundant; - if (!(xd->flags & XC_CORE_P2M_INIT)) - xc_core_p2m_create(); + if (xd->flags & (XC_CORE_P2M_CREATE|XC_CORE_PFN_CREATE)) + xc_core_create_pfn_tables(); pfn = (ulong)BTOP(paddr); @@ -797,12 +819,13 @@ if (pc->curcmd_flags & XEN_MACHINE_ADDR) return READ_ERROR; - switch (xd->flags & (XC_SAVE|XC_CORE)) + switch (xd->flags & (XC_SAVE|XC_CORE_ORIG|XC_CORE_ELF)) { case XC_SAVE: return xc_save_read(bufptr, cnt, addr, paddr); - case XC_CORE: + case XC_CORE_ORIG: + case XC_CORE_ELF: return xc_core_read(bufptr, cnt, addr, paddr); default: @@ -876,6 +899,9 @@ { int i, linefeed, used, others; ulong *ulongptr; + Elf32_Off offset32; + Elf64_Off offset64; + FILE *fpsave; fprintf(fp, " flags: %lx (", xd->flags); others = 0; @@ -883,12 +909,16 @@ fprintf(fp, "%sXENDUMP_LOCAL", others++ ? "|" : ""); if (xd->flags & XC_SAVE) fprintf(fp, "%sXC_SAVE", others++ ? "|" : ""); - if (xd->flags & XC_CORE) - fprintf(fp, "%sXC_CORE", others++ ? "|" : ""); - if (xd->flags & XC_CORE_P2M_INIT) - fprintf(fp, "%sXC_CORE_P2M_INIT", others++ ? "|" : ""); - if (xd->flags & XC_CORE_NO_P2MM) - fprintf(fp, "%sXC_CORE_NO_P2MM", others++ ? "|" : ""); + if (xd->flags & XC_CORE_ORIG) + fprintf(fp, "%sXC_CORE_ORIG", others++ ? "|" : ""); + if (xd->flags & XC_CORE_ELF) + fprintf(fp, "%sXC_CORE_ELF", others++ ? "|" : ""); + if (xd->flags & XC_CORE_P2M_CREATE) + fprintf(fp, "%sXC_CORE_P2M_CREATE", others++ ? "|" : ""); + if (xd->flags & XC_CORE_PFN_CREATE) + fprintf(fp, "%sXC_CORE_PFN_CREATE", others++ ? "|" : ""); + if (xd->flags & XC_CORE_NO_P2M) + fprintf(fp, "%sXC_CORE_NO_P2M", others++ ? "|" : ""); if (xd->flags & XC_SAVE_IA64) fprintf(fp, "%sXC_SAVE_IA64", others++ ? "|" : ""); if (xd->flags & XC_CORE_64BIT_HOST) @@ -1013,19 +1043,90 @@ xd->xc_core.header.xch_pages_offset, xd->xc_core.header.xch_pages_offset); + fprintf(fp, " elf_class: %s\n", xd->xc_core.elf_class == ELFCLASS64 ? "ELFCLASS64" : + xd->xc_core.elf_class == ELFCLASS32 ? "ELFCLASS32" : "n/a"); + fprintf(fp, " elf_strtab_offset: %lld (0x%llx)\n", + (ulonglong)xd->xc_core.elf_strtab_offset, + (ulonglong)xd->xc_core.elf_strtab_offset); + fprintf(fp, " format_version: %016llx\n", + (ulonglong)xd->xc_core.format_version); + fprintf(fp, " shared_info_offset: %lld (0x%llx)\n", + (ulonglong)xd->xc_core.shared_info_offset, + (ulonglong)xd->xc_core.shared_info_offset); + if (machine_type("IA64")) + fprintf(fp, " ia64_mapped_regs_offset: %lld (0x%llx)\n", + (ulonglong)xd->xc_core.ia64_mapped_regs_offset, + (ulonglong)xd->xc_core.ia64_mapped_regs_offset); + fprintf(fp, " elf_index_pfn[%d]: %s", INDEX_PFN_COUNT, + xd->xc_core.elf_class ? "\n" : "(none used)\n"); + if (xd->xc_core.elf_class) { + for (i = 0; i < INDEX_PFN_COUNT; i++) { + fprintf(fp, "%ld:%ld ", + xd->xc_core.elf_index_pfn[i].index, + xd->xc_core.elf_index_pfn[i].pfn); + } + fprintf(fp, "\n"); + } + fprintf(fp, " last_batch:\n"); + fprintf(fp, " index: %ld (%ld - %ld)\n", + xd->xc_core.last_batch.index, + xd->xc_core.last_batch.start, xd->xc_core.last_batch.end); + fprintf(fp, " accesses: %ld\n", + xd->xc_core.last_batch.accesses); + fprintf(fp, " duplicates: %ld ", + xd->xc_core.last_batch.duplicates); + if (xd->xc_core.last_batch.accesses) + fprintf(fp, "(%ld%%)\n", + xd->xc_core.last_batch.duplicates * 100 / + xd->xc_core.last_batch.accesses); + else + fprintf(fp, "\n"); + + fprintf(fp, " elf32: %lx\n", (ulong)xd->xc_core.elf32); + fprintf(fp, " elf64: %lx\n", (ulong)xd->xc_core.elf64); + fprintf(fp, " p2m_frames: %d\n", xd->xc_core.p2m_frames); fprintf(fp, " p2m_frame_index_list: %s\n", - (xd->flags & (XC_CORE_NO_P2MM|XC_SAVE)) ? "(not used)" : ""); + (xd->flags & (XC_CORE_NO_P2M|XC_SAVE)) ? "(not used)" : ""); for (i = 0; i < xd->xc_core.p2m_frames; i++) { fprintf(fp, "%ld ", xd->xc_core.p2m_frame_index_list[i]); } fprintf(fp, xd->xc_core.p2m_frames ? "\n" : ""); - if ((xd->flags & XC_CORE) && CRASHDEBUG(8)) + if ((xd->flags & XC_CORE_ORIG) && CRASHDEBUG(8)) xc_core_mfns(XENDUMP_LOCAL, fp); + switch (xd->xc_core.elf_class) + { + case ELFCLASS32: + fpsave = xd->ofp; + xd->ofp = fp; + xc_core_elf_dump(); + offset32 = xd->xc_core.elf32->e_shoff; + for (i = 0; i < xd->xc_core.elf32->e_shnum; i++) { + xc_core_dump_Elf32_Shdr(offset32, ELFREAD); + offset32 += xd->xc_core.elf32->e_shentsize; + } + xendump_print("\n"); + xd->ofp = fpsave; + break; + + case ELFCLASS64: + fpsave = xd->ofp; + xd->ofp = fp; + xc_core_elf_dump(); + offset64 = xd->xc_core.elf64->e_shoff; + for (i = 0; i < xd->xc_core.elf64->e_shnum; i++) { + xc_core_dump_Elf64_Shdr(offset64, ELFREAD); + offset64 += xd->xc_core.elf64->e_shentsize; + } + xendump_print("\n"); + xd->ofp = fpsave; + break; + } + return 0; } @@ -1064,9 +1165,10 @@ ulong task; struct task_context *tc; - switch (xd->flags & (XC_CORE|XC_SAVE)) + switch (xd->flags & (XC_CORE_ORIG|XC_CORE_ELF|XC_SAVE)) { - case XC_CORE: + case XC_CORE_ORIG: + case XC_CORE_ELF: if (machdep->xendump_panic_task) return (machdep->xendump_panic_task((void *)xd)); break; @@ -1101,9 +1203,10 @@ return; } - switch (xd->flags & (XC_CORE|XC_SAVE)) + switch (xd->flags & (XC_CORE_ORIG|XC_CORE_ELF|XC_SAVE)) { - case XC_CORE: + case XC_CORE_ORIG: + case XC_CORE_ELF: if (machdep->get_xendump_regs) return (machdep->get_xendump_regs(xd, bt, pc, sp)); break; @@ -1134,20 +1237,26 @@ } /* - * Farm out most of the work to the proper architecture. + * Farm out most of the work to the proper architecture to create + * the p2m table. For ELF core dumps, create the index;pfn table. */ static void -xc_core_p2m_create(void) +xc_core_create_pfn_tables(void) { - if (!machdep->xendump_p2m_create) - error(FATAL, - "xen xc_core dumpfiles not supported on this architecture"); + if (xd->flags & XC_CORE_P2M_CREATE) { + if (!machdep->xendump_p2m_create) + error(FATAL, + "xen xc_core dumpfiles not supported on this architecture"); + + if (!machdep->xendump_p2m_create((void *)xd)) + error(FATAL, + "cannot create xen pfn-to-mfn mapping\n"); + } - if (!machdep->xendump_p2m_create((void *)xd)) - error(FATAL, - "cannot create xen pfn-to-mfn mapping\n"); + if (xd->flags & XC_CORE_ELF) + xc_core_elf_pfn_init(); - xd->flags |= XC_CORE_P2M_INIT; + xd->flags &= ~(XC_CORE_P2M_CREATE|XC_CORE_PFN_CREATE); if (CRASHDEBUG(1)) xendump_memory_dump(xd->ofp); @@ -1165,6 +1274,9 @@ off_t offset; uint nr_pages; + if (xd->flags & XC_CORE_ELF) + return xc_core_elf_mfn_to_page(mfn, pgbuf); + if (lseek(xd->xfd, (off_t)xd->xc_core.header.xch_index_offset, SEEK_SET) == -1) { error(INFO, "cannot lseek to page index\n"); @@ -1191,7 +1303,7 @@ } if (tmp[i] == mfn) { idx = i+b; - if (CRASHDEBUG(2)) + if (CRASHDEBUG(4)) fprintf(xd->ofp, "page: found mfn 0x%lx (%ld) at index %d\n", mfn, mfn, idx); @@ -1227,6 +1339,79 @@ return pgbuf; } +/* + * Find the page index containing the mfn, and read the + * machine page into the buffer. + */ +static char * +xc_core_elf_mfn_to_page(ulong mfn, char *pgbuf) +{ + int i, b, idx, done; + off_t offset; + size_t size; + uint nr_pages; + ulong tmp; + struct xen_dumpcore_p2m p2m_batch[MAX_BATCH_SIZE]; + + offset = xd->xc_core.header.xch_index_offset; + size = sizeof(struct xen_dumpcore_p2m) * MAX_BATCH_SIZE; + nr_pages = xd->xc_core.header.xch_nr_pages; + + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, "cannot lseek to page index\n"); + + for (b = 0, idx = -1, done = FALSE; + !done && (b < nr_pages); b += MAX_BATCH_SIZE) { + + if (read(xd->xfd, &p2m_batch[0], size) != size) { + error(INFO, "cannot read index page %d\n", b); + return NULL; + } + + for (i = 0; i < MAX_BATCH_SIZE; i++) { + if ((b+i) >= nr_pages) { + done = TRUE; + break; + } + + tmp = (ulong)p2m_batch[i].gmfn; + + if (tmp == mfn) { + idx = i+b; + if (CRASHDEBUG(4)) + fprintf(xd->ofp, + "page: found mfn 0x%lx (%ld) at index %d\n", + mfn, mfn, idx); + done = TRUE; + } + } + } + + if (idx == -1) { + error(INFO, "cannot find mfn %ld (0x%lx) in page index\n", + mfn, mfn); + return NULL; + } + + if (lseek(xd->xfd, (off_t)xd->xc_core.header.xch_pages_offset, + SEEK_SET) == -1) + error(FATAL, "cannot lseek to xch_pages_offset\n"); + + offset = (off_t)(idx) * (off_t)xd->page_size; + + if (lseek(xd->xfd, offset, SEEK_CUR) == -1) { + error(INFO, "cannot lseek to mfn-specified page\n"); + return NULL; + } + + if (read(xd->xfd, pgbuf, xd->page_size) != xd->page_size) { + error(INFO, "cannot read mfn-specified page\n"); + return NULL; + } + + return pgbuf; +} + /* * Find and return the page index containing the mfn. @@ -1238,6 +1423,9 @@ ulong tmp[MAX_BATCH_SIZE]; uint nr_pages; + if (xd->flags & XC_CORE_ELF) + return xc_core_elf_mfn_to_page_index(mfn); + if (lseek(xd->xfd, (off_t)xd->xc_core.header.xch_index_offset, SEEK_SET) == -1) { error(INFO, "cannot lseek to page index\n"); @@ -1274,6 +1462,53 @@ } /* + * Find and return the page index containing the mfn. + */ +static int +xc_core_elf_mfn_to_page_index(ulong mfn) +{ + int i, b; + off_t offset; + size_t size; + uint nr_pages; + ulong tmp; + struct xen_dumpcore_p2m p2m_batch[MAX_BATCH_SIZE]; + + offset = xd->xc_core.header.xch_index_offset; + size = sizeof(struct xen_dumpcore_p2m) * MAX_BATCH_SIZE; + nr_pages = xd->xc_core.header.xch_nr_pages; + + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, "cannot lseek to page index\n"); + + for (b = 0; b < nr_pages; b += MAX_BATCH_SIZE) { + + if (read(xd->xfd, &p2m_batch[0], size) != size) { + error(INFO, "cannot read index page %d\n", b); + return MFN_NOT_FOUND; + } + + for (i = 0; i < MAX_BATCH_SIZE; i++) { + if ((b+i) >= nr_pages) + break; + + tmp = (ulong)p2m_batch[i].gmfn; + + if (tmp == mfn) { + if (CRASHDEBUG(4)) + fprintf(xd->ofp, + "index: batch: %d found mfn %ld (0x%lx) at index %d\n", + b/MAX_BATCH_SIZE, mfn, mfn, i+b); + return (i+b); + } + } + } + + return MFN_NOT_FOUND; +} + + +/* * XC_CORE mfn-related utility function. */ static int @@ -1397,7 +1632,6 @@ * - From the phys_to_machine_mapping page, determine the mfn. * - Find the mfn in the dumpfile page index. */ - #define PFNS_PER_PAGE (xd->page_size/sizeof(unsigned long)) static ulong @@ -1407,8 +1641,21 @@ ulong *up, mfn; off_t offset; - if (xd->flags & XC_CORE_NO_P2MM) + /* + * This function does not apply when there's no p2m + * mapping and/or if this is an ELF format dumpfile. + */ + switch (xd->flags & (XC_CORE_NO_P2M|XC_CORE_ELF)) + { + case (XC_CORE_NO_P2M|XC_CORE_ELF): + return xc_core_elf_pfn_valid(pfn); + + case XC_CORE_NO_P2M: return(xc_core_pfn_valid(pfn) ? pfn : PFN_NOT_FOUND); + + case XC_CORE_ELF: + return xc_core_elf_pfn_to_page_index(pfn); + } idx = pfn/PFNS_PER_PAGE; @@ -1451,6 +1698,84 @@ return mfn_idx; } + +/* + * Search the .xen_p2m array for the target pfn, starting at a + * higher batch if appropriate. This presumes that the pfns + * are laid out in ascending order. + */ +static ulong +xc_core_elf_pfn_to_page_index(ulong pfn) +{ + int i, b, start_index; + off_t offset; + size_t size; + uint nr_pages; + ulong tmp; + struct xen_dumpcore_p2m p2m_batch[MAX_BATCH_SIZE]; + + offset = xd->xc_core.header.xch_index_offset; + size = sizeof(struct xen_dumpcore_p2m) * MAX_BATCH_SIZE; + nr_pages = xd->xc_core.header.xch_nr_pages; + + /* + * Initialize the start_index. + */ + xd->xc_core.last_batch.accesses++; + + if ((pfn >= xd->xc_core.last_batch.start) && + (pfn <= xd->xc_core.last_batch.end)) { + xd->xc_core.last_batch.duplicates++; + start_index = xd->xc_core.last_batch.index; + } else { + for (i = 0; i <= INDEX_PFN_COUNT; i++) { + if ((i == INDEX_PFN_COUNT) || + (pfn < xd->xc_core.elf_index_pfn[i].pfn)) { + if (--i < 0) + i = 0; + start_index = xd->xc_core.elf_index_pfn[i].index; + break; + } + } + } + + offset += (start_index * sizeof(struct xen_dumpcore_p2m)); + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, "cannot lseek to page index\n"); + + for (b = start_index; b < nr_pages; b += MAX_BATCH_SIZE) { + + if (read(xd->xfd, &p2m_batch[0], size) != size) { + error(INFO, "cannot read index page %d\n", b); + return PFN_NOT_FOUND; + } + + for (i = 0; i < MAX_BATCH_SIZE; i++) { + if ((b+i) >= nr_pages) + break; + + tmp = (ulong)p2m_batch[i].pfn; + + if (tmp == pfn) { + if (CRASHDEBUG(4)) + fprintf(xd->ofp, + "index: batch: %d found pfn %ld (0x%lx) at index %d\n", + b/MAX_BATCH_SIZE, pfn, pfn, i+b); + + if ((b+MAX_BATCH_SIZE) < nr_pages) { + xd->xc_core.last_batch.index = b; + xd->xc_core.last_batch.start = p2m_batch[0].pfn; + xd->xc_core.last_batch.end = p2m_batch[MAX_BATCH_SIZE-1].pfn; + } + + return (i+b); + } + } + } + + return PFN_NOT_FOUND; +} + /* * In xendumps containing INVALID_MFN markers in the page index, * return the validity of the pfn. @@ -1505,6 +1830,82 @@ } /* + * Return the index into the .xen_pfn array containing the pfn. + * If not found, return PFN_NOT_FOUND. + */ +static ulong +xc_core_elf_pfn_valid(ulong pfn) +{ + int i, b, start_index; + off_t offset; + size_t size; + uint nr_pages; + ulong tmp; + uint64_t pfn_batch[MAX_BATCH_SIZE]; + + offset = xd->xc_core.header.xch_index_offset; + size = sizeof(uint64_t) * MAX_BATCH_SIZE; + nr_pages = xd->xc_core.header.xch_nr_pages; + + /* + * Initialize the start_index. + */ + xd->xc_core.last_batch.accesses++; + + if ((pfn >= xd->xc_core.last_batch.start) && + (pfn <= xd->xc_core.last_batch.end)) { + xd->xc_core.last_batch.duplicates++; + start_index = xd->xc_core.last_batch.index; + } else { + for (i = 0; i <= INDEX_PFN_COUNT; i++) { + if ((i == INDEX_PFN_COUNT) || + (pfn < xd->xc_core.elf_index_pfn[i].pfn)) { + if (--i < 0) + i = 0; + start_index = xd->xc_core.elf_index_pfn[i].index; + break; + } + } + } + + offset += (start_index * sizeof(uint64_t)); + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, "cannot lseek to page index\n"); + + for (b = start_index; b < nr_pages; b += MAX_BATCH_SIZE) { + + if (read(xd->xfd, &pfn_batch[0], size) != size) { + error(INFO, "cannot read index page %d\n", b); + return PFN_NOT_FOUND; + } + + for (i = 0; i < MAX_BATCH_SIZE; i++) { + if ((b+i) >= nr_pages) + break; + + tmp = (ulong)pfn_batch[i]; + + if (tmp == pfn) { + if (CRASHDEBUG(4)) + fprintf(xd->ofp, + "index: batch: %d found pfn %ld (0x%lx) at index %d\n", + b/MAX_BATCH_SIZE, pfn, pfn, i+b); + + if ((b+MAX_BATCH_SIZE) < nr_pages) { + xd->xc_core.last_batch.index = b; + xd->xc_core.last_batch.start = (ulong)pfn_batch[0]; + xd->xc_core.last_batch.end = (ulong)pfn_batch[MAX_BATCH_SIZE-1]; + } + + return (i+b); + } + } + } + + return PFN_NOT_FOUND; +} + +/* * Store the panic task's stack hooks from where it was found * in get_active_set_panic_task(). */ @@ -1546,3 +1947,883 @@ } } } + +static void +xendump_print(char *fmt, ...) +{ + char buf[BUFSIZE]; + va_list ap; + + if (!fmt || !strlen(fmt)) + return; + + va_start(ap, fmt); + (void)vsnprintf(buf, BUFSIZE, fmt, ap); + va_end(ap); + + if (xd->ofp) + fprintf(xd->ofp, buf); + else if (!XENDUMP_VALID() && CRASHDEBUG(7)) + fprintf(stderr, buf); + +} + +/* + * Support for xc_core ELF dumpfile format. + */ +static int +xc_core_elf_verify(char *buf) +{ + int i; + Elf32_Ehdr *elf32; + Elf64_Ehdr *elf64; + Elf32_Off offset32; + Elf64_Off offset64; + + elf32 = (Elf32_Ehdr *)buf; + elf64 = (Elf64_Ehdr *)buf; + + if (STRNEQ(elf32->e_ident, ELFMAG) && + (elf32->e_ident[EI_CLASS] == ELFCLASS32) && + (elf32->e_ident[EI_DATA] == ELFDATA2LSB) && + (elf32->e_ident[EI_VERSION] == EV_CURRENT) && + (elf32->e_type == ET_CORE) && + (elf32->e_version == EV_CURRENT) && + (elf32->e_shnum > 0)) { + switch (elf32->e_machine) + { + case EM_386: + if (machine_type("X86")) + break; + default: + goto bailout; + } + + xd->xc_core.elf_class = ELFCLASS32; + if ((xd->xc_core.elf32 = (Elf32_Ehdr *)malloc(sizeof(Elf32_Ehdr))) == NULL) { + fprintf(stderr, "cannot malloc ELF header buffer\n"); + clean_exit(1); + } + BCOPY(buf, xd->xc_core.elf32, sizeof(Elf32_Ehdr)); + + } else if (STRNEQ(elf64->e_ident, ELFMAG) && + (elf64->e_ident[EI_CLASS] == ELFCLASS64) && + (elf64->e_ident[EI_VERSION] == EV_CURRENT) && + (elf64->e_type == ET_CORE) && + (elf64->e_version == EV_CURRENT) && + (elf64->e_shnum > 0)) { + switch (elf64->e_machine) + { + case EM_IA_64: + if ((elf64->e_ident[EI_DATA] == ELFDATA2LSB) && + machine_type("IA64")) + break; + else + goto bailout; + + case EM_X86_64: + if ((elf64->e_ident[EI_DATA] == ELFDATA2LSB) && + machine_type("X86_64")) + break; + else + goto bailout; + + case EM_386: + if ((elf64->e_ident[EI_DATA] == ELFDATA2LSB) && + machine_type("X86")) + break; + else + goto bailout; + + default: + goto bailout; + } + + xd->xc_core.elf_class = ELFCLASS64; + if ((xd->xc_core.elf64 = (Elf64_Ehdr *)malloc(sizeof(Elf64_Ehdr))) == NULL) { + fprintf(stderr, "cannot malloc ELF header buffer\n"); + clean_exit(1); + } + BCOPY(buf, xd->xc_core.elf64, sizeof(Elf64_Ehdr)); + + } else { + if (CRASHDEBUG(1)) + error(INFO, "xc_core_elf_verify: not a xen ELF core file\n"); + goto bailout; + } + + xc_core_elf_dump(); + + switch (xd->xc_core.elf_class) + { + case ELFCLASS32: + offset32 = xd->xc_core.elf32->e_shoff; + for (i = 0; i < xd->xc_core.elf32->e_shnum; i++) { + xc_core_dump_Elf32_Shdr(offset32, ELFSTORE); + offset32 += xd->xc_core.elf32->e_shentsize; + } + xendump_print("\n"); + break; + + case ELFCLASS64: + offset64 = xd->xc_core.elf64->e_shoff; + for (i = 0; i < xd->xc_core.elf64->e_shnum; i++) { + xc_core_dump_Elf64_Shdr(offset64, ELFSTORE); + offset64 += xd->xc_core.elf64->e_shentsize; + } + xendump_print("\n"); + break; + } + + xd->flags |= (XENDUMP_LOCAL | XC_CORE_ELF); + + if (!xd->page_size) + error(FATAL, + "unknown page size: use -p command line option\n"); + + if (!(xd->page = (char *)malloc(xd->page_size))) + error(FATAL, "cannot malloc page space."); + + if (!(xd->poc = (struct pfn_offset_cache *)calloc + (PFN_TO_OFFSET_CACHE_ENTRIES, + sizeof(struct pfn_offset_cache)))) + error(FATAL, "cannot malloc pfn_offset_cache\n"); + xd->last_pfn = ~(0UL); + + for (i = 0; i < INDEX_PFN_COUNT; i++) + xd->xc_core.elf_index_pfn[i].pfn = ~0UL; + + if (CRASHDEBUG(1)) + xendump_memory_dump(fp); + + return TRUE; + +bailout: + return FALSE; +} + +/* + * Dump the relevant ELF header. + */ +static void +xc_core_elf_dump(void) +{ + switch (xd->xc_core.elf_class) + { + case ELFCLASS32: + xc_core_dump_Elf32_Ehdr(xd->xc_core.elf32); + break; + case ELFCLASS64: + xc_core_dump_Elf64_Ehdr(xd->xc_core.elf64); + break; + } +} + + +/* + * Dump the 32-bit ELF header, and grab a pointer to the strtab section. + */ +static void +xc_core_dump_Elf32_Ehdr(Elf32_Ehdr *elf) +{ + char buf[BUFSIZE]; + Elf32_Off offset32; + Elf32_Shdr shdr; + + BZERO(buf, BUFSIZE); + BCOPY(elf->e_ident, buf, SELFMAG); + xendump_print("\nElf32_Ehdr:\n"); + xendump_print(" e_ident: \\%o%s\n", buf[0], + &buf[1]); + xendump_print(" e_ident[EI_CLASS]: %d ", elf->e_ident[EI_CLASS]); + switch (elf->e_ident[EI_CLASS]) + { + case ELFCLASSNONE: + xendump_print("(ELFCLASSNONE)"); + break; + case ELFCLASS32: + xendump_print("(ELFCLASS32)\n"); + break; + case ELFCLASS64: + xendump_print("(ELFCLASS64)\n"); + break; + case ELFCLASSNUM: + xendump_print("(ELFCLASSNUM)\n"); + break; + default: + xendump_print("(?)\n"); + break; + } + xendump_print(" e_ident[EI_DATA]: %d ", elf->e_ident[EI_DATA]); + switch (elf->e_ident[EI_DATA]) + { + case ELFDATANONE: + xendump_print("(ELFDATANONE)\n"); + break; + case ELFDATA2LSB: + xendump_print("(ELFDATA2LSB)\n"); + break; + case ELFDATA2MSB: + xendump_print("(ELFDATA2MSB)\n"); + break; + case ELFDATANUM: + xendump_print("(ELFDATANUM)\n"); + break; + default: + xendump_print("(?)\n"); + } + xendump_print(" e_ident[EI_VERSION]: %d ", + elf->e_ident[EI_VERSION]); + if (elf->e_ident[EI_VERSION] == EV_CURRENT) + xendump_print("(EV_CURRENT)\n"); + else + xendump_print("(?)\n"); + xendump_print(" e_ident[EI_OSABI]: %d ", elf->e_ident[EI_OSABI]); + switch (elf->e_ident[EI_OSABI]) + { + case ELFOSABI_SYSV: + xendump_print("(ELFOSABI_SYSV)\n"); + break; + case ELFOSABI_HPUX: + xendump_print("(ELFOSABI_HPUX)\n"); + break; + case ELFOSABI_ARM: + xendump_print("(ELFOSABI_ARM)\n"); + break; + case ELFOSABI_STANDALONE: + xendump_print("(ELFOSABI_STANDALONE)\n"); + break; + default: + xendump_print("(?)\n"); + } + xendump_print(" e_ident[EI_ABIVERSION]: %d\n", + elf->e_ident[EI_ABIVERSION]); + + xendump_print(" e_type: %d ", elf->e_type); + switch (elf->e_type) + { + case ET_NONE: + xendump_print("(ET_NONE)\n"); + break; + case ET_REL: + xendump_print("(ET_REL)\n"); + break; + case ET_EXEC: + xendump_print("(ET_EXEC)\n"); + break; + case ET_DYN: + xendump_print("(ET_DYN)\n"); + break; + case ET_CORE: + xendump_print("(ET_CORE)\n"); + break; + case ET_NUM: + xendump_print("(ET_NUM)\n"); + break; + case ET_LOOS: + xendump_print("(ET_LOOS)\n"); + break; + case ET_HIOS: + xendump_print("(ET_HIOS)\n"); + break; + case ET_LOPROC: + xendump_print("(ET_LOPROC)\n"); + break; + case ET_HIPROC: + xendump_print("(ET_HIPROC)\n"); + break; + default: + xendump_print("(?)\n"); + } + + xendump_print(" e_machine: %d ", elf->e_machine); + switch (elf->e_machine) + { + case EM_386: + xendump_print("(EM_386)\n"); + break; + default: + xendump_print("(unsupported)\n"); + break; + } + + xendump_print(" e_version: %ld ", (ulong)elf->e_version); + xendump_print("%s\n", elf->e_version == EV_CURRENT ? + "(EV_CURRENT)" : ""); + + xendump_print(" e_entry: %lx\n", (ulong)elf->e_entry); + xendump_print(" e_phoff: %lx\n", (ulong)elf->e_phoff); + xendump_print(" e_shoff: %lx\n", (ulong)elf->e_shoff); + xendump_print(" e_flags: %lx\n", (ulong)elf->e_flags); + xendump_print(" e_ehsize: %x\n", elf->e_ehsize); + xendump_print(" e_phentsize: %x\n", elf->e_phentsize); + xendump_print(" e_phnum: %x\n", elf->e_phnum); + xendump_print(" e_shentsize: %x\n", elf->e_shentsize); + xendump_print(" e_shnum: %x\n", elf->e_shnum); + xendump_print(" e_shstrndx: %x\n", elf->e_shstrndx); + + /* Determine the strtab location. */ + + offset32 = elf->e_shoff + + (elf->e_shstrndx * elf->e_shentsize); + + if (lseek(xd->xfd, offset32, SEEK_SET) != offset32) + error(FATAL, + "xc_core_dump_Elf32_Ehdr: cannot seek to strtab Elf32_Shdr\n"); + if (read(xd->xfd, &shdr, sizeof(Elf32_Shdr)) != sizeof(Elf32_Shdr)) + error(FATAL, + "xc_core_dump_Elf32_Ehdr: cannot read strtab Elf32_Shdr\n"); + + xd->xc_core.elf_strtab_offset = (ulonglong)shdr.sh_offset; +} + +/* + * Dump the 64-bit ELF header, and grab a pointer to the strtab section. + */ +static void +xc_core_dump_Elf64_Ehdr(Elf64_Ehdr *elf) +{ + char buf[BUFSIZE]; + Elf64_Off offset64; + Elf64_Shdr shdr; + + BZERO(buf, BUFSIZE); + BCOPY(elf->e_ident, buf, SELFMAG); + xendump_print("\nElf64_Ehdr:\n"); + xendump_print(" e_ident: \\%o%s\n", buf[0], + &buf[1]); + xendump_print(" e_ident[EI_CLASS]: %d ", elf->e_ident[EI_CLASS]); + switch (elf->e_ident[EI_CLASS]) + { + case ELFCLASSNONE: + xendump_print("(ELFCLASSNONE)"); + break; + case ELFCLASS32: + xendump_print("(ELFCLASS32)\n"); + break; + case ELFCLASS64: + xendump_print("(ELFCLASS64)\n"); + break; + case ELFCLASSNUM: + xendump_print("(ELFCLASSNUM)\n"); + break; + default: + xendump_print("(?)\n"); + break; + } + xendump_print(" e_ident[EI_DATA]: %d ", elf->e_ident[EI_DATA]); + switch (elf->e_ident[EI_DATA]) + { + case ELFDATANONE: + xendump_print("(ELFDATANONE)\n"); + break; + case ELFDATA2LSB: + xendump_print("(ELFDATA2LSB)\n"); + break; + case ELFDATA2MSB: + xendump_print("(ELFDATA2MSB)\n"); + break; + case ELFDATANUM: + xendump_print("(ELFDATANUM)\n"); + break; + default: + xendump_print("(?)\n"); + } + xendump_print(" e_ident[EI_VERSION]: %d ", + elf->e_ident[EI_VERSION]); + if (elf->e_ident[EI_VERSION] == EV_CURRENT) + xendump_print("(EV_CURRENT)\n"); + else + xendump_print("(?)\n"); + xendump_print(" e_ident[EI_OSABI]: %d ", elf->e_ident[EI_OSABI]); + switch (elf->e_ident[EI_OSABI]) + { + case ELFOSABI_SYSV: + xendump_print("(ELFOSABI_SYSV)\n"); + break; + case ELFOSABI_HPUX: + xendump_print("(ELFOSABI_HPUX)\n"); + break; + case ELFOSABI_ARM: + xendump_print("(ELFOSABI_ARM)\n"); + break; + case ELFOSABI_STANDALONE: + xendump_print("(ELFOSABI_STANDALONE)\n"); + break; + default: + xendump_print("(?)\n"); + } + xendump_print(" e_ident[EI_ABIVERSION]: %d\n", + elf->e_ident[EI_ABIVERSION]); + + xendump_print(" e_type: %d ", elf->e_type); + switch (elf->e_type) + { + case ET_NONE: + xendump_print("(ET_NONE)\n"); + break; + case ET_REL: + xendump_print("(ET_REL)\n"); + break; + case ET_EXEC: + xendump_print("(ET_EXEC)\n"); + break; + case ET_DYN: + xendump_print("(ET_DYN)\n"); + break; + case ET_CORE: + xendump_print("(ET_CORE)\n"); + break; + case ET_NUM: + xendump_print("(ET_NUM)\n"); + break; + case ET_LOOS: + xendump_print("(ET_LOOS)\n"); + break; + case ET_HIOS: + xendump_print("(ET_HIOS)\n"); + break; + case ET_LOPROC: + xendump_print("(ET_LOPROC)\n"); + break; + case ET_HIPROC: + xendump_print("(ET_HIPROC)\n"); + break; + default: + xendump_print("(?)\n"); + } + + xendump_print(" e_machine: %d ", elf->e_machine); + switch (elf->e_machine) + { + case EM_386: + xendump_print("(EM_386)\n"); + break; + case EM_IA_64: + xendump_print("(EM_IA_64)\n"); + break; + case EM_PPC64: + xendump_print("(EM_PPC64)\n"); + break; + case EM_X86_64: + xendump_print("(EM_X86_64)\n"); + break; + default: + xendump_print("(unsupported)\n"); + break; + } + + xendump_print(" e_version: %ld ", (ulong)elf->e_version); + xendump_print("%s\n", elf->e_version == EV_CURRENT ? + "(EV_CURRENT)" : ""); + + xendump_print(" e_entry: %lx\n", (ulong)elf->e_entry); + xendump_print(" e_phoff: %lx\n", (ulong)elf->e_phoff); + xendump_print(" e_shoff: %lx\n", (ulong)elf->e_shoff); + xendump_print(" e_flags: %lx\n", (ulong)elf->e_flags); + xendump_print(" e_ehsize: %x\n", elf->e_ehsize); + xendump_print(" e_phentsize: %x\n", elf->e_phentsize); + xendump_print(" e_phnum: %x\n", elf->e_phnum); + xendump_print(" e_shentsize: %x\n", elf->e_shentsize); + xendump_print(" e_shnum: %x\n", elf->e_shnum); + xendump_print(" e_shstrndx: %x\n", elf->e_shstrndx); + + /* Determine the strtab location. */ + + offset64 = elf->e_shoff + + (elf->e_shstrndx * elf->e_shentsize); + + if (lseek(xd->xfd, offset64, SEEK_SET) != offset64) + error(FATAL, + "xc_core_dump_Elf64_Ehdr: cannot seek to strtab Elf32_Shdr\n"); + if (read(xd->xfd, &shdr, sizeof(Elf32_Shdr)) != sizeof(Elf32_Shdr)) + error(FATAL, + "xc_core_dump_Elf64_Ehdr: cannot read strtab Elf32_Shdr\n"); + + xd->xc_core.elf_strtab_offset = (ulonglong)shdr.sh_offset; +} + +/* + * Dump each 32-bit section header and the data that they reference. + */ +static void +xc_core_dump_Elf32_Shdr(Elf32_Off offset, int store) +{ + Elf32_Shdr shdr; + char name[BUFSIZE]; + int i; + char c; + + if (lseek(xd->xfd, offset, SEEK_SET) != offset) + error(FATAL, + "xc_core_dump_Elf32_Shdr: cannot seek to Elf32_Shdr\n"); + if (read(xd->xfd, &shdr, sizeof(Elf32_Shdr)) != sizeof(Elf32_Shdr)) + error(FATAL, + "xc_core_dump_Elf32_Shdr: cannot read Elf32_Shdr\n"); + + xendump_print("\nElf32_Shdr:\n"); + xendump_print(" sh_name: %lx ", shdr.sh_name); + xendump_print("\"%s\"\n", xc_core_strtab(shdr.sh_name, name)); + xendump_print(" sh_type: %lx ", shdr.sh_type); + switch (shdr.sh_type) + { + case SHT_NULL: + xendump_print("(SHT_NULL)\n"); + break; + case SHT_PROGBITS: + xendump_print("(SHT_PROGBITS)\n"); + break; + case SHT_STRTAB: + xendump_print("(SHT_STRTAB)\n"); + break; + case SHT_NOTE: + xendump_print("(SHT_NOTE)\n"); + break; + default: + xendump_print("\n"); + break; + } + xendump_print(" sh_flags: %lx\n", shdr.sh_flags); + xendump_print(" sh_addr: %lx\n", shdr.sh_addr); + xendump_print(" sh_offset: %lx\n", shdr.sh_offset); + xendump_print(" sh_size: %lx\n", shdr.sh_size); + xendump_print(" sh_link: %lx\n", shdr.sh_link); + xendump_print(" sh_info: %lx\n", shdr.sh_info); + xendump_print(" sh_addralign: %lx\n", shdr.sh_addralign); + xendump_print(" sh_entsize: %lx\n", shdr.sh_entsize); + + if (STREQ(name, ".shstrtab")) { + if (lseek(xd->xfd, xd->xc_core.elf_strtab_offset, SEEK_SET) != + xd->xc_core.elf_strtab_offset) + error(FATAL, + "xc_core_dump_Elf32_Shdr: cannot seek to strtab data\n"); + + xendump_print(" "); + for (i = 0; i < shdr.sh_size; i++) { + if (read(xd->xfd, &c, sizeof(char)) != sizeof(char)) + error(FATAL, + "xc_core_dump_Elf32_Shdr: cannot read strtab data\n"); + if (i && !c) + xendump_print("\n "); + else + xendump_print("%c", c); + } + } + + if (STREQ(name, ".note.Xen")) + xc_core_dump_elfnote((off_t)shdr.sh_offset, + (size_t)shdr.sh_size, store); + + if (!store) + return; + + if (STREQ(name, ".xen_prstatus")) + xd->xc_core.header.xch_ctxt_offset = + (unsigned int)shdr.sh_offset; + + if (STREQ(name, ".xen_shared_info")) + xd->xc_core.shared_info_offset = (off_t)shdr.sh_offset; + + if (STREQ(name, ".xen_pfn")) { + xd->xc_core.header.xch_index_offset = shdr.sh_offset; + xd->flags |= (XC_CORE_NO_P2M|XC_CORE_PFN_CREATE); + } + + if (STREQ(name, ".xen_p2m")) { + xd->xc_core.header.xch_index_offset = shdr.sh_offset; + xd->flags |= XC_CORE_P2M_CREATE; + } + + if (STREQ(name, ".xen_pages")) + xd->xc_core.header.xch_pages_offset = + (unsigned int)shdr.sh_offset; + + if (STREQ(name, ".xen_ia64_mapped_regs")) + xd->xc_core.ia64_mapped_regs_offset = + (off_t)shdr.sh_offset; +} + +/* + * Dump each 64-bit section header and the data that they reference. + */ +static void +xc_core_dump_Elf64_Shdr(Elf64_Off offset, int store) +{ + Elf64_Shdr shdr; + char name[BUFSIZE]; + int i; + char c; + + if (lseek(xd->xfd, offset, SEEK_SET) != offset) + error(FATAL, + "xc_core_dump_Elf64_Shdr: cannot seek to Elf64_Shdr\n"); + if (read(xd->xfd, &shdr, sizeof(Elf64_Shdr)) != sizeof(Elf64_Shdr)) + error(FATAL, + "xc_core_dump_Elf64_Shdr: cannot read Elf64_Shdr\n"); + + xendump_print("\nElf64_Shdr:\n"); + xendump_print(" sh_name: %x ", shdr.sh_name); + xendump_print("\"%s\"\n", xc_core_strtab(shdr.sh_name, name)); + xendump_print(" sh_type: %x ", shdr.sh_type); + switch (shdr.sh_type) + { + case SHT_NULL: + xendump_print("(SHT_NULL)\n"); + break; + case SHT_PROGBITS: + xendump_print("(SHT_PROGBITS)\n"); + break; + case SHT_STRTAB: + xendump_print("(SHT_STRTAB)\n"); + break; + case SHT_NOTE: + xendump_print("(SHT_NOTE)\n"); + break; + default: + xendump_print("\n"); + break; + } + xendump_print(" sh_flags: %lx\n", shdr.sh_flags); + xendump_print(" sh_addr: %lx\n", shdr.sh_addr); + xendump_print(" sh_offset: %lx\n", shdr.sh_offset); + xendump_print(" sh_size: %lx\n", shdr.sh_size); + xendump_print(" sh_link: %x\n", shdr.sh_link); + xendump_print(" sh_info: %x\n", shdr.sh_info); + xendump_print(" sh_addralign: %lx\n", shdr.sh_addralign); + xendump_print(" sh_entsize: %lx\n", shdr.sh_entsize); + + if (STREQ(name, ".shstrtab")) { + if (lseek(xd->xfd, xd->xc_core.elf_strtab_offset, SEEK_SET) != + xd->xc_core.elf_strtab_offset) + error(FATAL, + "xc_core_dump_Elf64_Shdr: cannot seek to strtab data\n"); + + xendump_print(" "); + for (i = 0; i < shdr.sh_size; i++) { + if (read(xd->xfd, &c, sizeof(char)) != sizeof(char)) + error(FATAL, + "xc_core_dump_Elf64_Shdr: cannot read strtab data\n"); + if (i && !c) + xendump_print("\n "); + else + xendump_print("%c", c); + } + } + + if (STREQ(name, ".note.Xen")) + xc_core_dump_elfnote((off_t)shdr.sh_offset, + (size_t)shdr.sh_size, store); + + if (!store) + return; + + if (STREQ(name, ".xen_prstatus")) + xd->xc_core.header.xch_ctxt_offset = + (unsigned int)shdr.sh_offset; + + if (STREQ(name, ".xen_shared_info")) + xd->xc_core.shared_info_offset = (off_t)shdr.sh_offset; + + if (STREQ(name, ".xen_pfn")) { + xd->xc_core.header.xch_index_offset = shdr.sh_offset; + xd->flags |= (XC_CORE_NO_P2M|XC_CORE_PFN_CREATE); + } + + if (STREQ(name, ".xen_p2m")) { + xd->xc_core.header.xch_index_offset = shdr.sh_offset; + xd->flags |= XC_CORE_P2M_CREATE; + } + + if (STREQ(name, ".xen_pages")) + xd->xc_core.header.xch_pages_offset = + (unsigned int)shdr.sh_offset; + + if (STREQ(name, ".xen_ia64_mapped_regs")) + xd->xc_core.ia64_mapped_regs_offset = + (off_t)shdr.sh_offset; +} + +/* + * Return the string found at the specified index into + * the dumpfile's strtab. + */ +static char * +xc_core_strtab(uint32_t index, char *buf) +{ + off_t offset; + int i; + + offset = xd->xc_core.elf_strtab_offset + index; + + if (lseek(xd->xfd, offset, SEEK_SET) != offset) + error(FATAL, + "xc_core_strtab: cannot seek to Elf64_Shdr\n"); + + BZERO(buf, BUFSIZE); + i = 0; + + while (read(xd->xfd, &buf[i], sizeof(char)) == sizeof(char)) { + if (buf[i] == NULLCHAR) + break; + i++; + } + + return buf; +} + + +/* + * Dump the array of elfnote structures, storing relevant info + * when requested during initialization. This function is + * common to both 32-bit and 64-bit ELF files. + */ +static void +xc_core_dump_elfnote(off_t sh_offset, size_t sh_size, int store) +{ + int i, lf, index; + char *notes_buffer; + struct elfnote *elfnote; + ulonglong *data; + struct xen_dumpcore_elfnote_header_desc *elfnote_header; + struct xen_dumpcore_elfnote_format_version_desc *format_version; + + elfnote_header = NULL; + + if (!(notes_buffer = (char *)malloc(sh_size))) + error(FATAL, "cannot malloc notes space."); + + if (lseek(xd->xfd, sh_offset, SEEK_SET) != sh_offset) + error(FATAL, + "xc_core_dump_elfnote: cannot seek to sh_offset\n"); + + if (read(xd->xfd, notes_buffer, sh_size) != sh_size) + error(FATAL, + "xc_core_dump_elfnote: cannot read elfnote data\n"); + + for (index = 0; index < sh_size; ) { + elfnote = (struct elfnote *)¬es_buffer[index]; + xendump_print(" namesz: %d\n", elfnote->namesz); + xendump_print(" descz: %d\n", elfnote->descsz); + xendump_print(" type: %x ", elfnote->type); + switch (elfnote->type) + { + case XEN_ELFNOTE_DUMPCORE_NONE: + xendump_print("(XEN_ELFNOTE_DUMPCORE_NONE)\n"); + break; + case XEN_ELFNOTE_DUMPCORE_HEADER: + xendump_print("(XEN_ELFNOTE_DUMPCORE_HEADER)\n"); + elfnote_header = (struct xen_dumpcore_elfnote_header_desc *) + (elfnote+1); + break; + case XEN_ELFNOTE_DUMPCORE_XEN_VERSION: + xendump_print("(XEN_ELFNOTE_DUMPCORE_XEN_VERSION)\n"); + break; + case XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION: + xendump_print("(XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION)\n"); + format_version = (struct xen_dumpcore_elfnote_format_version_desc *) + (elfnote+1); + break; + default: + xendump_print("(unknown)\n"); + break; + } + xendump_print(" name: %s\n", elfnote->name); + + data = (ulonglong *)(elfnote+1); + for (i = lf = 0; i < elfnote->descsz/sizeof(ulonglong); i++) { + if (((i%2)==0)) { + xendump_print("%s ", + i ? "\n" : ""); + lf++; + } else + lf = 0; + xendump_print("%016llx ", *data++); + } + if (!elfnote->descsz) + xendump_print(" (empty)"); + xendump_print("\n"); + + index += sizeof(struct elfnote) + elfnote->descsz; + } + + if (!store) + return; + + if (elfnote_header) { + xd->xc_core.header.xch_magic = elfnote_header->xch_magic; + xd->xc_core.header.xch_nr_vcpus = elfnote_header->xch_nr_vcpus; + xd->xc_core.header.xch_nr_pages = elfnote_header->xch_nr_pages; + xd->page_size = elfnote_header->xch_page_size; + } + + if (format_version) { + switch (format_version->version) + { + case FORMAT_VERSION_0000000000000001: + break; + default: + error(WARNING, + "unsupported xen dump-core format version: %016llx\n", + format_version->version); + } + xd->xc_core.format_version = format_version->version; + } + +} + +/* + * Initialize the batching list for the .xen_p2m or .xen_pfn + * arrays. + */ +static void +xc_core_elf_pfn_init(void) +{ + int i, c, chunk; + off_t offset; + struct xen_dumpcore_p2m p2m; + uint64_t pfn; + + switch (xd->flags & (XC_CORE_ELF|XC_CORE_NO_P2M)) + { + case (XC_CORE_ELF|XC_CORE_NO_P2M): + chunk = xd->xc_core.header.xch_nr_pages/INDEX_PFN_COUNT; + + for (i = c = 0; i < INDEX_PFN_COUNT; i++, c += chunk) { + offset = (off_t)xd->xc_core.header.xch_index_offset + + (off_t)(c * sizeof(uint64_t)); + + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, + "cannot lseek to page index %d\n", c); + if (read(xd->xfd, &pfn, sizeof(uint64_t)) != + sizeof(uint64_t)) + error(FATAL, + "cannot read page index %d\n", c); + + xd->xc_core.elf_index_pfn[i].index = c; + xd->xc_core.elf_index_pfn[i].pfn = (ulong)pfn; + } + break; + + case XC_CORE_ELF: + chunk = xd->xc_core.header.xch_nr_pages/INDEX_PFN_COUNT; + + for (i = c = 0; i < INDEX_PFN_COUNT; i++, c += chunk) { + offset = (off_t)xd->xc_core.header.xch_index_offset + + (off_t)(c * sizeof(struct xen_dumpcore_p2m)); + + if (lseek(xd->xfd, offset, SEEK_SET) == -1) + error(FATAL, + "cannot lseek to page index %d\n", c); + if (read(xd->xfd, &p2m, sizeof(struct xen_dumpcore_p2m)) != + sizeof(struct xen_dumpcore_p2m)) + error(FATAL, + "cannot read page index %d\n", c); + + xd->xc_core.elf_index_pfn[i].index = c; + xd->xc_core.elf_index_pfn[i].pfn = (ulong)p2m.pfn; + } + break; + } +} + --- crash-4.0-3.20/unwind.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/unwind.c 2007-03-15 08:16:14.000000000 -0500 @@ -1674,8 +1674,13 @@ unw_get_sp(info, &sp); unw_get_bsp(info, &bsp); - if (ip < GATE_ADDR + PAGE_SIZE) - break; + if (XEN_HYPER_MODE()) { + if (!IS_KVADDR(ip)) + break; + } else { + if (ip < GATE_ADDR + PAGE_SIZE) + break; + } if ((sm = value_search(ip, NULL))) name = sm->name; @@ -1747,7 +1752,8 @@ if (unw_switch_from_osinit_v3(info, bt, "INIT") == FALSE) break; } else { - unw_switch_from_osinit_v2(info, bt); + if (unw_switch_from_osinit_v2(info, bt) == FALSE) + break; frame++; goto restart; } --- crash-4.0-3.20/xen_hyper_global_data.c 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/xen_hyper_global_data.c 2007-03-15 08:19:15.000000000 -0500 @@ -169,7 +169,41 @@ char *xen_hyper_help_log[] = { "log", "dump system message buffer", +" ", " This command dumps the xen conring contents in chronological order." , +" ", +"EXAMPLES", +" Dump the Xen message buffer:\n", +" %s> log", +" __ __ _____ ___ _ _ _", +" \\ \\/ /___ _ __ |___ / / _ \\ _ _ _ __ ___| |_ __ _| |__ | | ___", +" \\ // _ \\ '_ \\ |_ \\| | | |__| | | | '_ \\/ __| __/ _` | '_ \\| |/ _ \\", +" / \\ __/ | | | ___) | |_| |__| |_| | | | \\__ \\ || (_| | |_) | | __/", +" /_/\\_\\___|_| |_| |____(_)___/ \\__,_|_| |_|___/\\__\\__,_|_.__/|_|\\___|", +" ", +" http://www.cl.cam.ac.uk/netos/xen", +" University of Cambridge Computer Laboratory", +" ", +" Xen version 3.0-unstable (damm@) (gcc version 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0,", +" pie-8.7.9)) Wed Dec 6 17:34:32 JST 2006", +" Latest ChangeSet: unavailable", +" ", +" (XEN) Console output is synchronous.", +" (XEN) Command line: 12733-i386-pae/xen.gz console=com1 sync_console conswitch=bb com1", +" =115200,8n1,0x3f8 dom0_mem=480000 crashkernel=64M@32M", +" (XEN) Physical RAM map:", +" (XEN) 0000000000000000 - 0000000000098000 (usable)", +" (XEN) 0000000000098000 - 00000000000a0000 (reserved)", +" (XEN) 00000000000f0000 - 0000000000100000 (reserved)", +" (XEN) 0000000000100000 - 000000003f7f0000 (usable)", +" (XEN) 000000003f7f0000 - 000000003f7f3000 (ACPI NVS)", +" (XEN) 000000003f7f3000 - 000000003f800000 (ACPI data)", +" (XEN) 00000000e0000000 - 00000000f0000000 (reserved)", +" (XEN) 00000000fec00000 - 0000000100000000 (reserved)", +" (XEN) Kdump: 64MB (65536kB) at 0x2000000", +" (XEN) System RAM: 1015MB (1039904kB)", +" (XEN) ACPI: RSDP (v000 XPC ) @ 0x000f9250", +" ...", NULL }; --- crash-4.0-3.20/defs.h 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/defs.h 2007-03-16 13:37:20.000000000 -0500 @@ -754,6 +754,7 @@ #define INIT (0x4000000) #define VM_4_LEVEL (0x2000000) #define MCA (0x1000000) +#define PAE (0x800000) extern struct machdep_table *machdep; @@ -1282,6 +1283,7 @@ long zone_pages_min; long zone_pages_low; long zone_pages_high; + long zone_vm_stat; long neighbour_next; long neighbour_primary_key; long neighbour_ha; @@ -1938,6 +1940,14 @@ #define SWP_TYPE(entry) (((entry) >> 1) & 0x3f) #define SWP_OFFSET(entry) ((entry) >> 8) +#define __swp_type_PAE(entry) (((entry) >> 32) & 0x1f) +#define __swp_type_nonPAE(entry) (((entry) >> 1) & 0x1f) +#define __swp_offset_PAE(entry) (((entry) >> 32) >> 5) +#define __swp_offset_nonPAE(entry) ((entry) >> 8) +#define __swp_type(entry) (machdep->flags & PAE ? \ + __swp_type_PAE(entry) : __swp_type_nonPAE(entry)) +#define __swp_offset(entry) (machdep->flags & PAE ? \ + __swp_offset_PAE(entry) : __swp_offset_nonPAE(entry)) #define TIF_SIGPENDING (2) @@ -2083,6 +2093,8 @@ #define SWP_TYPE(entry) (((entry) >> 1) & 0x3f) #define SWP_OFFSET(entry) ((entry) >> 8) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define TIF_SIGPENDING (2) @@ -2152,6 +2164,8 @@ #define SWP_TYPE(entry) (((entry) >> 32) & 0xff) #define SWP_OFFSET(entry) ((entry) >> 40) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define TIF_SIGPENDING (2) @@ -2185,6 +2199,8 @@ #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f) #define SWP_OFFSET(entry) ((entry) >> 8) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define TIF_SIGPENDING (2) @@ -2372,6 +2388,8 @@ #define SWP_TYPE(entry) (((entry) >> 1) & 0xff) #define SWP_OFFSET(entry) ((entry) >> 9) +#define __swp_type(entry) ((entry >> 2) & 0x7f) +#define __swp_offset(entry) ((entry << 1) >> 10) #define TIF_SIGPENDING (1) @@ -2461,6 +2479,8 @@ #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f) #define SWP_OFFSET(entry) ((entry) >> 8) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define MSR_PR_LG 14 /* Problem State / Privilege Level */ /* Used to find the user or kernel-mode frame*/ @@ -2489,6 +2509,8 @@ #define SWP_TYPE(entry) (((entry) >> 2) & 0x1f) #define SWP_OFFSET(entry) ((((entry) >> 11) & 0xfffffffe) | \ (((entry) >> 7) & 0x1)) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define TIF_SIGPENDING (2) @@ -2509,6 +2531,8 @@ #define SWP_TYPE(entry) (((entry) >> 2) & 0x1f) #define SWP_OFFSET(entry) ((((entry) >> 11) & 0xfffffffffffffffe) | \ (((entry) >> 7) & 0x1)) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #define TIF_SIGPENDING (2) @@ -2518,6 +2542,8 @@ #define SWP_TYPE(entry) (error("PLATFORM_SWP_TYPE: TBD\n")) #define SWP_OFFSET(entry) (error("PLATFORM_SWP_OFFSET: TBD\n")) +#define __swp_type(entry) SWP_TYPE(entry) +#define __swp_offset(entry) SWP_OFFSET(entry) #endif /* PLATFORM */ @@ -3553,7 +3579,6 @@ void x86_display_idt_table(void); #define display_idt_table() x86_display_idt_table() #define KSYMS_START (0x1) -#define PAE (0x2) void x86_dump_eframe_common(struct bt_info *bt, ulong *, int); char *x86_function_called_by(ulong); struct syment *x86_jmp_error_code(ulong); @@ -3747,6 +3772,8 @@ #define display_idt_table() \ error(FATAL, "-d option is not applicable to PowerPC architecture\n") #define KSYMS_START (0x1) +/* This should match PPC_FEATURE_BOOKE from include/asm-powerpc/cputable.h */ +#define CPU_BOOKE (0x00008000) #endif /* --- crash-4.0-3.20/xendump.h 2007-03-16 14:37:29.000000000 -0500 +++ crash-4.0-3.21/xendump.h 2007-03-14 10:16:41.000000000 -0500 @@ -12,6 +12,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include +#include #define XC_SAVE_SIGNATURE "LinuxGuestRecord" #define XC_CORE_MAGIC 0xF00FEBED @@ -34,9 +35,22 @@ ulong pfn; ulong cnt; }; - #define PFN_TO_OFFSET_CACHE_ENTRIES (5000) +struct elf_index_pfn { + ulong index; + ulong pfn; +}; +#define INDEX_PFN_COUNT (128) + +struct last_batch { + ulong index; + ulong start; + ulong end; + ulong accesses; + ulong duplicates; +}; + struct xendump_data { ulong flags; /* XENDUMP_LOCAL, plus anything else... */ int xfd; @@ -54,6 +68,15 @@ int p2m_frames; ulong *p2m_frame_index_list; struct xc_core_header header; + int elf_class; + uint64_t format_version; + off_t elf_strtab_offset; + off_t shared_info_offset; + off_t ia64_mapped_regs_offset; + struct elf_index_pfn elf_index_pfn[INDEX_PFN_COUNT]; + struct last_batch last_batch; + Elf32_Ehdr *elf32; + Elf64_Ehdr *elf64; } xc_core; struct xc_save_data { @@ -77,11 +100,13 @@ }; #define XC_SAVE (XENDUMP_LOCAL << 1) -#define XC_CORE (XENDUMP_LOCAL << 2) -#define XC_CORE_P2M_INIT (XENDUMP_LOCAL << 3) -#define XC_CORE_NO_P2MM (XENDUMP_LOCAL << 4) -#define XC_SAVE_IA64 (XENDUMP_LOCAL << 5) -#define XC_CORE_64BIT_HOST (XENDUMP_LOCAL << 6) +#define XC_CORE_ORIG (XENDUMP_LOCAL << 2) +#define XC_CORE_P2M_CREATE (XENDUMP_LOCAL << 3) +#define XC_CORE_PFN_CREATE (XENDUMP_LOCAL << 4) +#define XC_CORE_NO_P2M (XENDUMP_LOCAL << 5) +#define XC_SAVE_IA64 (XENDUMP_LOCAL << 6) +#define XC_CORE_64BIT_HOST (XENDUMP_LOCAL << 7) +#define XC_CORE_ELF (XENDUMP_LOCAL << 8) #define MACHINE_BYTE_ORDER() \ (machine_type("X86") || \ @@ -116,3 +141,37 @@ uint32_t hypercall_imm; /* Break imm for Xen hypercalls. */ /* #endif */ } xen_domctl_arch_setup_t; + +/* + * xc_core ELF note, which differs from the standard Elf[32|64]_Nhdr + * structure by the additional name field. + */ +struct elfnote { + uint32_t namesz; + uint32_t descsz; + uint32_t type; + char name[4]; +}; + +#define XEN_ELFNOTE_DUMPCORE_NONE 0x2000000 +#define XEN_ELFNOTE_DUMPCORE_HEADER 0x2000001 +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION 0x2000002 +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION 0x2000003 + +struct xen_dumpcore_elfnote_header_desc { + uint64_t xch_magic; + uint64_t xch_nr_vcpus; + uint64_t xch_nr_pages; + uint64_t xch_page_size; +}; + +#define FORMAT_VERSION_0000000000000001 0x0000000000000001ULL + +struct xen_dumpcore_elfnote_format_version_desc { + uint64_t version; +}; + +struct xen_dumpcore_p2m { + uint64_t pfn; + uint64_t gmfn; +};