2 # Copyright (c) 2010,2015 Nathan Whitehorn
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/param.h>
32 #include <sys/mutex.h>
33 #include <sys/systm.h>
36 #include <vm/vm_page.h>
38 #include <machine/mmuvar.h>
41 * MOEA64 kobj methods for 64-bit Book-S page table
42 * manipulation routines used, for example, by hypervisors.
48 static moea64_pte_replace_t moea64_pte_replace_default;
50 static int64_t moea64_pte_replace_default(mmu_t mmu,
51 struct pvo_entry *pvo, int flags)
55 refchg = MOEA64_PTE_UNSET(mmu, pvo);
56 MOEA64_PTE_INSERT(mmu, pvo);
63 * Return ref/changed bits from PTE referenced by _pvo if _pvo is currently in
64 * the page table. Returns -1 if _pvo not currently present in the page table.
66 METHOD int64_t pte_synch {
68 struct pvo_entry *_pvo;
72 * Clear bits ptebit (a mask) from the low word of the PTE referenced by
73 * _pvo. Return previous values of ref/changed bits or -1 if _pvo is not
74 * currently in the page table.
76 METHOD int64_t pte_clear {
78 struct pvo_entry *_pvo;
83 * Invalidate the PTE referenced by _pvo, returning its ref/changed bits.
84 * Returns -1 if PTE not currently present in page table.
86 METHOD int64_t pte_unset {
88 struct pvo_entry *_pvo;
92 * Update the reference PTE to correspond to the contents of _pvo. Has the
93 * same ref/changed semantics as pte_unset() (and should clear R/C bits). May
94 * change the PVO's location in the page table or return with it unmapped if
95 * PVO_WIRED is not set. By default, does unset() followed by insert().
97 * _flags is a bitmask describing what level of page invalidation should occur:
98 * 0 means no invalidation is required
99 * MOEA64_PTE_PROT_UPDATE signifies that the page protection bits are changing
100 * MOEA64_PTE_INVALIDATE requires an invalidation of the same strength as
101 * pte_unset() followed by pte_insert()
103 METHOD int64_t pte_replace {
105 struct pvo_entry *_pvo;
107 } DEFAULT moea64_pte_replace_default;
110 * Insert a PTE corresponding to _pvo into the page table, returning any errors
111 * encountered and (optionally) setting the PVO slot value to some
112 * representation of where the entry was placed.
114 * Must not replace PTEs marked LPTE_WIRED. If an existing valid PTE is spilled,
115 * must synchronize ref/changed bits as in pte_unset().
117 METHOD int pte_insert {
119 struct pvo_entry *_pvo;