Subject: Re: bug fix for cats core dumping
To: None <Richard.Earnshaw@buzzard.freeserve.co.uk>
From: Chris Gilbert <chris@dokein.co.uk>
List: port-arm
Date: 02/04/2003 00:25:54
This is a multi-part message in MIME format.

--Multipart_Tue__4_Feb_2003_00:25:54_+0000_081cfc00
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Sun, 17 Nov 2002 23:57:08 +0000
Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk> wrote:

> > Hi,
> > 
> > Not sure if other arm archs are suffering issues dumping kernel
> > cores, but attached it a patch that fixed it for my cats box (well
> > it doesn't hang any more when doing a dump (or it didn't for the one
> > go I tried)
> > 
> > however I'm wondering if someone can check that it's sane, before I
> > submit it.
> 
> What about cacheing?  can we be sure that the cache has been cleaned 
> before we potentially doubly map each page?  Otherwise we won't really
> be dumping what the processor sees.

Meant to sort this out sooner, but time etc...

How about the attached?  I believe it does the right thing now, re
flushing cache to memory.

Cheers,
Chris

--Multipart_Tue__4_Feb_2003_00:25:54_+0000_081cfc00
Content-Type: text/plain;
 name="stubs.c.coredump.diff"
Content-Disposition: attachment;
 filename="stubs.c.coredump.diff"
Content-Transfer-Encoding: 7bit

Index: stubs.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/stubs.c,v
retrieving revision 1.11
diff -u -p -r1.11 stubs.c
--- stubs.c	2002/12/28 20:40:21	1.11
+++ stubs.c	2003/02/03 23:55:00
@@ -126,6 +126,8 @@ dumpsys()
 
 	/* Save registers. */
 	savectx(&dumppcb);
+	/* flush everything out of caches */
+	cpu_dcache_wbinv_all();
 
 	if (dumpdev == NODEV)
 		return;
@@ -164,9 +166,13 @@ dumpsys()
 		    + (bootconfig.dram[block].pages * NBPG)); addr += NBPG) {
 		    	if ((len % (1024*1024)) == 0)
 		    		printf("%d ", len / (1024*1024));
-	                pmap_map(dumpspace, addr, addr + NBPG, VM_PROT_READ);
+			pmap_kenter_pa(dumpspace, addr, VM_PROT_READ);
+			pmap_update(pmap_kernel());
+
 			error = (*bdev->d_dump)(dumpdev,
 			    blkno, (caddr_t) dumpspace, NBPG);
+			pmap_kremove(dumpspace, NBPG);
+			pmap_update(pmap_kernel());
 			if (error) break;
 			blkno += btodb(NBPG);
 			len += NBPG;

--Multipart_Tue__4_Feb_2003_00:25:54_+0000_081cfc00--