From: claudio Date: Thu, 7 Mar 2024 15:01:53 +0000 (+0000) Subject: In _bus_dmamap_load_mbuf() ensure that for large mbuf m_len values X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=deb7b0be1b2a387092b27c5263ee89d7ae4b91bc;p=openbsd In _bus_dmamap_load_mbuf() ensure that for large mbuf m_len values the incr value is rounded to the page boundary. This can happen when m_defrag() packs a TSO packet into one big mbuf cluster. Also fix _bus_dmamap_load_uio() which has the same min(buflen, NBPG); logic. bus_dmamap_load_uio() is unsued and will be removed after unlock. OK miod@ bluhm@ kettenis@ --- diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index 3e8de4190a7..135cf08c58f 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.208 2024/02/10 07:10:13 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.209 2024/03/07 15:01:53 claudio Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1014,7 +1014,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, paddr_t pa; long incr; - incr = min(buflen, NBPG); + incr = min(buflen, + PAGE_SIZE - ((u_long)vaddr & PGOFSET)); if (pmap_extract(pmap_kernel(), vaddr, &pa) == FALSE) { #ifdef DIAGNOSTIC @@ -1100,7 +1101,9 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, paddr_t pa; long incr; - incr = min(buflen, NBPG); + incr = min(buflen, + PAGE_SIZE - ((u_long)vaddr & PGOFSET)); + (void) pmap_extract(pmap_kernel(), vaddr, &pa); buflen -= incr; vaddr += incr;