| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.298 2021/07/16 19:02:22 thorpej Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.299 2021/07/19 16:31:19 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020 | | 4 | * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020 |
5 | * The NetBSD Foundation, Inc. | | 5 | * The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
10 | * NASA Ames Research Center, by Andrew Doran and Mindaugas Rasiukevicius, | | 10 | * NASA Ames Research Center, by Andrew Doran and Mindaugas Rasiukevicius, |
11 | * and by Chris G. Demetriou. | | 11 | * and by Chris G. Demetriou. |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
| @@ -125,27 +125,27 @@ | | | @@ -125,27 +125,27 @@ |
125 | * this module may delay invalidate or reduced protection | | 125 | * this module may delay invalidate or reduced protection |
126 | * operations until such time as they are actually | | 126 | * operations until such time as they are actually |
127 | * necessary. This module is given full information as | | 127 | * necessary. This module is given full information as |
128 | * to which processors are currently using which maps, | | 128 | * to which processors are currently using which maps, |
129 | * and to when physical maps must be made correct. | | 129 | * and to when physical maps must be made correct. |
130 | */ | | 130 | */ |
131 | | | 131 | |
132 | #include "opt_lockdebug.h" | | 132 | #include "opt_lockdebug.h" |
133 | #include "opt_sysv.h" | | 133 | #include "opt_sysv.h" |
134 | #include "opt_multiprocessor.h" | | 134 | #include "opt_multiprocessor.h" |
135 | | | 135 | |
136 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 136 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
137 | | | 137 | |
138 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.298 2021/07/16 19:02:22 thorpej Exp $"); | | 138 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2021/07/19 16:31:19 thorpej Exp $"); |
139 | | | 139 | |
140 | #include <sys/param.h> | | 140 | #include <sys/param.h> |
141 | #include <sys/systm.h> | | 141 | #include <sys/systm.h> |
142 | #include <sys/kernel.h> | | 142 | #include <sys/kernel.h> |
143 | #include <sys/proc.h> | | 143 | #include <sys/proc.h> |
144 | #include <sys/pool.h> | | 144 | #include <sys/pool.h> |
145 | #include <sys/buf.h> | | 145 | #include <sys/buf.h> |
146 | #include <sys/evcnt.h> | | 146 | #include <sys/evcnt.h> |
147 | #include <sys/atomic.h> | | 147 | #include <sys/atomic.h> |
148 | #include <sys/cpu.h> | | 148 | #include <sys/cpu.h> |
149 | | | 149 | |
150 | #include <uvm/uvm.h> | | 150 | #include <uvm/uvm.h> |
151 | | | 151 | |
| @@ -2568,38 +2568,38 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa | | | @@ -2568,38 +2568,38 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa |
2568 | pt_entry_t *l1pte, *l2pte, *l3pte; | | 2568 | pt_entry_t *l1pte, *l2pte, *l3pte; |
2569 | paddr_t pa; | | 2569 | paddr_t pa; |
2570 | | | 2570 | |
2571 | #ifdef DEBUG | | 2571 | #ifdef DEBUG |
2572 | if (pmapdebug & PDB_FOLLOW) | | 2572 | if (pmapdebug & PDB_FOLLOW) |
2573 | printf("pmap_extract(%p, %lx) -> ", pmap, va); | | 2573 | printf("pmap_extract(%p, %lx) -> ", pmap, va); |
2574 | #endif | | 2574 | #endif |
2575 | | | 2575 | |
2576 | /* | | 2576 | /* |
2577 | * Take a faster path for the kernel pmap. Avoids locking, | | 2577 | * Take a faster path for the kernel pmap. Avoids locking, |
2578 | * handles K0SEG. | | 2578 | * handles K0SEG. |
2579 | */ | | 2579 | */ |
2580 | if (__predict_true(pmap == pmap_kernel())) { | | 2580 | if (__predict_true(pmap == pmap_kernel())) { |
2581 | if (__predict_true(vtophys_internal(va, pap))) { | | | |
2582 | #ifdef DEBUG | | 2581 | #ifdef DEBUG |
2583 | if (pmapdebug & PDB_FOLLOW) | | 2582 | bool address_is_valid = vtophys_internal(va, pap); |
| | | 2583 | if (pmapdebug & PDB_FOLLOW) { |
| | | 2584 | if (address_is_valid) { |
2584 | printf("0x%lx (kernel vtophys)\n", *pap); | | 2585 | printf("0x%lx (kernel vtophys)\n", *pap); |
2585 | #endif | | 2586 | } else { |
2586 | return true; | | 2587 | printf("failed (kernel vtophys)\n"); |
| | | 2588 | } |
2587 | } | | 2589 | } |
2588 | #ifdef DEBUG | | 2590 | #else |
2589 | if (pmapdebug & PDB_FOLLOW) | | 2591 | return vtophys_internal(va, pap); |
2590 | printf("failed (kernel vtophys)\n"); | | | |
2591 | #endif | | 2592 | #endif |
2592 | return false; | | | |
2593 | } | | 2593 | } |
2594 | | | 2594 | |
2595 | pt_entry_t * const lev1map = pmap_lev1map(pmap); | | 2595 | pt_entry_t * const lev1map = pmap_lev1map(pmap); |
2596 | | | 2596 | |
2597 | PMAP_LOCK(pmap); | | 2597 | PMAP_LOCK(pmap); |
2598 | | | 2598 | |
2599 | l1pte = pmap_l1pte(lev1map, va); | | 2599 | l1pte = pmap_l1pte(lev1map, va); |
2600 | if (pmap_pte_v(l1pte) == 0) | | 2600 | if (pmap_pte_v(l1pte) == 0) |
2601 | goto out; | | 2601 | goto out; |
2602 | | | 2602 | |
2603 | l2pte = pmap_l2pte(lev1map, va, l1pte); | | 2603 | l2pte = pmap_l2pte(lev1map, va, l1pte); |
2604 | if (pmap_pte_v(l2pte) == 0) | | 2604 | if (pmap_pte_v(l2pte) == 0) |
2605 | goto out; | | 2605 | goto out; |