| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.418 2020/08/10 05:38:43 skrll Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.419 2020/08/10 05:40:21 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2003 Wasabi Systems, Inc. | | 4 | * Copyright 2003 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Steve C. Woodford for Wasabi Systems, Inc. | | 7 | * Written by Steve C. Woodford for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -182,27 +182,27 @@ | | | @@ -182,27 +182,27 @@ |
182 | /* Include header files */ | | 182 | /* Include header files */ |
183 | | | 183 | |
184 | #include "opt_arm_debug.h" | | 184 | #include "opt_arm_debug.h" |
185 | #include "opt_cpuoptions.h" | | 185 | #include "opt_cpuoptions.h" |
186 | #include "opt_ddb.h" | | 186 | #include "opt_ddb.h" |
187 | #include "opt_lockdebug.h" | | 187 | #include "opt_lockdebug.h" |
188 | #include "opt_multiprocessor.h" | | 188 | #include "opt_multiprocessor.h" |
189 | | | 189 | |
190 | #ifdef MULTIPROCESSOR | | 190 | #ifdef MULTIPROCESSOR |
191 | #define _INTR_PRIVATE | | 191 | #define _INTR_PRIVATE |
192 | #endif | | 192 | #endif |
193 | | | 193 | |
194 | #include <sys/cdefs.h> | | 194 | #include <sys/cdefs.h> |
195 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.418 2020/08/10 05:38:43 skrll Exp $"); | | 195 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.419 2020/08/10 05:40:21 skrll Exp $"); |
196 | | | 196 | |
197 | #include <sys/param.h> | | 197 | #include <sys/param.h> |
198 | #include <sys/types.h> | | 198 | #include <sys/types.h> |
199 | | | 199 | |
200 | #include <sys/asan.h> | | 200 | #include <sys/asan.h> |
201 | #include <sys/atomic.h> | | 201 | #include <sys/atomic.h> |
202 | #include <sys/bus.h> | | 202 | #include <sys/bus.h> |
203 | #include <sys/cpu.h> | | 203 | #include <sys/cpu.h> |
204 | #include <sys/intr.h> | | 204 | #include <sys/intr.h> |
205 | #include <sys/kernel.h> | | 205 | #include <sys/kernel.h> |
206 | #include <sys/kernhist.h> | | 206 | #include <sys/kernhist.h> |
207 | #include <sys/kmem.h> | | 207 | #include <sys/kmem.h> |
208 | #include <sys/pool.h> | | 208 | #include <sys/pool.h> |
| @@ -4830,26 +4830,28 @@ pmap_unwire(pmap_t pm, vaddr_t va) | | | @@ -4830,26 +4830,28 @@ pmap_unwire(pmap_t pm, vaddr_t va) |
4830 | /* Extract the physical address of the page */ | | 4830 | /* Extract the physical address of the page */ |
4831 | pa = l2pte_pa(pte); | | 4831 | pa = l2pte_pa(pte); |
4832 | | | 4832 | |
4833 | if ((pg = PHYS_TO_VM_PAGE(pa)) != NULL) { | | 4833 | if ((pg = PHYS_TO_VM_PAGE(pa)) != NULL) { |
4834 | /* Update the wired bit in the pv entry for this page. */ | | 4834 | /* Update the wired bit in the pv entry for this page. */ |
4835 | struct vm_page_md *md = VM_PAGE_TO_MD(pg); | | 4835 | struct vm_page_md *md = VM_PAGE_TO_MD(pg); |
4836 | | | 4836 | |
4837 | pmap_acquire_page_lock(md); | | 4837 | pmap_acquire_page_lock(md); |
4838 | (void) pmap_modify_pv(md, pa, pm, va, PVF_WIRED, 0); | | 4838 | (void) pmap_modify_pv(md, pa, pm, va, PVF_WIRED, 0); |
4839 | pmap_release_page_lock(md); | | 4839 | pmap_release_page_lock(md); |
4840 | } | | 4840 | } |
4841 | | | 4841 | |
4842 | pmap_release_pmap_lock(pm); | | 4842 | pmap_release_pmap_lock(pm); |
| | | 4843 | |
| | | 4844 | UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0); |
4843 | } | | 4845 | } |
4844 | | | 4846 | |
4845 | #ifdef ARM_MMU_EXTENDED | | 4847 | #ifdef ARM_MMU_EXTENDED |
4846 | void | | 4848 | void |
4847 | pmap_md_pdetab_activate(pmap_t pm, struct lwp *l) | | 4849 | pmap_md_pdetab_activate(pmap_t pm, struct lwp *l) |
4848 | { | | 4850 | { |
4849 | UVMHIST_FUNC(__func__); | | 4851 | UVMHIST_FUNC(__func__); |
4850 | struct cpu_info * const ci = curcpu(); | | 4852 | struct cpu_info * const ci = curcpu(); |
4851 | struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci)); | | 4853 | struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci)); |
4852 | | | 4854 | |
4853 | UVMHIST_CALLARGS(maphist, "pm %#jx (pm->pm_l1_pa %08jx asid %ju)", | | 4855 | UVMHIST_CALLARGS(maphist, "pm %#jx (pm->pm_l1_pa %08jx asid %ju)", |
4854 | (uintptr_t)pm, pm->pm_l1_pa, pai->pai_asid, 0); | | 4856 | (uintptr_t)pm, pm->pm_l1_pa, pai->pai_asid, 0); |
4855 | | | 4857 | |
| @@ -5165,50 +5167,57 @@ pmap_update(pmap_t pm) | | | @@ -5165,50 +5167,57 @@ pmap_update(pmap_t pm) |
5165 | PMAPCOUNT(updates); | | 5167 | PMAPCOUNT(updates); |
5166 | | | 5168 | |
5167 | /* | | 5169 | /* |
5168 | * make sure TLB/cache operations have completed. | | 5170 | * make sure TLB/cache operations have completed. |
5169 | */ | | 5171 | */ |
5170 | cpu_cpwait(); | | 5172 | cpu_cpwait(); |
5171 | UVMHIST_LOG(maphist, " <-- done", 0, 0, 0, 0); | | 5173 | UVMHIST_LOG(maphist, " <-- done", 0, 0, 0, 0); |
5172 | } | | 5174 | } |
5173 | | | 5175 | |
5174 | bool | | 5176 | bool |
5175 | pmap_remove_all(pmap_t pm) | | 5177 | pmap_remove_all(pmap_t pm) |
5176 | { | | 5178 | { |
5177 | | | 5179 | |
| | | 5180 | UVMHIST_FUNC(__func__); |
| | | 5181 | UVMHIST_CALLARGS(pmaphist, "(pm=%#jx)", (uintptr_t)pmap, 0, 0, 0); |
| | | 5182 | |
| | | 5183 | KASSERT(pm != pmap_kernel()); |
| | | 5184 | |
5178 | /* | | 5185 | /* |
5179 | * The vmspace described by this pmap is about to be torn down. | | 5186 | * The vmspace described by this pmap is about to be torn down. |
5180 | * Until pmap_update() is called, UVM will only make calls | | 5187 | * Until pmap_update() is called, UVM will only make calls |
5181 | * to pmap_remove(). We can make life much simpler by flushing | | 5188 | * to pmap_remove(). We can make life much simpler by flushing |
5182 | * the cache now, and deferring TLB invalidation to pmap_update(). | | 5189 | * the cache now, and deferring TLB invalidation to pmap_update(). |
5183 | */ | | 5190 | */ |
5184 | #ifdef PMAP_CACHE_VIVT | | 5191 | #ifdef PMAP_CACHE_VIVT |
5185 | pmap_cache_wbinv_all(pm, PVF_EXEC); | | 5192 | pmap_cache_wbinv_all(pm, PVF_EXEC); |
5186 | #endif | | 5193 | #endif |
5187 | #ifdef ARM_MMU_EXTENDED | | 5194 | #ifdef ARM_MMU_EXTENDED |
5188 | #ifdef MULTIPROCESSOR | | 5195 | #ifdef MULTIPROCESSOR |
5189 | struct cpu_info * const ci = curcpu(); | | 5196 | struct cpu_info * const ci = curcpu(); |
5190 | // This should be the last CPU with this pmap onproc | | 5197 | // This should be the last CPU with this pmap onproc |
5191 | KASSERT(!kcpuset_isotherset(pm->pm_onproc, cpu_index(ci))); | | 5198 | KASSERT(!kcpuset_isotherset(pm->pm_onproc, cpu_index(ci))); |
5192 | if (kcpuset_isset(pm->pm_onproc, cpu_index(ci))) | | 5199 | if (kcpuset_isset(pm->pm_onproc, cpu_index(ci))) |
5193 | #endif | | 5200 | #endif |
5194 | pmap_tlb_asid_deactivate(pm); | | 5201 | pmap_tlb_asid_deactivate(pm); |
5195 | #ifdef MULTIPROCESSOR | | 5202 | #ifdef MULTIPROCESSOR |
5196 | KASSERT(kcpuset_iszero(pm->pm_onproc)); | | 5203 | KASSERT(kcpuset_iszero(pm->pm_onproc)); |
5197 | #endif | | 5204 | #endif |
5198 | | | 5205 | |
5199 | pmap_tlb_asid_release_all(pm); | | 5206 | pmap_tlb_asid_release_all(pm); |
5200 | #endif | | 5207 | #endif |
5201 | pm->pm_remove_all = true; | | 5208 | pm->pm_remove_all = true; |
| | | 5209 | |
| | | 5210 | UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0); |
5202 | return false; | | 5211 | return false; |
5203 | } | | 5212 | } |
5204 | | | 5213 | |
5205 | /* | | 5214 | /* |
5206 | * Retire the given physical map from service. | | 5215 | * Retire the given physical map from service. |
5207 | * Should only be called if the map contains no valid mappings. | | 5216 | * Should only be called if the map contains no valid mappings. |
5208 | */ | | 5217 | */ |
5209 | void | | 5218 | void |
5210 | pmap_destroy(pmap_t pm) | | 5219 | pmap_destroy(pmap_t pm) |
5211 | { | | 5220 | { |
5212 | UVMHIST_FUNC(__func__); | | 5221 | UVMHIST_FUNC(__func__); |
5213 | UVMHIST_CALLARGS(maphist, "pm=%#jx remove_all %jd", (uintptr_t)pm, | | 5222 | UVMHIST_CALLARGS(maphist, "pm=%#jx remove_all %jd", (uintptr_t)pm, |
5214 | pm ? pm->pm_remove_all : 0, 0, 0); | | 5223 | pm ? pm->pm_remove_all : 0, 0, 0); |