Add two pmap fields, will be used by NVMM.diff -r1.88 -r1.89 src/sys/arch/x86/include/pmap.h
(maxv)
--- src/sys/arch/x86/include/pmap.h 2018/08/29 16:26:25 1.88
+++ src/sys/arch/x86/include/pmap.h 2018/11/07 07:14:51 1.89
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pmap.h,v 1.88 2018/08/29 16:26:25 maxv Exp $ */ | 1 | /* $NetBSD: pmap.h,v 1.89 2018/11/07 07:14:51 maxv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | 4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -248,26 +248,30 @@ struct pmap { | @@ -248,26 +248,30 @@ struct pmap { | |||
248 | #endif /* !defined(__x86_64__) */ | 248 | #endif /* !defined(__x86_64__) */ | |
249 | int pm_flags; /* see below */ | 249 | int pm_flags; /* see below */ | |
250 | 250 | |||
251 | union descriptor *pm_ldt; /* user-set LDT */ | 251 | union descriptor *pm_ldt; /* user-set LDT */ | |
252 | size_t pm_ldt_len; /* size of LDT in bytes */ | 252 | size_t pm_ldt_len; /* size of LDT in bytes */ | |
253 | int pm_ldt_sel; /* LDT selector */ | 253 | int pm_ldt_sel; /* LDT selector */ | |
254 | kcpuset_t *pm_cpus; /* mask of CPUs using pmap */ | 254 | kcpuset_t *pm_cpus; /* mask of CPUs using pmap */ | |
255 | kcpuset_t *pm_kernel_cpus; /* mask of CPUs using kernel part | 255 | kcpuset_t *pm_kernel_cpus; /* mask of CPUs using kernel part | |
256 | of pmap */ | 256 | of pmap */ | |
257 | kcpuset_t *pm_xen_ptp_cpus; /* mask of CPUs which have this pmap's | 257 | kcpuset_t *pm_xen_ptp_cpus; /* mask of CPUs which have this pmap's | |
258 | ptp mapped */ | 258 | ptp mapped */ | |
259 | uint64_t pm_ncsw; /* for assertions */ | 259 | uint64_t pm_ncsw; /* for assertions */ | |
260 | struct vm_page *pm_gc_ptp; /* pages from pmap g/c */ | 260 | struct vm_page *pm_gc_ptp; /* pages from pmap g/c */ | |
261 | ||||
262 | /* Used by NVMM. */ | |||
263 | void (*pm_tlb_flush)(struct pmap *); | |||
264 | void *pm_data; | |||
261 | }; | 265 | }; | |
262 | 266 | |||
263 | /* macro to access pm_pdirpa slots */ | 267 | /* macro to access pm_pdirpa slots */ | |
264 | #ifdef PAE | 268 | #ifdef PAE | |
265 | #define pmap_pdirpa(pmap, index) \ | 269 | #define pmap_pdirpa(pmap, index) \ | |
266 | ((pmap)->pm_pdirpa[l2tol3(index)] + l2tol2(index) * sizeof(pd_entry_t)) | 270 | ((pmap)->pm_pdirpa[l2tol3(index)] + l2tol2(index) * sizeof(pd_entry_t)) | |
267 | #else | 271 | #else | |
268 | #define pmap_pdirpa(pmap, index) \ | 272 | #define pmap_pdirpa(pmap, index) \ | |
269 | ((pmap)->pm_pdirpa[0] + (index) * sizeof(pd_entry_t)) | 273 | ((pmap)->pm_pdirpa[0] + (index) * sizeof(pd_entry_t)) | |
270 | #endif | 274 | #endif | |
271 | 275 | |||
272 | /* | 276 | /* | |
273 | * MD flags that we use for pmap_enter and pmap_kenter_pa: | 277 | * MD flags that we use for pmap_enter and pmap_kenter_pa: |
--- src/sys/arch/x86/x86/pmap.c 2018/10/31 06:26:26 1.309
+++ src/sys/arch/x86/x86/pmap.c 2018/11/07 07:14:51 1.310
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pmap.c,v 1.309 2018/10/31 06:26:26 maxv Exp $ */ | 1 | /* $NetBSD: pmap.c,v 1.310 2018/11/07 07:14:51 maxv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran, and by Maxime Villard. | 8 | * by Andrew Doran, and by Maxime Villard. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -120,27 +120,27 @@ | @@ -120,27 +120,27 @@ | |||
120 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 120 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
121 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 121 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
122 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 122 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
123 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 123 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
124 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 124 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
125 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 125 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
126 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 126 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
127 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 127 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
128 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 128 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
129 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 129 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
130 | */ | 130 | */ | |
131 | 131 | |||
132 | #include <sys/cdefs.h> | 132 | #include <sys/cdefs.h> | |
133 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.309 2018/10/31 06:26:26 maxv Exp $"); | 133 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.310 2018/11/07 07:14:51 maxv Exp $"); | |
134 | 134 | |||
135 | #include "opt_user_ldt.h" | 135 | #include "opt_user_ldt.h" | |
136 | #include "opt_lockdebug.h" | 136 | #include "opt_lockdebug.h" | |
137 | #include "opt_multiprocessor.h" | 137 | #include "opt_multiprocessor.h" | |
138 | #include "opt_xen.h" | 138 | #include "opt_xen.h" | |
139 | #include "opt_svs.h" | 139 | #include "opt_svs.h" | |
140 | #include "opt_kasan.h" | 140 | #include "opt_kasan.h" | |
141 | 141 | |||
142 | #include <sys/param.h> | 142 | #include <sys/param.h> | |
143 | #include <sys/systm.h> | 143 | #include <sys/systm.h> | |
144 | #include <sys/proc.h> | 144 | #include <sys/proc.h> | |
145 | #include <sys/pool.h> | 145 | #include <sys/pool.h> | |
146 | #include <sys/kernel.h> | 146 | #include <sys/kernel.h> | |
@@ -2368,26 +2368,27 @@ pmap_create(void) | @@ -2368,26 +2368,27 @@ pmap_create(void) | |||
2368 | mutex_init(&pmap->pm_obj_lock[i], MUTEX_DEFAULT, IPL_NONE); | 2368 | mutex_init(&pmap->pm_obj_lock[i], MUTEX_DEFAULT, IPL_NONE); | |
2369 | uvm_obj_init(&pmap->pm_obj[i], NULL, false, 1); | 2369 | uvm_obj_init(&pmap->pm_obj[i], NULL, false, 1); | |
2370 | uvm_obj_setlock(&pmap->pm_obj[i], &pmap->pm_obj_lock[i]); | 2370 | uvm_obj_setlock(&pmap->pm_obj[i], &pmap->pm_obj_lock[i]); | |
2371 | pmap->pm_ptphint[i] = NULL; | 2371 | pmap->pm_ptphint[i] = NULL; | |
2372 | } | 2372 | } | |
2373 | pmap->pm_stats.wired_count = 0; | 2373 | pmap->pm_stats.wired_count = 0; | |
2374 | /* count the PDP allocd below */ | 2374 | /* count the PDP allocd below */ | |
2375 | pmap->pm_stats.resident_count = PDP_SIZE; | 2375 | pmap->pm_stats.resident_count = PDP_SIZE; | |
2376 | #if !defined(__x86_64__) | 2376 | #if !defined(__x86_64__) | |
2377 | pmap->pm_hiexec = 0; | 2377 | pmap->pm_hiexec = 0; | |
2378 | #endif | 2378 | #endif | |
2379 | pmap->pm_flags = 0; | 2379 | pmap->pm_flags = 0; | |
2380 | pmap->pm_gc_ptp = NULL; | 2380 | pmap->pm_gc_ptp = NULL; | |
2381 | pmap->pm_tlb_flush = NULL; | |||
2381 | 2382 | |||
2382 | kcpuset_create(&pmap->pm_cpus, true); | 2383 | kcpuset_create(&pmap->pm_cpus, true); | |
2383 | kcpuset_create(&pmap->pm_kernel_cpus, true); | 2384 | kcpuset_create(&pmap->pm_kernel_cpus, true); | |
2384 | #ifdef XEN | 2385 | #ifdef XEN | |
2385 | kcpuset_create(&pmap->pm_xen_ptp_cpus, true); | 2386 | kcpuset_create(&pmap->pm_xen_ptp_cpus, true); | |
2386 | #endif | 2387 | #endif | |
2387 | /* init the LDT */ | 2388 | /* init the LDT */ | |
2388 | pmap->pm_ldt = NULL; | 2389 | pmap->pm_ldt = NULL; | |
2389 | pmap->pm_ldt_len = 0; | 2390 | pmap->pm_ldt_len = 0; | |
2390 | pmap->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL); | 2391 | pmap->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL); | |
2391 | 2392 | |||
2392 | /* allocate PDP */ | 2393 | /* allocate PDP */ | |
2393 | try_again: | 2394 | try_again: |
--- src/sys/arch/x86/x86/x86_tlb.c 2018/05/19 16:51:32 1.2
+++ src/sys/arch/x86/x86/x86_tlb.c 2018/11/07 07:14:51 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_tlb.c,v 1.2 2018/05/19 16:51:32 jakllsch Exp $ */ | 1 | /* $NetBSD: x86_tlb.c,v 1.3 2018/11/07 07:14:51 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008-2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008-2012 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran and Mindaugas Rasiukevicius. | 8 | * by Andrew Doran and Mindaugas Rasiukevicius. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * x86 pmap(9) module: TLB shootdowns. | 33 | * x86 pmap(9) module: TLB shootdowns. | |
34 | * | 34 | * | |
35 | * TLB shootdowns are hard interrupts that operate outside the SPL framework. | 35 | * TLB shootdowns are hard interrupts that operate outside the SPL framework. | |
36 | * They do not need to be blocked, provided that the pmap module gets the | 36 | * They do not need to be blocked, provided that the pmap module gets the | |
37 | * order of events correct. The calls are made by poking the LAPIC directly. | 37 | * order of events correct. The calls are made by poking the LAPIC directly. | |
38 | * The interrupt handler is short and does one of the following: invalidate | 38 | * The interrupt handler is short and does one of the following: invalidate | |
39 | * a set of pages, all user TLB entries or the entire TLB. | 39 | * a set of pages, all user TLB entries or the entire TLB. | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.2 2018/05/19 16:51:32 jakllsch Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.3 2018/11/07 07:14:51 maxv Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | 47 | |||
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/atomic.h> | 49 | #include <sys/atomic.h> | |
50 | #include <sys/cpu.h> | 50 | #include <sys/cpu.h> | |
51 | #include <sys/intr.h> | 51 | #include <sys/intr.h> | |
52 | #include <uvm/uvm.h> | 52 | #include <uvm/uvm.h> | |
53 | 53 | |||
54 | #include <machine/cpuvar.h> | 54 | #include <machine/cpuvar.h> | |
55 | #ifdef XEN | 55 | #ifdef XEN | |
56 | #include <xen/xenpmap.h> | 56 | #include <xen/xenpmap.h> | |
@@ -217,26 +217,31 @@ pmap_tlb_invalidate(const pmap_tlb_packe | @@ -217,26 +217,31 @@ pmap_tlb_invalidate(const pmap_tlb_packe | |||
217 | /* | 217 | /* | |
218 | * pmap_tlb_shootdown: invalidate a page on all CPUs using pmap 'pm'. | 218 | * pmap_tlb_shootdown: invalidate a page on all CPUs using pmap 'pm'. | |
219 | */ | 219 | */ | |
220 | void | 220 | void | |
221 | pmap_tlb_shootdown(struct pmap *pm, vaddr_t va, pt_entry_t pte, tlbwhy_t why) | 221 | pmap_tlb_shootdown(struct pmap *pm, vaddr_t va, pt_entry_t pte, tlbwhy_t why) | |
222 | { | 222 | { | |
223 | pmap_tlb_packet_t *tp; | 223 | pmap_tlb_packet_t *tp; | |
224 | int s; | 224 | int s; | |
225 | 225 | |||
226 | #ifndef XEN | 226 | #ifndef XEN | |
227 | KASSERT((pte & PG_G) == 0 || pm == pmap_kernel()); | 227 | KASSERT((pte & PG_G) == 0 || pm == pmap_kernel()); | |
228 | #endif | 228 | #endif | |
229 | 229 | |||
230 | if (__predict_false(pm->pm_tlb_flush != NULL)) { | |||
231 | (*pm->pm_tlb_flush)(pm); | |||
232 | return; | |||
233 | } | |||
234 | ||||
230 | /* | 235 | /* | |
231 | * If tearing down the pmap, do nothing. We will flush later | 236 | * If tearing down the pmap, do nothing. We will flush later | |
232 | * when we are ready to recycle/destroy it. | 237 | * when we are ready to recycle/destroy it. | |
233 | */ | 238 | */ | |
234 | if (__predict_false(curlwp->l_md.md_gc_pmap == pm)) { | 239 | if (__predict_false(curlwp->l_md.md_gc_pmap == pm)) { | |
235 | return; | 240 | return; | |
236 | } | 241 | } | |
237 | 242 | |||
238 | if ((pte & PG_PS) != 0) { | 243 | if ((pte & PG_PS) != 0) { | |
239 | va &= PG_LGFRAME; | 244 | va &= PG_LGFRAME; | |
240 | } | 245 | } | |
241 | 246 | |||
242 | /* | 247 | /* |