From: deraadt Date: Mon, 24 Apr 2000 04:54:19 +0000 (+0000) Subject: use pmap_extract() instead of vtophys(); art X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d2479c78f6e61d5dc7e17c1f1bf7cad5b7236dbc;p=openbsd use pmap_extract() instead of vtophys(); art --- diff --git a/sys/crypto/mbuf.c b/sys/crypto/mbuf.c index 44bb60ec9e5..32a714786b6 100644 --- a/sys/crypto/mbuf.c +++ b/sys/crypto/mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.c,v 1.2 2000/04/20 13:05:30 art Exp $ */ +/* $OpenBSD: mbuf.c,v 1.3 2000/04/24 04:54:19 deraadt Exp $ */ /* * Copyright (c) 1999 Theo de Raadt @@ -49,50 +49,41 @@ mbuf2pages(m, np, pp, lp, maxp, nicep) int maxp; int *nicep; { - struct mbuf *m0; int npa = 0, tlen = 0; - /* generate a [pa,len] array from an mbuf */ - for (m0 = m; m; m = m->m_next) { - void *va; - long pg, npg; - int len, off; + for (; m != NULL; m = m->m_next) { + vaddr_t va, off; + paddr_t pa; + int len; - if (m->m_len == 0) + if ((len = m->m_len) == 0) continue; - len = m->m_len; tlen += len; - va = m->m_data; + va = (vaddr_t)m->m_data; + off = va & PAGE_MASK; + va -= off; - lp[npa] = len; - pp[npa] = vtophys(va); - pg = pp[npa] & ~PAGE_MASK; - off = (long)va & PAGE_MASK; - - while (len + off > PAGE_SIZE) { - va = va + PAGE_SIZE - off; - npg = vtophys(va); - if (npg != pg) { - /* FUCKED UP condition */ - if (++npa > maxp) - return (0); - continue; - } - lp[npa] = PAGE_SIZE - off; - off = 0; +next_page: + pa = pmap_extract(pmap_kernel(), va); + if (pa == 0) + panic("mbuf2pages: pa == 0"); - if (++npa > maxp) - return (0); + pa += off; - lp[npa] = len - (PAGE_SIZE - off); - len -= lp[npa]; - pp[npa] = vtophys(va); - } + lp[npa] = len; + pp[npa] = pa; - if (++npa == maxp) + if (++npa > maxp) return (0); - } + if (len + off > PAGE_SIZE) { + lp[npa - 1] = PAGE_SIZE - off; + va += PAGE_SIZE; + len -= PAGE_SIZE; + goto next_page; + } + } + if (nicep) { int nice = 1; int i;