From 4b83b27fea586d38b52dfea077c381a4249aa477 Mon Sep 17 00:00:00 2001 From: John Dyson Date: Wed, 26 Jun 1996 05:52:15 +0000 Subject: [PATCH] Fix a problem that caused system crashes after physio. This problem was due to non-aligned 64K transfers taking 17 pages. We currently do not support >16 page transfers. The transfer is unfortunately truncated, but since buffers are usually malloced, this is a problem only once in a while. Savecore is a culprit, but tar/cpio usually aren't. This is NOT the final fix (which is likely a bouncing scheme), but will at least keep the system from crashing. --- sys/kern/kern_physio.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 7f8324b36db8..ed4920c64ff1 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: kern_physio.c,v 1.15 1995/12/07 12:46:46 davidg Exp $ + * $Id: kern_physio.c,v 1.16 1995/12/13 15:12:59 julian Exp $ */ #include @@ -78,13 +78,13 @@ physio(strategy, bp, dev, rw, minp, uio) while( uio->uio_iov[i].iov_len) { bp->b_bcount = uio->uio_iov[i].iov_len; + bp->b_flags = B_BUSY | B_PHYS | B_CALL | bufflags; + bp->b_iodone = physwakeup; + bp->b_data = uio->uio_iov[i].iov_base; bp->b_bcount = minp( bp); if( minp != minphys) bp->b_bcount = minphys( bp); bp->b_bufsize = bp->b_bcount; - bp->b_flags = B_BUSY | B_PHYS | B_CALL | bufflags; - bp->b_iodone = physwakeup; - bp->b_data = uio->uio_iov[i].iov_base; /* * pass in the kva from the physical buffer * for the temporary kernel mapping. @@ -164,9 +164,14 @@ doerror: u_int minphys(struct buf *bp) { + u_int maxphys = MAXPHYS; - if( bp->b_bcount > MAXPHYS) { - bp->b_bcount = MAXPHYS; + if( ((vm_offset_t) bp->b_data) & PAGE_MASK) { + maxphys = MAXPHYS - PAGE_SIZE; + } + + if( bp->b_bcount > maxphys) { + bp->b_bcount = maxphys; } return bp->b_bcount; }