From: kettenis Date: Mon, 21 Feb 2022 19:18:52 +0000 (+0000) Subject: Convert KVA allocation to km_alloc(9). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7a487ff54c7d56850fd5b2b6a7439ed34ce5a1e9;p=openbsd Convert KVA allocation to km_alloc(9). ok mpi@ --- diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index e48e1ba9015..d887a9d308d 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.71 2021/05/16 06:20:29 jsg Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.72 2022/02/21 19:18:52 kettenis Exp $ */ /* $NetBSD: vm_machdep.c,v 1.61 1996/05/03 19:42:35 christos Exp $ */ /*- @@ -140,8 +140,15 @@ kvtop(caddr_t addr) return((int)pa); } +struct kmem_va_mode kv_physwait = { + .kv_map = &phys_map, + .kv_wait = 1, +}; + /* - * Map an user IO request into kernel virtual address space. + * Map a user I/O request into kernel virtual address space. + * Note: the pages are already locked by uvm_vslock(), so we + * do not need to pass an access_type to pmap_enter(). */ void vmapbuf(struct buf *bp, vsize_t len) @@ -154,7 +161,7 @@ vmapbuf(struct buf *bp, vsize_t len) faddr = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data)); off = (vaddr_t)bp->b_data - faddr; len = round_page(off + len); - taddr= uvm_km_valloc_wait(phys_map, len); + taddr = (vaddr_t)km_alloc(len, &kv_physwait, &kp_none, &kd_waitok); bp->b_data = (caddr_t)(taddr + off); /* * The region is locked, so we expect that pmap_pte() will return @@ -169,7 +176,7 @@ vmapbuf(struct buf *bp, vsize_t len) * mapping is removed). */ while (len) { - pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), + (void) pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), faddr, &fpa); pmap_kenter_pa(taddr, fpa, PROT_READ | PROT_WRITE); faddr += PAGE_SIZE; @@ -180,8 +187,7 @@ vmapbuf(struct buf *bp, vsize_t len) } /* - * Free the io map PTEs associated with this IO operation. - * We also invalidate the TLB entries and restore the original b_addr. + * Unmap a previously-mapped user I/O request. */ void vunmapbuf(struct buf *bp, vsize_t len) @@ -195,7 +201,7 @@ vunmapbuf(struct buf *bp, vsize_t len) len = round_page(off + len); pmap_kremove(addr, len); pmap_update(pmap_kernel()); - uvm_km_free_wakeup(phys_map, addr, len); + km_free((void *)addr, len, &kv_physwait, &kp_none); bp->b_data = bp->b_saveaddr; bp->b_saveaddr = NULL; }