Date: Wed, 22 Jun 2005 17:40:57 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 78813 for review Message-ID: <200506221740.j5MHevcl057977@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=78813 Change 78813 by peter@peter_overcee on 2005/06/22 17:40:51 Try and include the kernel code+data+bss in the crashdump. We could use the bios SMAP for the data source, but then we need to re-implement the Maxmem stuff to avoid dumping unused stuff. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/dump_machdep.c#11 edit .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#126 edit .. //depot/projects/hammer/sys/amd64/include/pmap.h#53 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/dump_machdep.c#11 (text+ko) ==== @@ -51,7 +51,7 @@ struct md_pa { vm_paddr_t md_start; - vm_paddr_t md_end; + vm_paddr_t md_size; }; typedef int callback_t(struct md_pa *, int, void *); @@ -63,15 +63,26 @@ static char buffer[DEV_BSIZE]; static size_t fragsz; +/* 20 phys_avail entry pairs correspond to 10 md_pa's */ +static struct md_pa dump_avail[10]; + static struct md_pa * md_pa_first(void) { - struct md_pa *mdp; + int n; - mdp = (struct md_pa *)&phys_avail[0]; - if (mdp->md_start == 0 && mdp->md_end == 0) - mdp = NULL; - return (mdp); + bzero(&dump_avail, sizeof(dump_avail)); + for (n = 0; n < sizeof(dump_avail) / sizeof(dump_avail[0]); n++) { + if (phys_avail[n * 2] == 0 && phys_avail[n * 2 + 1] == 0) + break; + dump_avail[n].md_start = phys_avail[n * 2]; + dump_avail[n].md_size = phys_avail[n * 2 + 1] - phys_avail[n * 2]; + if (dump_avail[n].md_start == kernphys[1]) { + dump_avail[n].md_start = kernphys[0]; + dump_avail[n].md_size += kernphys[1] - kernphys[0]; + } + } + return (&dump_avail[0]); } static struct md_pa * @@ -79,7 +90,7 @@ { mdp++; - if (mdp->md_start == 0 && mdp->md_end == 0) + if (mdp->md_start == 0 && mdp->md_size == 0) mdp = NULL; return (mdp); } @@ -159,7 +170,7 @@ counter = 0; /* Update twiddle every 16MB */ twiddle = 0; va = 0; - pgs = (mdp->md_end - mdp->md_start) / PAGE_SIZE; + pgs = mdp->md_size / PAGE_SIZE; pa = mdp->md_start; printf(" chunk %d: %ld pages ", seqnr, (long)pgs); @@ -202,7 +213,7 @@ uint64_t size; int error; - size = mdp->md_end - mdp->md_start; + size = mdp->md_size; bzero(&phdr, sizeof(phdr)); phdr.p_type = PT_LOAD; phdr.p_flags = PF_R; /* XXX */ @@ -223,7 +234,7 @@ { uint64_t *sz = (uint64_t*)arg; - *sz += (uint64_t)(mdp->md_end - mdp->md_start); + *sz += (uint64_t)mdp->md_size; return (0); } @@ -290,7 +301,7 @@ dumplo = di->mediaoffset + di->mediasize - dumpsize; dumplo -= sizeof(kdh) * 2; - mkdumpheader(&kdh, KERNELDUMP_IA64_VERSION, dumpsize, di->blocksize); + mkdumpheader(&kdh, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize); printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20, ehdr.e_phnum); ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#126 (text+ko) ==== @@ -848,6 +848,8 @@ u_int basemem; +vm_paddr_t kernphys[2]; + /* * Populate the (physmap) array with base/bound pairs describing the * available physical memory in the system, then test this memory and @@ -990,6 +992,12 @@ dcons_addr = 0; /* + * Keep track of where the kernel lives for crash dumps. + */ + kernphys[0] = 0x100000; + kernphys[1] = first; + + /* * physmap is in bytes, so when converting to page boundaries, * round up the start address and round down the end address. */ @@ -1006,7 +1014,7 @@ /* * block out kernel memory as not available. */ - if (pa >= 0x100000 && pa < first) + if (pa >= kernphys[0] && pa < kernphys[1]) continue; /* ==== //depot/projects/hammer/sys/amd64/include/pmap.h#53 (text+ko) ==== @@ -282,6 +282,7 @@ extern pt_entry_t *CMAP1; extern vm_paddr_t avail_end; extern vm_paddr_t phys_avail[]; +extern vm_paddr_t kernphys[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506221740.j5MHevcl057977>