2 * Copyright (c) 2006 Kip Macy
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
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/queue.h>
38 #include <sys/mutex.h>
40 #include <sys/sched.h>
42 #include <sys/sysctl.h>
43 #include <sys/systm.h>
46 #include <vm/vm_page.h>
48 #include <machine/cpufunc.h>
49 #include <machine/smp.h>
50 #include <machine/mmu.h>
51 #include <machine/tte.h>
52 #include <machine/cpu.h>
53 #include <machine/tte_hash.h>
56 tte_clear_phys_bit(vm_page_t m, uint64_t flags)
59 tte_t active_flags = (flags & ~VTD_SW_W);
61 if (m->flags & PG_FICTITIOUS)
64 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
66 * Loop over all current mappings setting/clearing as appropos If
67 * setting RO do we need to clear the VAC?
69 TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
70 tte_t otte_data, matchbits;
75 otte_data = tte_hash_clear_bits(pmap->pm_hash, pv->pv_va, flags);
76 if ((matchbits = (otte_data & active_flags)) != 0) {
77 if ((otte_data & (VTD_SW_W|VTD_W)) == (VTD_SW_W|VTD_W))
79 pmap_invalidate_page(pmap, pv->pv_va, TRUE);
86 tte_get_phys_bit(vm_page_t m, uint64_t flags)
94 if (m->flags & PG_FICTITIOUS)
97 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
98 TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
102 otte_data = tte_hash_lookup(pmap->pm_hash, pv->pv_va);
103 if ((rv = ((otte_data & flags) != 0)))
111 tte_clear_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags)
113 (void)tte_hash_clear_bits(pmap->pm_hash, va, flags);
117 tte_set_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags)
123 tte_get_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags)
127 tte_data = tte_hash_lookup(pmap->pm_hash, va);
129 return ((tte_data & flags) == flags);