| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.164.2.4.4.2 2017/03/06 08:17:49 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2010 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. | | 8 | * by Andrew Doran. |
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. |
| @@ -161,27 +161,27 @@ | | | @@ -161,27 +161,27 @@ |
161 | * Hibler/Jolitz pmap, as modified for FreeBSD by John S. Dyson | | 161 | * Hibler/Jolitz pmap, as modified for FreeBSD by John S. Dyson |
162 | * and David Greenman. | | 162 | * and David Greenman. |
163 | * | | 163 | * |
164 | * [3] the Mach pmap. this pmap, from CMU, seems to have migrated | | 164 | * [3] the Mach pmap. this pmap, from CMU, seems to have migrated |
165 | * between several processors. the VAX version was done by | | 165 | * between several processors. the VAX version was done by |
166 | * Avadis Tevanian, Jr., and Michael Wayne Young. the i386 | | 166 | * Avadis Tevanian, Jr., and Michael Wayne Young. the i386 |
167 | * version was done by Lance Berc, Mike Kupfer, Bob Baron, | | 167 | * version was done by Lance Berc, Mike Kupfer, Bob Baron, |
168 | * David Golub, and Richard Draves. the alpha version was | | 168 | * David Golub, and Richard Draves. the alpha version was |
169 | * done by Alessandro Forin (CMU/Mach) and Chris Demetriou | | 169 | * done by Alessandro Forin (CMU/Mach) and Chris Demetriou |
170 | * (NetBSD/alpha). | | 170 | * (NetBSD/alpha). |
171 | */ | | 171 | */ |
172 | | | 172 | |
173 | #include <sys/cdefs.h> | | 173 | #include <sys/cdefs.h> |
174 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $"); | | 174 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4.4.2 2017/03/06 08:17:49 snj Exp $"); |
175 | | | 175 | |
176 | #include "opt_user_ldt.h" | | 176 | #include "opt_user_ldt.h" |
177 | #include "opt_lockdebug.h" | | 177 | #include "opt_lockdebug.h" |
178 | #include "opt_multiprocessor.h" | | 178 | #include "opt_multiprocessor.h" |
179 | #include "opt_xen.h" | | 179 | #include "opt_xen.h" |
180 | #if !defined(__x86_64__) | | 180 | #if !defined(__x86_64__) |
181 | #include "opt_kstack_dr0.h" | | 181 | #include "opt_kstack_dr0.h" |
182 | #endif /* !defined(__x86_64__) */ | | 182 | #endif /* !defined(__x86_64__) */ |
183 | | | 183 | |
184 | #include <sys/param.h> | | 184 | #include <sys/param.h> |
185 | #include <sys/systm.h> | | 185 | #include <sys/systm.h> |
186 | #include <sys/proc.h> | | 186 | #include <sys/proc.h> |
187 | #include <sys/pool.h> | | 187 | #include <sys/pool.h> |
| @@ -1457,27 +1457,27 @@ pmap_bootstrap(vaddr_t kva_start) | | | @@ -1457,27 +1457,27 @@ pmap_bootstrap(vaddr_t kva_start) |
1457 | /* | | 1457 | /* |
1458 | * We want a dummy page directory for Xen: | | 1458 | * We want a dummy page directory for Xen: |
1459 | * when deactivate a pmap, Xen will still consider it active. | | 1459 | * when deactivate a pmap, Xen will still consider it active. |
1460 | * So we set user PGD to this one to lift all protection on | | 1460 | * So we set user PGD to this one to lift all protection on |
1461 | * the now inactive page tables set. | | 1461 | * the now inactive page tables set. |
1462 | */ | | 1462 | */ |
1463 | xen_dummy_user_pgd = avail_start; | | 1463 | xen_dummy_user_pgd = avail_start; |
1464 | avail_start += PAGE_SIZE; | | 1464 | avail_start += PAGE_SIZE; |
1465 | | | 1465 | |
1466 | /* Zero fill it, the less checks in Xen it requires the better */ | | 1466 | /* Zero fill it, the less checks in Xen it requires the better */ |
1467 | memset((void *) (xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE); | | 1467 | memset((void *) (xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE); |
1468 | /* Mark read-only */ | | 1468 | /* Mark read-only */ |
1469 | HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE, | | 1469 | HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE, |
1470 | pmap_pa2pte(xen_dummy_user_pgd) | PG_u | PG_V, UVMF_INVLPG); | | 1470 | pmap_pa2pte(xen_dummy_user_pgd) | PG_k | PG_V, UVMF_INVLPG); |
1471 | /* Pin as L4 */ | | 1471 | /* Pin as L4 */ |
1472 | xpq_queue_pin_l4_table(xpmap_ptom_masked(xen_dummy_user_pgd)); | | 1472 | xpq_queue_pin_l4_table(xpmap_ptom_masked(xen_dummy_user_pgd)); |
1473 | #endif /* __x86_64__ */ | | 1473 | #endif /* __x86_64__ */ |
1474 | idt_vaddr = virtual_avail; /* don't need pte */ | | 1474 | idt_vaddr = virtual_avail; /* don't need pte */ |
1475 | idt_paddr = avail_start; /* steal a page */ | | 1475 | idt_paddr = avail_start; /* steal a page */ |
1476 | /* | | 1476 | /* |
1477 | * Xen require one more page as we can't store | | 1477 | * Xen require one more page as we can't store |
1478 | * GDT and LDT on the same page | | 1478 | * GDT and LDT on the same page |
1479 | */ | | 1479 | */ |
1480 | virtual_avail += 3 * PAGE_SIZE; | | 1480 | virtual_avail += 3 * PAGE_SIZE; |
1481 | avail_start += 3 * PAGE_SIZE; | | 1481 | avail_start += 3 * PAGE_SIZE; |
1482 | #else /* XEN */ | | 1482 | #else /* XEN */ |
1483 | idt_vaddr = virtual_avail; /* don't need pte */ | | 1483 | idt_vaddr = virtual_avail; /* don't need pte */ |
| @@ -2054,27 +2054,27 @@ pmap_pdp_ctor(void *arg, void *v, int fl | | | @@ -2054,27 +2054,27 @@ pmap_pdp_ctor(void *arg, void *v, int fl |
2054 | * NOTE: The `pmaps_lock' is held when the PDP is allocated. | | 2054 | * NOTE: The `pmaps_lock' is held when the PDP is allocated. |
2055 | */ | | 2055 | */ |
2056 | | | 2056 | |
2057 | #if defined(XEN) && defined(__x86_64__) | | 2057 | #if defined(XEN) && defined(__x86_64__) |
2058 | /* fetch the physical address of the page directory. */ | | 2058 | /* fetch the physical address of the page directory. */ |
2059 | (void) pmap_extract(pmap_kernel(), (vaddr_t) pdir, &pdirpa); | | 2059 | (void) pmap_extract(pmap_kernel(), (vaddr_t) pdir, &pdirpa); |
2060 | | | 2060 | |
2061 | /* zero init area */ | | 2061 | /* zero init area */ |
2062 | memset (pdir, 0, PAGE_SIZE); /* Xen wants a clean page */ | | 2062 | memset (pdir, 0, PAGE_SIZE); /* Xen wants a clean page */ |
2063 | /* | | 2063 | /* |
2064 | * this pdir will NEVER be active in kernel mode | | 2064 | * this pdir will NEVER be active in kernel mode |
2065 | * so mark recursive entry invalid | | 2065 | * so mark recursive entry invalid |
2066 | */ | | 2066 | */ |
2067 | pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_u; | | 2067 | pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_k; |
2068 | /* | | 2068 | /* |
2069 | * PDP constructed this way won't be for kernel, | | 2069 | * PDP constructed this way won't be for kernel, |
2070 | * hence we don't put kernel mappings on Xen. | | 2070 | * hence we don't put kernel mappings on Xen. |
2071 | * But we need to make pmap_create() happy, so put a dummy (without | | 2071 | * But we need to make pmap_create() happy, so put a dummy (without |
2072 | * PG_V) value at the right place. | | 2072 | * PG_V) value at the right place. |
2073 | */ | | 2073 | */ |
2074 | pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] = | | 2074 | pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] = |
2075 | (pd_entry_t)-1 & PG_FRAME; | | 2075 | (pd_entry_t)-1 & PG_FRAME; |
2076 | #else /* XEN && __x86_64__*/ | | 2076 | #else /* XEN && __x86_64__*/ |
2077 | /* zero init area */ | | 2077 | /* zero init area */ |
2078 | memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t)); | | 2078 | memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t)); |
2079 | | | 2079 | |
2080 | object = (vaddr_t)v; | | 2080 | object = (vaddr_t)v; |