Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/common There is already a fast-path in pmap_e...



details:   https://anonhg.NetBSD.org/src/rev/5514ffa3e0b9
branches:  trunk
changeset: 1022449:5514ffa3e0b9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Jul 19 16:25:54 2021 +0000

description:
There is already a fast-path in pmap_extract() for the kernel pmap, so
don't bother doing a conditional for kernel vs. user-space here.

KASSERT() that pmap_extract() succeeds; it is a programming error if
it does not, and it's not a great idea to insert a garbage address
into the SGMAP page table.

diffstat:

 sys/arch/alpha/common/bus_dma.c       |  12 ++++++------
 sys/arch/alpha/common/sgmap_typedep.c |  17 +++++++----------
 2 files changed, 13 insertions(+), 16 deletions(-)

diffs (92 lines):

diff -r fbc8cc72849d -r 5514ffa3e0b9 sys/arch/alpha/common/bus_dma.c
--- a/sys/arch/alpha/common/bus_dma.c   Mon Jul 19 14:49:45 2021 +0000
+++ b/sys/arch/alpha/common/bus_dma.c   Mon Jul 19 16:25:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $ */
+/* $NetBSD: bus_dma.c,v 1.73 2021/07/19 16:25:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.73 2021/07/19 16:25:54 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -138,6 +138,7 @@
        bus_addr_t curaddr, lastaddr, baddr, bmask;
        vaddr_t vaddr = (vaddr_t)buf;
        int seg;
+       bool address_is_valid __diagused;
 
        lastaddr = *lastaddrp;
        bmask = ~(map->_dm_boundary - 1);
@@ -146,10 +147,9 @@
                /*
                 * Get the physical address for this segment.
                 */
-               if (!VMSPACE_IS_KERNEL_P(vm))
-                       (void) pmap_extract(vm->vm_map.pmap, vaddr, &curaddr);
-               else
-                       curaddr = vtophys(vaddr);
+               address_is_valid =
+                   pmap_extract(vm->vm_map.pmap, vaddr, &curaddr);
+               KASSERT(address_is_valid);
 
                /*
                 * If we're beyond the current DMA window, indicate
diff -r fbc8cc72849d -r 5514ffa3e0b9 sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c     Mon Jul 19 14:49:45 2021 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c     Mon Jul 19 16:25:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.44 2021/07/19 16:25:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.44 2021/07/19 16:25:54 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -74,6 +74,7 @@
        bus_size_t sgvalen, extra_sgvalen, boundary, alignment;
        SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
        int pteidx, error, spill, seg = *segp;
+       bool address_is_valid __diagused;
 
        /* Initialize the spill page PTE if it hasn't been already. */
        if (__C(SGMAP_TYPE,_prefetch_spill_page_pte) == 0)
@@ -268,10 +269,8 @@
        for (; va < endva; va += PAGE_SIZE, pteidx++,
             pte = &page_table[pteidx * SGMAP_PTE_SPACING]) {
                /* Get the physical address for this segment. */
-               if (!VMSPACE_IS_KERNEL_P(vm))
-                       (void) pmap_extract(vm->vm_map.pmap, va, &pa);
-               else
-                       pa = vtophys(va);
+               address_is_valid = pmap_extract(vm->vm_map.pmap, va, &pa);
+               KASSERT(address_is_valid);
 
                /* Load the current PTE with this page. */
                *pte = (pa >> SGPTE_PGADDR_SHIFT) | SGPTE_VALID;
@@ -289,10 +288,8 @@
 
                /* va == endva == address of extra page */
                KASSERT(va == endva);
-               if (!VMSPACE_IS_KERNEL_P(vm))
-                       (void) pmap_extract(vm->vm_map.pmap, va, &pa);
-               else
-                       pa = vtophys(va);
+               address_is_valid = pmap_extract(vm->vm_map.pmap, va, &pa);
+               KASSERT(address_is_valid);
 
                /*
                 * If a spill page is needed, the previous segment will



Home | Main Index | Thread Index | Old Index