| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.183.2.2.2.2 2016/12/18 07:02:59 snj Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.183.2.2.2.3 2017/03/06 03:32:45 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.183.2.2.2.2 2016/12/18 07:02:59 snj Exp $"); | | 174 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.2.2.3 2017/03/06 03:32:45 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> |
| @@ -1597,27 +1597,27 @@ pmap_bootstrap(vaddr_t kva_start) | | | @@ -1597,27 +1597,27 @@ pmap_bootstrap(vaddr_t kva_start) |
1597 | /* | | 1597 | /* |
1598 | * We want a dummy page directory for Xen: | | 1598 | * We want a dummy page directory for Xen: |
1599 | * when deactivate a pmap, Xen will still consider it active. | | 1599 | * when deactivate a pmap, Xen will still consider it active. |
1600 | * So we set user PGD to this one to lift all protection on | | 1600 | * So we set user PGD to this one to lift all protection on |
1601 | * the now inactive page tables set. | | 1601 | * the now inactive page tables set. |
1602 | */ | | 1602 | */ |
1603 | xen_dummy_user_pgd = avail_start; | | 1603 | xen_dummy_user_pgd = avail_start; |
1604 | avail_start += PAGE_SIZE; | | 1604 | avail_start += PAGE_SIZE; |
1605 | | | 1605 | |
1606 | /* Zero fill it, the less checks in Xen it requires the better */ | | 1606 | /* Zero fill it, the less checks in Xen it requires the better */ |
1607 | memset((void *) (xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE); | | 1607 | memset((void *) (xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE); |
1608 | /* Mark read-only */ | | 1608 | /* Mark read-only */ |
1609 | HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE, | | 1609 | HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE, |
1610 | pmap_pa2pte(xen_dummy_user_pgd) | PG_u | PG_V, UVMF_INVLPG); | | 1610 | pmap_pa2pte(xen_dummy_user_pgd) | PG_k | PG_V, UVMF_INVLPG); |
1611 | /* Pin as L4 */ | | 1611 | /* Pin as L4 */ |
1612 | xpq_queue_pin_l4_table(xpmap_ptom_masked(xen_dummy_user_pgd)); | | 1612 | xpq_queue_pin_l4_table(xpmap_ptom_masked(xen_dummy_user_pgd)); |
1613 | #endif /* __x86_64__ */ | | 1613 | #endif /* __x86_64__ */ |
1614 | idt_vaddr = virtual_avail; /* don't need pte */ | | 1614 | idt_vaddr = virtual_avail; /* don't need pte */ |
1615 | idt_paddr = avail_start; /* steal a page */ | | 1615 | idt_paddr = avail_start; /* steal a page */ |
1616 | /* | | 1616 | /* |
1617 | * Xen require one more page as we can't store | | 1617 | * Xen require one more page as we can't store |
1618 | * GDT and LDT on the same page | | 1618 | * GDT and LDT on the same page |
1619 | */ | | 1619 | */ |
1620 | virtual_avail += 3 * PAGE_SIZE; | | 1620 | virtual_avail += 3 * PAGE_SIZE; |
1621 | avail_start += 3 * PAGE_SIZE; | | 1621 | avail_start += 3 * PAGE_SIZE; |
1622 | #else /* XEN */ | | 1622 | #else /* XEN */ |
1623 | idt_vaddr = virtual_avail; /* don't need pte */ | | 1623 | idt_vaddr = virtual_avail; /* don't need pte */ |
| @@ -2190,27 +2190,27 @@ pmap_pdp_ctor(void *arg, void *v, int fl | | | @@ -2190,27 +2190,27 @@ pmap_pdp_ctor(void *arg, void *v, int fl |
2190 | * NOTE: The `pmaps_lock' is held when the PDP is allocated. | | 2190 | * NOTE: The `pmaps_lock' is held when the PDP is allocated. |
2191 | */ | | 2191 | */ |
2192 | | | 2192 | |
2193 | #if defined(XEN) && defined(__x86_64__) | | 2193 | #if defined(XEN) && defined(__x86_64__) |
2194 | /* fetch the physical address of the page directory. */ | | 2194 | /* fetch the physical address of the page directory. */ |
2195 | (void) pmap_extract(pmap_kernel(), (vaddr_t) pdir, &pdirpa); | | 2195 | (void) pmap_extract(pmap_kernel(), (vaddr_t) pdir, &pdirpa); |
2196 | | | 2196 | |
2197 | /* zero init area */ | | 2197 | /* zero init area */ |
2198 | memset (pdir, 0, PAGE_SIZE); /* Xen wants a clean page */ | | 2198 | memset (pdir, 0, PAGE_SIZE); /* Xen wants a clean page */ |
2199 | /* | | 2199 | /* |
2200 | * this pdir will NEVER be active in kernel mode | | 2200 | * this pdir will NEVER be active in kernel mode |
2201 | * so mark recursive entry invalid | | 2201 | * so mark recursive entry invalid |
2202 | */ | | 2202 | */ |
2203 | pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_u; | | 2203 | pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_k; |
2204 | /* | | 2204 | /* |
2205 | * PDP constructed this way won't be for kernel, | | 2205 | * PDP constructed this way won't be for kernel, |
2206 | * hence we don't put kernel mappings on Xen. | | 2206 | * hence we don't put kernel mappings on Xen. |
2207 | * But we need to make pmap_create() happy, so put a dummy (without | | 2207 | * But we need to make pmap_create() happy, so put a dummy (without |
2208 | * PG_V) value at the right place. | | 2208 | * PG_V) value at the right place. |
2209 | */ | | 2209 | */ |
2210 | pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] = | | 2210 | pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] = |
2211 | (pd_entry_t)-1 & PG_FRAME; | | 2211 | (pd_entry_t)-1 & PG_FRAME; |
2212 | #else /* XEN && __x86_64__*/ | | 2212 | #else /* XEN && __x86_64__*/ |
2213 | /* zero init area */ | | 2213 | /* zero init area */ |
2214 | memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t)); | | 2214 | memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t)); |
2215 | | | 2215 | |
2216 | object = (vaddr_t)v; | | 2216 | object = (vaddr_t)v; |