pmap.h revision 1.89.22.3 1 1.89.22.3 matt /* pmap.h,v 1.89.22.2 2008/01/09 01:46:42 matt Exp */
2 1.38 mycroft
3 1.40 thorpej /*
4 1.40 thorpej *
5 1.40 thorpej * Copyright (c) 1997 Charles D. Cranor and Washington University.
6 1.38 mycroft * All rights reserved.
7 1.38 mycroft *
8 1.38 mycroft * Redistribution and use in source and binary forms, with or without
9 1.38 mycroft * modification, are permitted provided that the following conditions
10 1.38 mycroft * are met:
11 1.38 mycroft * 1. Redistributions of source code must retain the above copyright
12 1.38 mycroft * notice, this list of conditions and the following disclaimer.
13 1.38 mycroft * 2. Redistributions in binary form must reproduce the above copyright
14 1.38 mycroft * notice, this list of conditions and the following disclaimer in the
15 1.38 mycroft * documentation and/or other materials provided with the distribution.
16 1.38 mycroft * 3. All advertising materials mentioning features or use of this software
17 1.40 thorpej * must display the following acknowledgment:
18 1.40 thorpej * This product includes software developed by Charles D. Cranor and
19 1.40 thorpej * Washington University.
20 1.40 thorpej * 4. The name of the author may not be used to endorse or promote products
21 1.40 thorpej * derived from this software without specific prior written permission.
22 1.1 cgd *
23 1.40 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.40 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.40 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.40 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.40 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.40 thorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.40 thorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.40 thorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.40 thorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.40 thorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1 cgd */
34 1.1 cgd
35 1.1 cgd /*
36 1.89.22.1 matt * Copyright (c) 2001 Wasabi Systems, Inc.
37 1.89.22.1 matt * All rights reserved.
38 1.89.22.1 matt *
39 1.89.22.1 matt * Written by Frank van der Linden for Wasabi Systems, Inc.
40 1.89.22.1 matt *
41 1.89.22.1 matt * Redistribution and use in source and binary forms, with or without
42 1.89.22.1 matt * modification, are permitted provided that the following conditions
43 1.89.22.1 matt * are met:
44 1.89.22.1 matt * 1. Redistributions of source code must retain the above copyright
45 1.89.22.1 matt * notice, this list of conditions and the following disclaimer.
46 1.89.22.1 matt * 2. Redistributions in binary form must reproduce the above copyright
47 1.89.22.1 matt * notice, this list of conditions and the following disclaimer in the
48 1.89.22.1 matt * documentation and/or other materials provided with the distribution.
49 1.89.22.1 matt * 3. All advertising materials mentioning features or use of this software
50 1.89.22.1 matt * must display the following acknowledgement:
51 1.89.22.1 matt * This product includes software developed for the NetBSD Project by
52 1.89.22.1 matt * Wasabi Systems, Inc.
53 1.89.22.1 matt * 4. The name of Wasabi Systems, Inc. may not be used to endorse
54 1.89.22.1 matt * or promote products derived from this software without specific prior
55 1.89.22.1 matt * written permission.
56 1.89.22.1 matt *
57 1.89.22.1 matt * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
58 1.89.22.1 matt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
59 1.89.22.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60 1.89.22.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
61 1.89.22.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
62 1.89.22.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
63 1.89.22.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
64 1.89.22.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
65 1.89.22.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66 1.89.22.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67 1.89.22.1 matt * POSSIBILITY OF SUCH DAMAGE.
68 1.1 cgd */
69 1.34 mrg
70 1.40 thorpej #ifndef _I386_PMAP_H_
71 1.40 thorpej #define _I386_PMAP_H_
72 1.40 thorpej
73 1.58 mrg #if defined(_KERNEL_OPT)
74 1.39 thorpej #include "opt_user_ldt.h"
75 1.89.22.3 matt #include "opt_xen.h"
76 1.34 mrg #endif
77 1.1 cgd
78 1.89.22.2 matt #include <sys/atomic.h>
79 1.89.22.2 matt
80 1.6 mycroft #include <machine/pte.h>
81 1.39 thorpej #include <machine/segments.h>
82 1.89.22.1 matt #if defined(_KERNEL)
83 1.89.22.1 matt #include <machine/cpufunc.h>
84 1.89.22.1 matt #endif
85 1.89.22.1 matt
86 1.40 thorpej #include <uvm/uvm_object.h>
87 1.89.22.3 matt #ifdef XEN
88 1.89.22.3 matt #include <xen/xenfunc.h>
89 1.89.22.3 matt #include <xen/xenpmap.h>
90 1.89.22.3 matt #endif /* XEN */
91 1.1 cgd
92 1.1 cgd /*
93 1.40 thorpej * see pte.h for a description of i386 MMU terminology and hardware
94 1.40 thorpej * interface.
95 1.40 thorpej *
96 1.89.22.3 matt * a pmap describes a processes' 4GB virtual address space. when PAE
97 1.89.22.3 matt * is not in use, this virtual address space can be broken up into 1024 4MB
98 1.89.22.3 matt * regions which are described by PDEs in the PDP. the PDEs are defined as
99 1.89.22.3 matt * follows:
100 1.40 thorpej *
101 1.40 thorpej * (ranges are inclusive -> exclusive, just like vm_map_entry start/end)
102 1.43 thorpej * (the following assumes that KERNBASE is 0xc0000000)
103 1.40 thorpej *
104 1.40 thorpej * PDE#s VA range usage
105 1.68 drochner * 0->766 0x0 -> 0xbfc00000 user address space
106 1.61 yamt * 767 0xbfc00000-> recursive mapping of PDP (used for
107 1.43 thorpej * 0xc0000000 linear mapping of PTPs)
108 1.43 thorpej * 768->1023 0xc0000000-> kernel address space (constant
109 1.40 thorpej * 0xffc00000 across all pmap's/processes)
110 1.40 thorpej * 1023 0xffc00000-> "alternate" recursive PDP mapping
111 1.40 thorpej * <end> (for other pmaps)
112 1.40 thorpej *
113 1.40 thorpej *
114 1.40 thorpej * note: a recursive PDP mapping provides a way to map all the PTEs for
115 1.41 chs * a 4GB address space into a linear chunk of virtual memory. in other
116 1.41 chs * words, the PTE for page 0 is the first int mapped into the 4MB recursive
117 1.41 chs * area. the PTE for page 1 is the second int. the very last int in the
118 1.81 junyoung * 4MB range is the PTE that maps VA 0xfffff000 (the last page in a 4GB
119 1.40 thorpej * address).
120 1.40 thorpej *
121 1.43 thorpej * all pmap's PD's must have the same values in slots 768->1023 so that
122 1.41 chs * the kernel is always mapped in every process. these values are loaded
123 1.40 thorpej * into the PD at pmap creation time.
124 1.40 thorpej *
125 1.41 chs * at any one time only one pmap can be active on a processor. this is
126 1.41 chs * the pmap whose PDP is pointed to by processor register %cr3. this pmap
127 1.40 thorpej * will have all its PTEs mapped into memory at the recursive mapping
128 1.43 thorpej * point (slot #767 as show above). when the pmap code wants to find the
129 1.40 thorpej * PTE for a virtual address, all it has to do is the following:
130 1.40 thorpej *
131 1.71 thorpej * address of PTE = (767 * 4MB) + (VA / PAGE_SIZE) * sizeof(pt_entry_t)
132 1.43 thorpej * = 0xbfc00000 + (VA / 4096) * 4
133 1.40 thorpej *
134 1.40 thorpej * what happens if the pmap layer is asked to perform an operation
135 1.41 chs * on a pmap that is not the one which is currently active? in that
136 1.41 chs * case we take the PA of the PDP of non-active pmap and put it in
137 1.41 chs * slot 1023 of the active pmap. this causes the non-active pmap's
138 1.40 thorpej * PTEs to get mapped in the final 4MB of the 4GB address space
139 1.40 thorpej * (e.g. starting at 0xffc00000).
140 1.40 thorpej *
141 1.40 thorpej * the following figure shows the effects of the recursive PDP mapping:
142 1.40 thorpej *
143 1.40 thorpej * PDP (%cr3)
144 1.40 thorpej * +----+
145 1.40 thorpej * | 0| -> PTP#0 that maps VA 0x0 -> 0x400000
146 1.40 thorpej * | |
147 1.40 thorpej * | |
148 1.43 thorpej * | 767| -> points back to PDP (%cr3) mapping VA 0xbfc00000 -> 0xc0000000
149 1.83 junyoung * | 768| -> first kernel PTP (maps 0xc0000000 -> 0xc0400000)
150 1.40 thorpej * | |
151 1.40 thorpej * |1023| -> points to alternate pmap's PDP (maps 0xffc00000 -> end)
152 1.40 thorpej * +----+
153 1.40 thorpej *
154 1.43 thorpej * note that the PDE#767 VA (0xbfc00000) is defined as "PTE_BASE"
155 1.40 thorpej * note that the PDE#1023 VA (0xffc00000) is defined as "APTE_BASE"
156 1.40 thorpej *
157 1.43 thorpej * starting at VA 0xbfc00000 the current active PDP (%cr3) acts as a
158 1.40 thorpej * PTP:
159 1.40 thorpej *
160 1.43 thorpej * PTP#767 == PDP(%cr3) => maps VA 0xbfc00000 -> 0xc0000000
161 1.40 thorpej * +----+
162 1.43 thorpej * | 0| -> maps the contents of PTP#0 at VA 0xbfc00000->0xbfc01000
163 1.40 thorpej * | |
164 1.40 thorpej * | |
165 1.81 junyoung * | 767| -> maps contents of PTP#767 (the PDP) at VA 0xbfeff000
166 1.43 thorpej * | 768| -> maps contents of first kernel PTP
167 1.40 thorpej * | |
168 1.40 thorpej * |1023|
169 1.40 thorpej * +----+
170 1.40 thorpej *
171 1.81 junyoung * note that mapping of the PDP at PTP#767's VA (0xbfeff000) is
172 1.40 thorpej * defined as "PDP_BASE".... within that mapping there are two
173 1.41 chs * defines:
174 1.59 chs * "PDP_PDE" (0xbfeffbfc) is the VA of the PDE in the PDP
175 1.41 chs * which points back to itself.
176 1.59 chs * "APDP_PDE" (0xbfeffffc) is the VA of the PDE in the PDP which
177 1.40 thorpej * establishes the recursive mapping of the alternate pmap.
178 1.40 thorpej * to set the alternate PDP, one just has to put the correct
179 1.40 thorpej * PA info in *APDP_PDE.
180 1.40 thorpej *
181 1.41 chs * note that in the APTE_BASE space, the APDP appears at VA
182 1.40 thorpej * "APDP_BASE" (0xfffff000).
183 1.89.22.3 matt *
184 1.89.22.3 matt * When PAE is in use, the L3 page directory breaks up the address space in
185 1.89.22.3 matt * 4 1GB * regions, each of them broken in 512 2MB regions by the L2 PD
186 1.89.22.3 matt * (the size of the pages at the L1 level is still 4K).
187 1.89.22.3 matt * The kernel virtual space is mapped by the last entry in the L3 page,
188 1.89.22.3 matt * the first 3 entries mapping the user VA space.
189 1.89.22.3 matt * Because the L3 has only 4 entries of 1GB each, we can't use recursive
190 1.89.22.3 matt * mappings at this level for PDP_PDE and APDP_PDE (this would eat 2 of the
191 1.89.22.3 matt * 4GB virtual space). There's also restrictions imposed by Xen on the
192 1.89.22.3 matt * last entry of the L3 PD, which makes it hard to use one L3 page per pmap
193 1.89.22.3 matt * switch %cr3 to switch pmaps. So we use one static L3 page which is
194 1.89.22.3 matt * always loaded in %cr3, and we use it as 2 virtual PD pointers: one for
195 1.89.22.3 matt * kenrel space (L3[3], always loaded), and one for user space (in fact the
196 1.89.22.3 matt * first 3 entries of the L3 PD), and we claim the VM has only a 2-level
197 1.89.22.3 matt * PTP (with the L2 index extended by 2 bytes).
198 1.89.22.3 matt * PTE_BASE and APTE_BASE will need 4 entries in the L2 page table.
199 1.89.22.3 matt * In addition, we can't recursively map L3[3] (Xen wants the ref count on
200 1.89.22.3 matt * this page to be exactly once), so we use a shadow PD page for the last
201 1.89.22.3 matt * L2 PD. The shadow page could be static too, but to make pm_pdir[]
202 1.89.22.3 matt * contigous we'll allocate/copy one page per pmap.
203 1.1 cgd */
204 1.65 fvdl /* XXX MP should we allocate one APDP_PDE per processor?? */
205 1.33 mrg
206 1.33 mrg /*
207 1.89.22.1 matt * Mask to get rid of the sign-extended part of addresses.
208 1.89.22.1 matt */
209 1.89.22.1 matt #define VA_SIGN_MASK 0
210 1.89.22.1 matt #define VA_SIGN_NEG(va) ((va) | VA_SIGN_MASK)
211 1.89.22.1 matt /*
212 1.89.22.1 matt * XXXfvdl this one's not right.
213 1.89.22.1 matt */
214 1.89.22.1 matt #define VA_SIGN_POS(va) ((va) & ~VA_SIGN_MASK)
215 1.89.22.1 matt
216 1.89.22.1 matt /*
217 1.40 thorpej * the following defines identify the slots used as described above.
218 1.33 mrg */
219 1.89.22.3 matt #ifdef PAE
220 1.89.22.3 matt #define L2_SLOT_PTE (KERNBASE/NBPD_L2-4) /* 1532: for recursive PDP map */
221 1.89.22.3 matt #define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 1536: start of kernel space */
222 1.89.22.3 matt #define L2_SLOT_KERNBASE L2_SLOT_KERN
223 1.89.22.3 matt #define L2_SLOT_APTE 1960 /* 1964-2047 reserved by Xen */
224 1.89.22.3 matt #else /* PAE */
225 1.89.22.3 matt #define L2_SLOT_PTE (KERNBASE/NBPD_L2-1) /* 767: for recursive PDP map */
226 1.89.22.3 matt #define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 768: start of kernel space */
227 1.89.22.1 matt #define L2_SLOT_KERNBASE L2_SLOT_KERN
228 1.89.22.3 matt #ifndef XEN
229 1.89.22.3 matt #define L2_SLOT_APTE 1023 /* 1023: alternative recursive slot */
230 1.89.22.3 matt #else
231 1.89.22.3 matt #define L2_SLOT_APTE 1007 /* 1008-1023 reserved by Xen */
232 1.89.22.3 matt #endif
233 1.89.22.3 matt #endif /* PAE */
234 1.89.22.3 matt
235 1.89.22.1 matt
236 1.89.22.1 matt #define PDIR_SLOT_KERN L2_SLOT_KERN
237 1.89.22.1 matt #define PDIR_SLOT_PTE L2_SLOT_PTE
238 1.89.22.1 matt #define PDIR_SLOT_APTE L2_SLOT_APTE
239 1.1 cgd
240 1.1 cgd /*
241 1.41 chs * the following defines give the virtual addresses of various MMU
242 1.40 thorpej * data structures:
243 1.40 thorpej * PTE_BASE and APTE_BASE: the base VA of the linear PTE mappings
244 1.81 junyoung * PDP_BASE and APDP_BASE: the base VA of the recursive mapping of the PDP
245 1.40 thorpej * PDP_PDE and APDP_PDE: the VA of the PDE that points back to the PDP/APDP
246 1.1 cgd */
247 1.29 fvdl
248 1.89.22.3 matt #define PTE_BASE ((pt_entry_t *) (PDIR_SLOT_PTE * NBPD_L2))
249 1.89.22.3 matt #define APTE_BASE ((pt_entry_t *) (VA_SIGN_NEG((PDIR_SLOT_APTE * NBPD_L2))))
250 1.40 thorpej
251 1.89.22.1 matt #define L1_BASE PTE_BASE
252 1.89.22.1 matt #define AL1_BASE APTE_BASE
253 1.40 thorpej
254 1.89.22.1 matt #define L2_BASE ((pd_entry_t *)((char *)L1_BASE + L2_SLOT_PTE * NBPD_L1))
255 1.89.22.1 matt #define AL2_BASE ((pd_entry_t *)((char *)AL1_BASE + L2_SLOT_PTE * NBPD_L1))
256 1.40 thorpej
257 1.89.22.1 matt #define PDP_PDE (L2_BASE + PDIR_SLOT_PTE)
258 1.89.22.3 matt #ifdef PAE
259 1.89.22.3 matt /*
260 1.89.22.3 matt * when PAE is in use we can't write APDP_PDE though the recursive mapping,
261 1.89.22.3 matt * because it points to the shadow PD. Use the kernel PD instead, which is
262 1.89.22.3 matt * static
263 1.89.22.3 matt */
264 1.89.22.3 matt #define APDP_PDE (&pmap_kl2pd[l2tol2(PDIR_SLOT_APTE)])
265 1.89.22.3 matt #define APDP_PDE_SHADOW (L2_BASE + PDIR_SLOT_APTE)
266 1.89.22.3 matt #else /* PAE */
267 1.89.22.1 matt #define APDP_PDE (L2_BASE + PDIR_SLOT_APTE)
268 1.89.22.3 matt #endif /* PAE */
269 1.40 thorpej
270 1.89.22.1 matt #define PDP_BASE L2_BASE
271 1.89.22.1 matt #define APDP_BASE AL2_BASE
272 1.40 thorpej
273 1.89.22.1 matt /* largest value (-1 for APTP space) */
274 1.89.22.1 matt #define NKL2_MAX_ENTRIES (NTOPLEVEL_PDES - (KERNBASE/NBPD_L2) - 1)
275 1.89.22.1 matt #define NKL1_MAX_ENTRIES (unsigned long)(NKL2_MAX_ENTRIES * NPDPG)
276 1.65 fvdl
277 1.89.22.1 matt #define NKL2_KIMG_ENTRIES 0 /* XXX unused */
278 1.44 thorpej
279 1.89.22.1 matt #define NKL2_START_ENTRIES 0 /* XXX computed on runtime */
280 1.89.22.1 matt #define NKL1_START_ENTRIES 0 /* XXX unused */
281 1.40 thorpej
282 1.89.22.3 matt #ifdef PAE
283 1.89.22.3 matt #define NTOPLEVEL_PDES (PAGE_SIZE * 4 / (sizeof (pd_entry_t)))
284 1.89.22.3 matt #else
285 1.89.22.1 matt #define NTOPLEVEL_PDES (PAGE_SIZE / (sizeof (pd_entry_t)))
286 1.89.22.3 matt #endif
287 1.63 chs
288 1.89.22.1 matt #define NPDPG (PAGE_SIZE / sizeof (pd_entry_t))
289 1.40 thorpej
290 1.89.22.1 matt #define PTP_MASK_INITIALIZER { L1_FRAME, L2_FRAME }
291 1.89.22.1 matt #define PTP_SHIFT_INITIALIZER { L1_SHIFT, L2_SHIFT }
292 1.89.22.1 matt #define NKPTP_INITIALIZER { NKL1_START_ENTRIES, NKL2_START_ENTRIES }
293 1.89.22.1 matt #define NKPTPMAX_INITIALIZER { NKL1_MAX_ENTRIES, NKL2_MAX_ENTRIES }
294 1.89.22.1 matt #define NBPD_INITIALIZER { NBPD_L1, NBPD_L2 }
295 1.89.22.1 matt #define PDES_INITIALIZER { L2_BASE }
296 1.89.22.1 matt #define APDES_INITIALIZER { AL2_BASE }
297 1.40 thorpej
298 1.89.22.1 matt #define PTP_LEVELS 2
299 1.11 mycroft
300 1.40 thorpej /*
301 1.89.22.1 matt * PG_AVAIL usage: we make use of the ignored bits of the PTE
302 1.40 thorpej */
303 1.40 thorpej
304 1.89.22.1 matt #define PG_W PG_AVAIL1 /* "wired" mapping */
305 1.89.22.1 matt #define PG_PVLIST PG_AVAIL2 /* mapping has entry on pvlist */
306 1.89.22.1 matt #define PG_X PG_AVAIL3 /* executable mapping */
307 1.47 thorpej
308 1.47 thorpej /*
309 1.89.22.1 matt * Number of PTE's per cache line. 4 byte pte, 32-byte cache line
310 1.89.22.1 matt * Used to avoid false sharing of cache lines.
311 1.47 thorpej */
312 1.89.22.3 matt #ifdef PAE
313 1.89.22.3 matt #define NPTECL 4
314 1.89.22.3 matt #else
315 1.89.22.1 matt #define NPTECL 8
316 1.89.22.3 matt #endif
317 1.89.22.3 matt
318 1.89.22.3 matt #include <x86/pmap.h>
319 1.47 thorpej
320 1.89.22.3 matt #ifndef XEN
321 1.89.22.2 matt #define pmap_pa2pte(a) (a)
322 1.89.22.2 matt #define pmap_pte2pa(a) ((a) & PG_FRAME)
323 1.89.22.2 matt #define pmap_pte_set(p, n) do { *(p) = (n); } while (0)
324 1.89.22.3 matt #define pmap_pte_cas(p, o, n) atomic_cas_32((p), (o), (n))
325 1.89.22.2 matt #define pmap_pte_testset(p, n) \
326 1.89.22.2 matt atomic_swap_ulong((volatile unsigned long *)p, n)
327 1.89.22.2 matt #define pmap_pte_setbits(p, b) \
328 1.89.22.2 matt atomic_or_ulong((volatile unsigned long *)p, b)
329 1.89.22.2 matt #define pmap_pte_clearbits(p, b) \
330 1.89.22.2 matt atomic_and_ulong((volatile unsigned long *)p, ~(b))
331 1.89.22.2 matt #define pmap_pte_flush() /* nothing */
332 1.89.22.3 matt #else
333 1.89.22.3 matt static __inline pt_entry_t
334 1.89.22.3 matt pmap_pa2pte(paddr_t pa)
335 1.89.22.3 matt {
336 1.89.22.3 matt return (pt_entry_t)xpmap_ptom_masked(pa);
337 1.89.22.3 matt }
338 1.89.22.3 matt
339 1.89.22.3 matt static __inline paddr_t
340 1.89.22.3 matt pmap_pte2pa(pt_entry_t pte)
341 1.89.22.3 matt {
342 1.89.22.3 matt return xpmap_mtop_masked(pte & PG_FRAME);
343 1.89.22.3 matt }
344 1.89.22.3 matt static __inline void
345 1.89.22.3 matt pmap_pte_set(pt_entry_t *pte, pt_entry_t npte)
346 1.89.22.3 matt {
347 1.89.22.3 matt int s = splvm();
348 1.89.22.3 matt xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
349 1.89.22.3 matt splx(s);
350 1.89.22.3 matt }
351 1.89.22.3 matt
352 1.89.22.3 matt static __inline pt_entry_t
353 1.89.22.3 matt pmap_pte_cas(volatile pt_entry_t *ptep, pt_entry_t o, pt_entry_t n)
354 1.89.22.3 matt {
355 1.89.22.3 matt int s = splvm();
356 1.89.22.3 matt pt_entry_t opte = *ptep;
357 1.89.22.3 matt
358 1.89.22.3 matt if (opte == o) {
359 1.89.22.3 matt xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(ptep)), n);
360 1.89.22.3 matt xpq_flush_queue();
361 1.89.22.3 matt }
362 1.89.22.3 matt splx(s);
363 1.89.22.3 matt return opte;
364 1.89.22.3 matt }
365 1.89.22.3 matt
366 1.89.22.3 matt static __inline pt_entry_t
367 1.89.22.3 matt pmap_pte_testset(volatile pt_entry_t *pte, pt_entry_t npte)
368 1.89.22.3 matt {
369 1.89.22.3 matt int s = splvm();
370 1.89.22.3 matt pt_entry_t opte = *pte;
371 1.89.22.3 matt xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
372 1.89.22.3 matt npte);
373 1.89.22.3 matt xpq_flush_queue();
374 1.89.22.3 matt splx(s);
375 1.89.22.3 matt return opte;
376 1.89.22.3 matt }
377 1.89.22.3 matt
378 1.89.22.3 matt static __inline void
379 1.89.22.3 matt pmap_pte_setbits(volatile pt_entry_t *pte, pt_entry_t bits)
380 1.89.22.3 matt {
381 1.89.22.3 matt int s = splvm();
382 1.89.22.3 matt xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)), (*pte) | bits);
383 1.89.22.3 matt xpq_flush_queue();
384 1.89.22.3 matt splx(s);
385 1.89.22.3 matt }
386 1.89.22.3 matt
387 1.89.22.3 matt static __inline void
388 1.89.22.3 matt pmap_pte_clearbits(volatile pt_entry_t *pte, pt_entry_t bits)
389 1.89.22.3 matt {
390 1.89.22.3 matt int s = splvm();
391 1.89.22.3 matt xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
392 1.89.22.3 matt (*pte) & ~bits);
393 1.89.22.3 matt xpq_flush_queue();
394 1.89.22.3 matt splx(s);
395 1.89.22.3 matt }
396 1.89.22.3 matt
397 1.89.22.3 matt static __inline void
398 1.89.22.3 matt pmap_pte_flush(void)
399 1.89.22.3 matt {
400 1.89.22.3 matt int s = splvm();
401 1.89.22.3 matt xpq_flush_queue();
402 1.89.22.3 matt splx(s);
403 1.89.22.3 matt }
404 1.89.22.3 matt
405 1.89.22.3 matt #endif
406 1.89.22.3 matt
407 1.89.22.3 matt #ifdef PAE
408 1.89.22.3 matt /* addresses of static pages used for PAE pmap: */
409 1.89.22.3 matt /* the L3 page */
410 1.89.22.3 matt pd_entry_t *pmap_l3pd;
411 1.89.22.3 matt paddr_t pmap_l3paddr;
412 1.89.22.3 matt /* the kernel's L2 page */
413 1.89.22.3 matt pd_entry_t *pmap_kl2pd;
414 1.89.22.3 matt paddr_t pmap_kl2paddr;
415 1.89.22.3 matt #endif
416 1.35 cgd
417 1.39 thorpej
418 1.89.22.1 matt struct trapframe;
419 1.73 thorpej
420 1.89.22.1 matt int pmap_exec_fixup(struct vm_map *, struct trapframe *, struct pcb *);
421 1.89.22.1 matt void pmap_ldt_cleanup(struct lwp *);
422 1.1 cgd
423 1.40 thorpej #endif /* _I386_PMAP_H_ */
424