Module Name: src Committed By: martin Date: Sat Jan 7 14:56:44 UTC 2023
Modified Files: src/sys/arch/m68k/m68k [netbsd-10]: bus_dma.c Log Message: Pull up following revision(s) (requested by tsutsui in ticket #39): sys/arch/m68k/m68k/bus_dma.c: revision 1.39 Fix out of bounds invalidate (and writeback) in bus_dmamap_sync(9) ops. Detected by the POOL_REDZONE check in sys/kern/subr_pool.c that has been activated if options DIAGNOSTIC is enabled on post netbsd-9. The extra invalidate on DMASYNC_PREREAD op discards redzone pattern data allocated right after an mbuf cluster without proper writeback to memory so that it triggers false redzone assertions on freeing mbufs. This bug was my botch in rev 1.25 committed 15 years ago. (sigh) Fixes PR/57107 (kernel panic on -current when configuring network with sn(4) on mac68k), as actually the bus_dma(9) op changes in the past days were introduced for mac68k sn(4) improvements by using the MI SONIC (src/sys/dev/ic/dp83932.c) driver. https://mail-index.netbsd.org/port-mac68k/2007/06/01/0001.html To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/arch/m68k/m68k/bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/m68k/m68k/bus_dma.c diff -u src/sys/arch/m68k/m68k/bus_dma.c:1.38 src/sys/arch/m68k/m68k/bus_dma.c:1.38.4.1 --- src/sys/arch/m68k/m68k/bus_dma.c:1.38 Tue Jul 26 20:08:55 2022 +++ src/sys/arch/m68k/m68k/bus_dma.c Sat Jan 7 14:56:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.38 2022/07/26 20:08:55 andvar Exp $ */ +/* $NetBSD: bus_dma.c,v 1.38.4.1 2023/01/07 14:56:44 martin Exp $ */ /* * This file was taken from alpha/common/bus_dma.c @@ -41,7 +41,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.38 2022/07/26 20:08:55 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.38.4.1 2023/01/07 14:56:44 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -494,7 +494,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm } /* flush cachelines per 128bytes */ - while ((p < e) && (p & PAGE_MASK) != 0) { + while ((p + CACHELINE_SIZE * 8 <= e) && + (p & PAGE_MASK) != 0) { DCFL(p); p += CACHELINE_SIZE; DCFL(p); @@ -570,7 +571,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm } /* purge cachelines per 128bytes */ - while ((p < e) && (p & PAGE_MASK) != 0) { + while ((p + CACHELINE_SIZE * 8 <= e) && + (p & PAGE_MASK) != 0) { DCPL(p); p += CACHELINE_SIZE; DCPL(p);