From owner-p4-projects@FreeBSD.ORG Wed Jun 22 17:40:59 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A36C816A420; Wed, 22 Jun 2005 17:40:58 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66DCB16A41C for ; Wed, 22 Jun 2005 17:40:58 +0000 (GMT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 481F643D1F for ; Wed, 22 Jun 2005 17:40:58 +0000 (GMT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j5MHewfA057980 for ; Wed, 22 Jun 2005 17:40:58 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j5MHevcl057977 for perforce@freebsd.org; Wed, 22 Jun 2005 17:40:57 GMT (envelope-from peter@freebsd.org) Date: Wed, 22 Jun 2005 17:40:57 GMT Message-Id: <200506221740.j5MHevcl057977@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 78813 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2005 17:40:59 -0000 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;