186be9f0dSKonstantin Belousov /*- 286be9f0dSKonstantin Belousov * Copyright (c) 2013 The FreeBSD Foundation 386be9f0dSKonstantin Belousov * All rights reserved. 486be9f0dSKonstantin Belousov * 586be9f0dSKonstantin Belousov * This software was developed by Konstantin Belousov <kib@FreeBSD.org> 686be9f0dSKonstantin Belousov * under sponsorship from the FreeBSD Foundation. 786be9f0dSKonstantin Belousov * 886be9f0dSKonstantin Belousov * Redistribution and use in source and binary forms, with or without 986be9f0dSKonstantin Belousov * modification, are permitted provided that the following conditions 1086be9f0dSKonstantin Belousov * are met: 1186be9f0dSKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 1286be9f0dSKonstantin Belousov * notice, this list of conditions and the following disclaimer. 1386be9f0dSKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 1486be9f0dSKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 1586be9f0dSKonstantin Belousov * documentation and/or other materials provided with the distribution. 1686be9f0dSKonstantin Belousov * 1786be9f0dSKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1886be9f0dSKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1986be9f0dSKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2086be9f0dSKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2186be9f0dSKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2286be9f0dSKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2386be9f0dSKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2486be9f0dSKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2586be9f0dSKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2686be9f0dSKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2786be9f0dSKonstantin Belousov * SUCH DAMAGE. 2886be9f0dSKonstantin Belousov */ 2986be9f0dSKonstantin Belousov 3086be9f0dSKonstantin Belousov #include <sys/cdefs.h> 3186be9f0dSKonstantin Belousov __FBSDID("$FreeBSD$"); 3286be9f0dSKonstantin Belousov 3386be9f0dSKonstantin Belousov #include <sys/param.h> 3486be9f0dSKonstantin Belousov #include <sys/bus.h> 3586be9f0dSKonstantin Belousov #include <sys/kernel.h> 3686be9f0dSKonstantin Belousov #include <sys/lock.h> 3786be9f0dSKonstantin Belousov #include <sys/malloc.h> 3886be9f0dSKonstantin Belousov #include <sys/memdesc.h> 3986be9f0dSKonstantin Belousov #include <sys/mutex.h> 4086be9f0dSKonstantin Belousov #include <sys/proc.h> 4186be9f0dSKonstantin Belousov #include <sys/queue.h> 4286be9f0dSKonstantin Belousov #include <sys/rman.h> 4386be9f0dSKonstantin Belousov #include <sys/rwlock.h> 4486be9f0dSKonstantin Belousov #include <sys/sched.h> 4586be9f0dSKonstantin Belousov #include <sys/sf_buf.h> 4686be9f0dSKonstantin Belousov #include <sys/sysctl.h> 4786be9f0dSKonstantin Belousov #include <sys/systm.h> 4886be9f0dSKonstantin Belousov #include <sys/taskqueue.h> 4986be9f0dSKonstantin Belousov #include <sys/tree.h> 500a110d5bSKonstantin Belousov #include <sys/vmem.h> 5167499354SRyan Stone #include <dev/pci/pcivar.h> 5286be9f0dSKonstantin Belousov #include <vm/vm.h> 5386be9f0dSKonstantin Belousov #include <vm/vm_extern.h> 5486be9f0dSKonstantin Belousov #include <vm/vm_kern.h> 5586be9f0dSKonstantin Belousov #include <vm/vm_object.h> 5686be9f0dSKonstantin Belousov #include <vm/vm_page.h> 5786be9f0dSKonstantin Belousov #include <vm/vm_map.h> 5886be9f0dSKonstantin Belousov #include <vm/vm_pageout.h> 5986be9f0dSKonstantin Belousov #include <machine/bus.h> 6086be9f0dSKonstantin Belousov #include <machine/cpu.h> 610a110d5bSKonstantin Belousov #include <machine/intr_machdep.h> 620a110d5bSKonstantin Belousov #include <x86/include/apicvar.h> 6386be9f0dSKonstantin Belousov #include <x86/include/busdma_impl.h> 6486be9f0dSKonstantin Belousov #include <x86/iommu/intel_reg.h> 6586be9f0dSKonstantin Belousov #include <x86/iommu/busdma_dmar.h> 6686be9f0dSKonstantin Belousov #include <x86/iommu/intel_dmar.h> 6786be9f0dSKonstantin Belousov 6886be9f0dSKonstantin Belousov u_int 6986be9f0dSKonstantin Belousov dmar_nd2mask(u_int nd) 7086be9f0dSKonstantin Belousov { 7186be9f0dSKonstantin Belousov static const u_int masks[] = { 7286be9f0dSKonstantin Belousov 0x000f, /* nd == 0 */ 7386be9f0dSKonstantin Belousov 0x002f, /* nd == 1 */ 7486be9f0dSKonstantin Belousov 0x00ff, /* nd == 2 */ 7586be9f0dSKonstantin Belousov 0x02ff, /* nd == 3 */ 7686be9f0dSKonstantin Belousov 0x0fff, /* nd == 4 */ 7786be9f0dSKonstantin Belousov 0x2fff, /* nd == 5 */ 7886be9f0dSKonstantin Belousov 0xffff, /* nd == 6 */ 7986be9f0dSKonstantin Belousov 0x0000, /* nd == 7 reserved */ 8086be9f0dSKonstantin Belousov }; 8186be9f0dSKonstantin Belousov 8286be9f0dSKonstantin Belousov KASSERT(nd <= 6, ("number of domains %d", nd)); 8386be9f0dSKonstantin Belousov return (masks[nd]); 8486be9f0dSKonstantin Belousov } 8586be9f0dSKonstantin Belousov 8686be9f0dSKonstantin Belousov static const struct sagaw_bits_tag { 8786be9f0dSKonstantin Belousov int agaw; 8886be9f0dSKonstantin Belousov int cap; 8986be9f0dSKonstantin Belousov int awlvl; 9086be9f0dSKonstantin Belousov int pglvl; 9186be9f0dSKonstantin Belousov } sagaw_bits[] = { 9286be9f0dSKonstantin Belousov {.agaw = 30, .cap = DMAR_CAP_SAGAW_2LVL, .awlvl = DMAR_CTX2_AW_2LVL, 9386be9f0dSKonstantin Belousov .pglvl = 2}, 9486be9f0dSKonstantin Belousov {.agaw = 39, .cap = DMAR_CAP_SAGAW_3LVL, .awlvl = DMAR_CTX2_AW_3LVL, 9586be9f0dSKonstantin Belousov .pglvl = 3}, 9686be9f0dSKonstantin Belousov {.agaw = 48, .cap = DMAR_CAP_SAGAW_4LVL, .awlvl = DMAR_CTX2_AW_4LVL, 9786be9f0dSKonstantin Belousov .pglvl = 4}, 9886be9f0dSKonstantin Belousov {.agaw = 57, .cap = DMAR_CAP_SAGAW_5LVL, .awlvl = DMAR_CTX2_AW_5LVL, 9986be9f0dSKonstantin Belousov .pglvl = 5}, 10086be9f0dSKonstantin Belousov {.agaw = 64, .cap = DMAR_CAP_SAGAW_6LVL, .awlvl = DMAR_CTX2_AW_6LVL, 10186be9f0dSKonstantin Belousov .pglvl = 6} 10286be9f0dSKonstantin Belousov }; 10386be9f0dSKonstantin Belousov 10486be9f0dSKonstantin Belousov bool 10586be9f0dSKonstantin Belousov dmar_pglvl_supported(struct dmar_unit *unit, int pglvl) 10686be9f0dSKonstantin Belousov { 10786be9f0dSKonstantin Belousov int i; 10886be9f0dSKonstantin Belousov 109*1abfd355SKonstantin Belousov for (i = 0; i < nitems(sagaw_bits); i++) { 11086be9f0dSKonstantin Belousov if (sagaw_bits[i].pglvl != pglvl) 11186be9f0dSKonstantin Belousov continue; 11286be9f0dSKonstantin Belousov if ((DMAR_CAP_SAGAW(unit->hw_cap) & sagaw_bits[i].cap) != 0) 11386be9f0dSKonstantin Belousov return (true); 11486be9f0dSKonstantin Belousov } 11586be9f0dSKonstantin Belousov return (false); 11686be9f0dSKonstantin Belousov } 11786be9f0dSKonstantin Belousov 11886be9f0dSKonstantin Belousov int 119*1abfd355SKonstantin Belousov domain_set_agaw(struct dmar_domain *domain, int mgaw) 12086be9f0dSKonstantin Belousov { 12186be9f0dSKonstantin Belousov int sagaw, i; 12286be9f0dSKonstantin Belousov 123*1abfd355SKonstantin Belousov domain->mgaw = mgaw; 124*1abfd355SKonstantin Belousov sagaw = DMAR_CAP_SAGAW(domain->dmar->hw_cap); 125*1abfd355SKonstantin Belousov for (i = 0; i < nitems(sagaw_bits); i++) { 12686be9f0dSKonstantin Belousov if (sagaw_bits[i].agaw >= mgaw) { 127*1abfd355SKonstantin Belousov domain->agaw = sagaw_bits[i].agaw; 128*1abfd355SKonstantin Belousov domain->pglvl = sagaw_bits[i].pglvl; 129*1abfd355SKonstantin Belousov domain->awlvl = sagaw_bits[i].awlvl; 13086be9f0dSKonstantin Belousov return (0); 13186be9f0dSKonstantin Belousov } 13286be9f0dSKonstantin Belousov } 133*1abfd355SKonstantin Belousov device_printf(domain->dmar->dev, 134*1abfd355SKonstantin Belousov "context request mgaw %d: no agaw found, sagaw %x\n", 135*1abfd355SKonstantin Belousov mgaw, sagaw); 13686be9f0dSKonstantin Belousov return (EINVAL); 13786be9f0dSKonstantin Belousov } 13886be9f0dSKonstantin Belousov 13986be9f0dSKonstantin Belousov /* 14086be9f0dSKonstantin Belousov * Find a best fit mgaw for the given maxaddr: 14186be9f0dSKonstantin Belousov * - if allow_less is false, must find sagaw which maps all requested 14286be9f0dSKonstantin Belousov * addresses (used by identity mappings); 14386be9f0dSKonstantin Belousov * - if allow_less is true, and no supported sagaw can map all requested 14486be9f0dSKonstantin Belousov * address space, accept the biggest sagaw, whatever is it. 14586be9f0dSKonstantin Belousov */ 14686be9f0dSKonstantin Belousov int 14786be9f0dSKonstantin Belousov dmar_maxaddr2mgaw(struct dmar_unit *unit, dmar_gaddr_t maxaddr, bool allow_less) 14886be9f0dSKonstantin Belousov { 14986be9f0dSKonstantin Belousov int i; 15086be9f0dSKonstantin Belousov 151*1abfd355SKonstantin Belousov for (i = 0; i < nitems(sagaw_bits); i++) { 15286be9f0dSKonstantin Belousov if ((1ULL << sagaw_bits[i].agaw) >= maxaddr && 15386be9f0dSKonstantin Belousov (DMAR_CAP_SAGAW(unit->hw_cap) & sagaw_bits[i].cap) != 0) 15486be9f0dSKonstantin Belousov break; 15586be9f0dSKonstantin Belousov } 156*1abfd355SKonstantin Belousov if (allow_less && i == nitems(sagaw_bits)) { 15786be9f0dSKonstantin Belousov do { 15886be9f0dSKonstantin Belousov i--; 15986be9f0dSKonstantin Belousov } while ((DMAR_CAP_SAGAW(unit->hw_cap) & sagaw_bits[i].cap) 16086be9f0dSKonstantin Belousov == 0); 16186be9f0dSKonstantin Belousov } 162*1abfd355SKonstantin Belousov if (i < nitems(sagaw_bits)) 16386be9f0dSKonstantin Belousov return (sagaw_bits[i].agaw); 16486be9f0dSKonstantin Belousov KASSERT(0, ("no mgaw for maxaddr %jx allow_less %d", 16586be9f0dSKonstantin Belousov (uintmax_t) maxaddr, allow_less)); 16686be9f0dSKonstantin Belousov return (-1); 16786be9f0dSKonstantin Belousov } 16886be9f0dSKonstantin Belousov 16986be9f0dSKonstantin Belousov /* 17086be9f0dSKonstantin Belousov * Calculate the total amount of page table pages needed to map the 17186be9f0dSKonstantin Belousov * whole bus address space on the context with the selected agaw. 17286be9f0dSKonstantin Belousov */ 17386be9f0dSKonstantin Belousov vm_pindex_t 17486be9f0dSKonstantin Belousov pglvl_max_pages(int pglvl) 17586be9f0dSKonstantin Belousov { 17686be9f0dSKonstantin Belousov vm_pindex_t res; 17786be9f0dSKonstantin Belousov int i; 17886be9f0dSKonstantin Belousov 17986be9f0dSKonstantin Belousov for (res = 0, i = pglvl; i > 0; i--) { 18086be9f0dSKonstantin Belousov res *= DMAR_NPTEPG; 18186be9f0dSKonstantin Belousov res++; 18286be9f0dSKonstantin Belousov } 18386be9f0dSKonstantin Belousov return (res); 18486be9f0dSKonstantin Belousov } 18586be9f0dSKonstantin Belousov 18686be9f0dSKonstantin Belousov /* 18786be9f0dSKonstantin Belousov * Return true if the page table level lvl supports the superpage for 18886be9f0dSKonstantin Belousov * the context ctx. 18986be9f0dSKonstantin Belousov */ 19086be9f0dSKonstantin Belousov int 191*1abfd355SKonstantin Belousov domain_is_sp_lvl(struct dmar_domain *domain, int lvl) 19286be9f0dSKonstantin Belousov { 19386be9f0dSKonstantin Belousov int alvl, cap_sps; 19486be9f0dSKonstantin Belousov static const int sagaw_sp[] = { 19586be9f0dSKonstantin Belousov DMAR_CAP_SPS_2M, 19686be9f0dSKonstantin Belousov DMAR_CAP_SPS_1G, 19786be9f0dSKonstantin Belousov DMAR_CAP_SPS_512G, 19886be9f0dSKonstantin Belousov DMAR_CAP_SPS_1T 19986be9f0dSKonstantin Belousov }; 20086be9f0dSKonstantin Belousov 201*1abfd355SKonstantin Belousov alvl = domain->pglvl - lvl - 1; 202*1abfd355SKonstantin Belousov cap_sps = DMAR_CAP_SPS(domain->dmar->hw_cap); 203*1abfd355SKonstantin Belousov return (alvl < nitems(sagaw_sp) && (sagaw_sp[alvl] & cap_sps) != 0); 20486be9f0dSKonstantin Belousov } 20586be9f0dSKonstantin Belousov 20686be9f0dSKonstantin Belousov dmar_gaddr_t 20786be9f0dSKonstantin Belousov pglvl_page_size(int total_pglvl, int lvl) 20886be9f0dSKonstantin Belousov { 20986be9f0dSKonstantin Belousov int rlvl; 21086be9f0dSKonstantin Belousov static const dmar_gaddr_t pg_sz[] = { 21186be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE, 21286be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE << DMAR_NPTEPGSHIFT, 21386be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE << (2 * DMAR_NPTEPGSHIFT), 21486be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE << (3 * DMAR_NPTEPGSHIFT), 21586be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE << (4 * DMAR_NPTEPGSHIFT), 21686be9f0dSKonstantin Belousov (dmar_gaddr_t)DMAR_PAGE_SIZE << (5 * DMAR_NPTEPGSHIFT) 21786be9f0dSKonstantin Belousov }; 21886be9f0dSKonstantin Belousov 21986be9f0dSKonstantin Belousov KASSERT(lvl >= 0 && lvl < total_pglvl, 22086be9f0dSKonstantin Belousov ("total %d lvl %d", total_pglvl, lvl)); 22186be9f0dSKonstantin Belousov rlvl = total_pglvl - lvl - 1; 222*1abfd355SKonstantin Belousov KASSERT(rlvl < nitems(pg_sz), ("sizeof pg_sz lvl %d", lvl)); 22386be9f0dSKonstantin Belousov return (pg_sz[rlvl]); 22486be9f0dSKonstantin Belousov } 22586be9f0dSKonstantin Belousov 22686be9f0dSKonstantin Belousov dmar_gaddr_t 227*1abfd355SKonstantin Belousov domain_page_size(struct dmar_domain *domain, int lvl) 22886be9f0dSKonstantin Belousov { 22986be9f0dSKonstantin Belousov 230*1abfd355SKonstantin Belousov return (pglvl_page_size(domain->pglvl, lvl)); 23186be9f0dSKonstantin Belousov } 23286be9f0dSKonstantin Belousov 23368eeb96aSKonstantin Belousov int 23468eeb96aSKonstantin Belousov calc_am(struct dmar_unit *unit, dmar_gaddr_t base, dmar_gaddr_t size, 23568eeb96aSKonstantin Belousov dmar_gaddr_t *isizep) 23668eeb96aSKonstantin Belousov { 23768eeb96aSKonstantin Belousov dmar_gaddr_t isize; 23868eeb96aSKonstantin Belousov int am; 23968eeb96aSKonstantin Belousov 24068eeb96aSKonstantin Belousov for (am = DMAR_CAP_MAMV(unit->hw_cap);; am--) { 24168eeb96aSKonstantin Belousov isize = 1ULL << (am + DMAR_PAGE_SHIFT); 24268eeb96aSKonstantin Belousov if ((base & (isize - 1)) == 0 && size >= isize) 24368eeb96aSKonstantin Belousov break; 24468eeb96aSKonstantin Belousov if (am == 0) 24568eeb96aSKonstantin Belousov break; 24668eeb96aSKonstantin Belousov } 24768eeb96aSKonstantin Belousov *isizep = isize; 24868eeb96aSKonstantin Belousov return (am); 24968eeb96aSKonstantin Belousov } 25068eeb96aSKonstantin Belousov 25186be9f0dSKonstantin Belousov dmar_haddr_t dmar_high; 25286be9f0dSKonstantin Belousov int haw; 25386be9f0dSKonstantin Belousov int dmar_tbl_pagecnt; 25486be9f0dSKonstantin Belousov 25586be9f0dSKonstantin Belousov vm_page_t 25686be9f0dSKonstantin Belousov dmar_pgalloc(vm_object_t obj, vm_pindex_t idx, int flags) 25786be9f0dSKonstantin Belousov { 25886be9f0dSKonstantin Belousov vm_page_t m; 25986be9f0dSKonstantin Belousov int zeroed; 26086be9f0dSKonstantin Belousov 26186be9f0dSKonstantin Belousov zeroed = (flags & DMAR_PGF_ZERO) != 0 ? VM_ALLOC_ZERO : 0; 26286be9f0dSKonstantin Belousov for (;;) { 26386be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 26486be9f0dSKonstantin Belousov VM_OBJECT_WLOCK(obj); 26586be9f0dSKonstantin Belousov m = vm_page_lookup(obj, idx); 26686be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_NOALLOC) != 0 || m != NULL) { 26786be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 26886be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 26986be9f0dSKonstantin Belousov break; 27086be9f0dSKonstantin Belousov } 27186be9f0dSKonstantin Belousov m = vm_page_alloc_contig(obj, idx, VM_ALLOC_NOBUSY | 27286be9f0dSKonstantin Belousov VM_ALLOC_SYSTEM | VM_ALLOC_NODUMP | zeroed, 1, 0, 27386be9f0dSKonstantin Belousov dmar_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT); 27486be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 27586be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 27686be9f0dSKonstantin Belousov if (m != NULL) { 27786be9f0dSKonstantin Belousov if (zeroed && (m->flags & PG_ZERO) == 0) 27886be9f0dSKonstantin Belousov pmap_zero_page(m); 27986be9f0dSKonstantin Belousov atomic_add_int(&dmar_tbl_pagecnt, 1); 28086be9f0dSKonstantin Belousov break; 28186be9f0dSKonstantin Belousov } 28286be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_WAITOK) == 0) 28386be9f0dSKonstantin Belousov break; 28486be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) != 0) 28586be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 28686be9f0dSKonstantin Belousov VM_WAIT; 28786be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) != 0) 28886be9f0dSKonstantin Belousov VM_OBJECT_WLOCK(obj); 28986be9f0dSKonstantin Belousov } 29086be9f0dSKonstantin Belousov return (m); 29186be9f0dSKonstantin Belousov } 29286be9f0dSKonstantin Belousov 29386be9f0dSKonstantin Belousov void 29486be9f0dSKonstantin Belousov dmar_pgfree(vm_object_t obj, vm_pindex_t idx, int flags) 29586be9f0dSKonstantin Belousov { 29686be9f0dSKonstantin Belousov vm_page_t m; 29786be9f0dSKonstantin Belousov 29886be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 29986be9f0dSKonstantin Belousov VM_OBJECT_WLOCK(obj); 30086be9f0dSKonstantin Belousov m = vm_page_lookup(obj, idx); 30186be9f0dSKonstantin Belousov if (m != NULL) { 30286be9f0dSKonstantin Belousov vm_page_free(m); 30386be9f0dSKonstantin Belousov atomic_subtract_int(&dmar_tbl_pagecnt, 1); 30486be9f0dSKonstantin Belousov } 30586be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 30686be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 30786be9f0dSKonstantin Belousov } 30886be9f0dSKonstantin Belousov 30986be9f0dSKonstantin Belousov void * 31086be9f0dSKonstantin Belousov dmar_map_pgtbl(vm_object_t obj, vm_pindex_t idx, int flags, 31186be9f0dSKonstantin Belousov struct sf_buf **sf) 31286be9f0dSKonstantin Belousov { 31386be9f0dSKonstantin Belousov vm_page_t m; 31486be9f0dSKonstantin Belousov bool allocated; 31586be9f0dSKonstantin Belousov 31686be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 31786be9f0dSKonstantin Belousov VM_OBJECT_WLOCK(obj); 31886be9f0dSKonstantin Belousov m = vm_page_lookup(obj, idx); 31986be9f0dSKonstantin Belousov if (m == NULL && (flags & DMAR_PGF_ALLOC) != 0) { 32086be9f0dSKonstantin Belousov m = dmar_pgalloc(obj, idx, flags | DMAR_PGF_OBJL); 32186be9f0dSKonstantin Belousov allocated = true; 32286be9f0dSKonstantin Belousov } else 32386be9f0dSKonstantin Belousov allocated = false; 32486be9f0dSKonstantin Belousov if (m == NULL) { 32586be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 32686be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 32786be9f0dSKonstantin Belousov return (NULL); 32886be9f0dSKonstantin Belousov } 32986be9f0dSKonstantin Belousov /* Sleepable allocations cannot fail. */ 33086be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_WAITOK) != 0) 33186be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 33286be9f0dSKonstantin Belousov sched_pin(); 33386be9f0dSKonstantin Belousov *sf = sf_buf_alloc(m, SFB_CPUPRIVATE | ((flags & DMAR_PGF_WAITOK) 33486be9f0dSKonstantin Belousov == 0 ? SFB_NOWAIT : 0)); 33586be9f0dSKonstantin Belousov if (*sf == NULL) { 33686be9f0dSKonstantin Belousov sched_unpin(); 33786be9f0dSKonstantin Belousov if (allocated) { 33886be9f0dSKonstantin Belousov VM_OBJECT_ASSERT_WLOCKED(obj); 33986be9f0dSKonstantin Belousov dmar_pgfree(obj, m->pindex, flags | DMAR_PGF_OBJL); 34086be9f0dSKonstantin Belousov } 34186be9f0dSKonstantin Belousov if ((flags & DMAR_PGF_OBJL) == 0) 34286be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 34386be9f0dSKonstantin Belousov return (NULL); 34486be9f0dSKonstantin Belousov } 34586be9f0dSKonstantin Belousov if ((flags & (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) == 34686be9f0dSKonstantin Belousov (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) 34786be9f0dSKonstantin Belousov VM_OBJECT_WLOCK(obj); 34886be9f0dSKonstantin Belousov else if ((flags & (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) == 0) 34986be9f0dSKonstantin Belousov VM_OBJECT_WUNLOCK(obj); 35086be9f0dSKonstantin Belousov return ((void *)sf_buf_kva(*sf)); 35186be9f0dSKonstantin Belousov } 35286be9f0dSKonstantin Belousov 35386be9f0dSKonstantin Belousov void 3546b7c46afSKonstantin Belousov dmar_unmap_pgtbl(struct sf_buf *sf) 35586be9f0dSKonstantin Belousov { 35686be9f0dSKonstantin Belousov 35786be9f0dSKonstantin Belousov sf_buf_free(sf); 35886be9f0dSKonstantin Belousov sched_unpin(); 3596b7c46afSKonstantin Belousov } 36086be9f0dSKonstantin Belousov 3616b7c46afSKonstantin Belousov static void 3626b7c46afSKonstantin Belousov dmar_flush_transl_to_ram(struct dmar_unit *unit, void *dst, size_t sz) 3636b7c46afSKonstantin Belousov { 3646b7c46afSKonstantin Belousov 3656b7c46afSKonstantin Belousov if (DMAR_IS_COHERENT(unit)) 3666b7c46afSKonstantin Belousov return; 36786be9f0dSKonstantin Belousov /* 36886be9f0dSKonstantin Belousov * If DMAR does not snoop paging structures accesses, flush 36986be9f0dSKonstantin Belousov * CPU cache to memory. 37086be9f0dSKonstantin Belousov */ 3716b7c46afSKonstantin Belousov pmap_invalidate_cache_range((uintptr_t)dst, (uintptr_t)dst + sz, 3726b7c46afSKonstantin Belousov TRUE); 3736b7c46afSKonstantin Belousov } 3746b7c46afSKonstantin Belousov 3756b7c46afSKonstantin Belousov void 3766b7c46afSKonstantin Belousov dmar_flush_pte_to_ram(struct dmar_unit *unit, dmar_pte_t *dst) 3776b7c46afSKonstantin Belousov { 3786b7c46afSKonstantin Belousov 3796b7c46afSKonstantin Belousov dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 3806b7c46afSKonstantin Belousov } 3816b7c46afSKonstantin Belousov 3826b7c46afSKonstantin Belousov void 3836b7c46afSKonstantin Belousov dmar_flush_ctx_to_ram(struct dmar_unit *unit, dmar_ctx_entry_t *dst) 3846b7c46afSKonstantin Belousov { 3856b7c46afSKonstantin Belousov 3866b7c46afSKonstantin Belousov dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 3876b7c46afSKonstantin Belousov } 3886b7c46afSKonstantin Belousov 3896b7c46afSKonstantin Belousov void 3906b7c46afSKonstantin Belousov dmar_flush_root_to_ram(struct dmar_unit *unit, dmar_root_entry_t *dst) 3916b7c46afSKonstantin Belousov { 3926b7c46afSKonstantin Belousov 3936b7c46afSKonstantin Belousov dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 39486be9f0dSKonstantin Belousov } 39586be9f0dSKonstantin Belousov 39686be9f0dSKonstantin Belousov /* 39786be9f0dSKonstantin Belousov * Load the root entry pointer into the hardware, busily waiting for 39886be9f0dSKonstantin Belousov * the completion. 39986be9f0dSKonstantin Belousov */ 40086be9f0dSKonstantin Belousov int 40186be9f0dSKonstantin Belousov dmar_load_root_entry_ptr(struct dmar_unit *unit) 40286be9f0dSKonstantin Belousov { 40386be9f0dSKonstantin Belousov vm_page_t root_entry; 40486be9f0dSKonstantin Belousov 40586be9f0dSKonstantin Belousov /* 40686be9f0dSKonstantin Belousov * Access to the GCMD register must be serialized while the 40786be9f0dSKonstantin Belousov * command is submitted. 40886be9f0dSKonstantin Belousov */ 40986be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 41086be9f0dSKonstantin Belousov 4115a49ae8eSKonstantin Belousov VM_OBJECT_RLOCK(unit->ctx_obj); 41286be9f0dSKonstantin Belousov root_entry = vm_page_lookup(unit->ctx_obj, 0); 4135a49ae8eSKonstantin Belousov VM_OBJECT_RUNLOCK(unit->ctx_obj); 41486be9f0dSKonstantin Belousov dmar_write8(unit, DMAR_RTADDR_REG, VM_PAGE_TO_PHYS(root_entry)); 41586be9f0dSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd | DMAR_GCMD_SRTP); 41686be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 41786be9f0dSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_RTPS) == 0) 41886be9f0dSKonstantin Belousov cpu_spinwait(); 41986be9f0dSKonstantin Belousov return (0); 42086be9f0dSKonstantin Belousov } 42186be9f0dSKonstantin Belousov 42286be9f0dSKonstantin Belousov /* 42386be9f0dSKonstantin Belousov * Globally invalidate the context entries cache, busily waiting for 42486be9f0dSKonstantin Belousov * the completion. 42586be9f0dSKonstantin Belousov */ 42686be9f0dSKonstantin Belousov int 42786be9f0dSKonstantin Belousov dmar_inv_ctx_glob(struct dmar_unit *unit) 42886be9f0dSKonstantin Belousov { 42986be9f0dSKonstantin Belousov 43086be9f0dSKonstantin Belousov /* 43186be9f0dSKonstantin Belousov * Access to the CCMD register must be serialized while the 43286be9f0dSKonstantin Belousov * command is submitted. 43386be9f0dSKonstantin Belousov */ 43486be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 43568eeb96aSKonstantin Belousov KASSERT(!unit->qi_enabled, ("QI enabled")); 43686be9f0dSKonstantin Belousov 43786be9f0dSKonstantin Belousov /* 43886be9f0dSKonstantin Belousov * The DMAR_CCMD_ICC bit in the upper dword should be written 43986be9f0dSKonstantin Belousov * after the low dword write is completed. Amd64 44086be9f0dSKonstantin Belousov * dmar_write8() does not have this issue, i386 dmar_write8() 44186be9f0dSKonstantin Belousov * writes the upper dword last. 44286be9f0dSKonstantin Belousov */ 44386be9f0dSKonstantin Belousov dmar_write8(unit, DMAR_CCMD_REG, DMAR_CCMD_ICC | DMAR_CCMD_CIRG_GLOB); 44486be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 44586be9f0dSKonstantin Belousov while ((dmar_read4(unit, DMAR_CCMD_REG + 4) & DMAR_CCMD_ICC32) != 0) 44686be9f0dSKonstantin Belousov cpu_spinwait(); 44786be9f0dSKonstantin Belousov return (0); 44886be9f0dSKonstantin Belousov } 44986be9f0dSKonstantin Belousov 45086be9f0dSKonstantin Belousov /* 45186be9f0dSKonstantin Belousov * Globally invalidate the IOTLB, busily waiting for the completion. 45286be9f0dSKonstantin Belousov */ 45386be9f0dSKonstantin Belousov int 45486be9f0dSKonstantin Belousov dmar_inv_iotlb_glob(struct dmar_unit *unit) 45586be9f0dSKonstantin Belousov { 45686be9f0dSKonstantin Belousov int reg; 45786be9f0dSKonstantin Belousov 45886be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 45968eeb96aSKonstantin Belousov KASSERT(!unit->qi_enabled, ("QI enabled")); 46086be9f0dSKonstantin Belousov 46186be9f0dSKonstantin Belousov reg = 16 * DMAR_ECAP_IRO(unit->hw_ecap); 46286be9f0dSKonstantin Belousov /* See a comment about DMAR_CCMD_ICC in dmar_inv_ctx_glob. */ 46386be9f0dSKonstantin Belousov dmar_write8(unit, reg + DMAR_IOTLB_REG_OFF, DMAR_IOTLB_IVT | 46486be9f0dSKonstantin Belousov DMAR_IOTLB_IIRG_GLB | DMAR_IOTLB_DR | DMAR_IOTLB_DW); 46586be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 46686be9f0dSKonstantin Belousov while ((dmar_read4(unit, reg + DMAR_IOTLB_REG_OFF + 4) & 46786be9f0dSKonstantin Belousov DMAR_IOTLB_IVT32) != 0) 46886be9f0dSKonstantin Belousov cpu_spinwait(); 46986be9f0dSKonstantin Belousov return (0); 47086be9f0dSKonstantin Belousov } 47186be9f0dSKonstantin Belousov 47286be9f0dSKonstantin Belousov /* 47386be9f0dSKonstantin Belousov * Flush the chipset write buffers. See 11.1 "Write Buffer Flushing" 47486be9f0dSKonstantin Belousov * in the architecture specification. 47586be9f0dSKonstantin Belousov */ 47686be9f0dSKonstantin Belousov int 47786be9f0dSKonstantin Belousov dmar_flush_write_bufs(struct dmar_unit *unit) 47886be9f0dSKonstantin Belousov { 47986be9f0dSKonstantin Belousov 48086be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 48186be9f0dSKonstantin Belousov 48286be9f0dSKonstantin Belousov /* 48386be9f0dSKonstantin Belousov * DMAR_GCMD_WBF is only valid when CAP_RWBF is reported. 48486be9f0dSKonstantin Belousov */ 48586be9f0dSKonstantin Belousov KASSERT((unit->hw_cap & DMAR_CAP_RWBF) != 0, 48686be9f0dSKonstantin Belousov ("dmar%d: no RWBF", unit->unit)); 48786be9f0dSKonstantin Belousov 48886be9f0dSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd | DMAR_GCMD_WBF); 48986be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 49086be9f0dSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_WBFS) == 0) 49186be9f0dSKonstantin Belousov cpu_spinwait(); 49286be9f0dSKonstantin Belousov return (0); 49386be9f0dSKonstantin Belousov } 49486be9f0dSKonstantin Belousov 49586be9f0dSKonstantin Belousov int 49686be9f0dSKonstantin Belousov dmar_enable_translation(struct dmar_unit *unit) 49786be9f0dSKonstantin Belousov { 49886be9f0dSKonstantin Belousov 49986be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 50086be9f0dSKonstantin Belousov unit->hw_gcmd |= DMAR_GCMD_TE; 50186be9f0dSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd); 50286be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 50386be9f0dSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_TES) == 0) 50486be9f0dSKonstantin Belousov cpu_spinwait(); 50586be9f0dSKonstantin Belousov return (0); 50686be9f0dSKonstantin Belousov } 50786be9f0dSKonstantin Belousov 50886be9f0dSKonstantin Belousov int 50986be9f0dSKonstantin Belousov dmar_disable_translation(struct dmar_unit *unit) 51086be9f0dSKonstantin Belousov { 51186be9f0dSKonstantin Belousov 51286be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 51386be9f0dSKonstantin Belousov unit->hw_gcmd &= ~DMAR_GCMD_TE; 51486be9f0dSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd); 51586be9f0dSKonstantin Belousov /* XXXKIB should have a timeout */ 51686be9f0dSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_TES) != 0) 51786be9f0dSKonstantin Belousov cpu_spinwait(); 51886be9f0dSKonstantin Belousov return (0); 51986be9f0dSKonstantin Belousov } 52086be9f0dSKonstantin Belousov 5210a110d5bSKonstantin Belousov int 5220a110d5bSKonstantin Belousov dmar_load_irt_ptr(struct dmar_unit *unit) 5230a110d5bSKonstantin Belousov { 5240a110d5bSKonstantin Belousov uint64_t irta, s; 5250a110d5bSKonstantin Belousov 5260a110d5bSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 5270a110d5bSKonstantin Belousov irta = unit->irt_phys; 5280a110d5bSKonstantin Belousov if (DMAR_X2APIC(unit)) 5290a110d5bSKonstantin Belousov irta |= DMAR_IRTA_EIME; 5300a110d5bSKonstantin Belousov s = fls(unit->irte_cnt) - 2; 5310a110d5bSKonstantin Belousov KASSERT(unit->irte_cnt >= 2 && s <= DMAR_IRTA_S_MASK && 5320a110d5bSKonstantin Belousov powerof2(unit->irte_cnt), 5330a110d5bSKonstantin Belousov ("IRTA_REG_S overflow %x", unit->irte_cnt)); 5340a110d5bSKonstantin Belousov irta |= s; 5350a110d5bSKonstantin Belousov dmar_write8(unit, DMAR_IRTA_REG, irta); 5360a110d5bSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd | DMAR_GCMD_SIRTP); 5370a110d5bSKonstantin Belousov /* XXXKIB should have a timeout */ 5380a110d5bSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_IRTPS) == 0) 5390a110d5bSKonstantin Belousov cpu_spinwait(); 5400a110d5bSKonstantin Belousov return (0); 5410a110d5bSKonstantin Belousov } 5420a110d5bSKonstantin Belousov 5430a110d5bSKonstantin Belousov int 5440a110d5bSKonstantin Belousov dmar_enable_ir(struct dmar_unit *unit) 5450a110d5bSKonstantin Belousov { 5460a110d5bSKonstantin Belousov 5470a110d5bSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 5480a110d5bSKonstantin Belousov unit->hw_gcmd |= DMAR_GCMD_IRE; 5490a110d5bSKonstantin Belousov unit->hw_gcmd &= ~DMAR_GCMD_CFI; 5500a110d5bSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd); 5510a110d5bSKonstantin Belousov /* XXXKIB should have a timeout */ 5520a110d5bSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_IRES) == 0) 5530a110d5bSKonstantin Belousov cpu_spinwait(); 5540a110d5bSKonstantin Belousov return (0); 5550a110d5bSKonstantin Belousov } 5560a110d5bSKonstantin Belousov 5570a110d5bSKonstantin Belousov int 5580a110d5bSKonstantin Belousov dmar_disable_ir(struct dmar_unit *unit) 5590a110d5bSKonstantin Belousov { 5600a110d5bSKonstantin Belousov 5610a110d5bSKonstantin Belousov DMAR_ASSERT_LOCKED(unit); 5620a110d5bSKonstantin Belousov unit->hw_gcmd &= ~DMAR_GCMD_IRE; 5630a110d5bSKonstantin Belousov dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd); 5640a110d5bSKonstantin Belousov /* XXXKIB should have a timeout */ 5650a110d5bSKonstantin Belousov while ((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_IRES) != 0) 5660a110d5bSKonstantin Belousov cpu_spinwait(); 5670a110d5bSKonstantin Belousov return (0); 5680a110d5bSKonstantin Belousov } 5690a110d5bSKonstantin Belousov 57086be9f0dSKonstantin Belousov #define BARRIER_F \ 57186be9f0dSKonstantin Belousov u_int f_done, f_inproc, f_wakeup; \ 57286be9f0dSKonstantin Belousov \ 57386be9f0dSKonstantin Belousov f_done = 1 << (barrier_id * 3); \ 57486be9f0dSKonstantin Belousov f_inproc = 1 << (barrier_id * 3 + 1); \ 57586be9f0dSKonstantin Belousov f_wakeup = 1 << (barrier_id * 3 + 2) 57686be9f0dSKonstantin Belousov 57786be9f0dSKonstantin Belousov bool 57886be9f0dSKonstantin Belousov dmar_barrier_enter(struct dmar_unit *dmar, u_int barrier_id) 57986be9f0dSKonstantin Belousov { 58086be9f0dSKonstantin Belousov BARRIER_F; 58186be9f0dSKonstantin Belousov 58286be9f0dSKonstantin Belousov DMAR_LOCK(dmar); 58386be9f0dSKonstantin Belousov if ((dmar->barrier_flags & f_done) != 0) { 58486be9f0dSKonstantin Belousov DMAR_UNLOCK(dmar); 58586be9f0dSKonstantin Belousov return (false); 58686be9f0dSKonstantin Belousov } 58786be9f0dSKonstantin Belousov 58886be9f0dSKonstantin Belousov if ((dmar->barrier_flags & f_inproc) != 0) { 58986be9f0dSKonstantin Belousov while ((dmar->barrier_flags & f_inproc) != 0) { 59086be9f0dSKonstantin Belousov dmar->barrier_flags |= f_wakeup; 59186be9f0dSKonstantin Belousov msleep(&dmar->barrier_flags, &dmar->lock, 0, 59286be9f0dSKonstantin Belousov "dmarb", 0); 59386be9f0dSKonstantin Belousov } 59486be9f0dSKonstantin Belousov KASSERT((dmar->barrier_flags & f_done) != 0, 59586be9f0dSKonstantin Belousov ("dmar%d barrier %d missing done", dmar->unit, barrier_id)); 59686be9f0dSKonstantin Belousov DMAR_UNLOCK(dmar); 59786be9f0dSKonstantin Belousov return (false); 59886be9f0dSKonstantin Belousov } 59986be9f0dSKonstantin Belousov 60086be9f0dSKonstantin Belousov dmar->barrier_flags |= f_inproc; 60186be9f0dSKonstantin Belousov DMAR_UNLOCK(dmar); 60286be9f0dSKonstantin Belousov return (true); 60386be9f0dSKonstantin Belousov } 60486be9f0dSKonstantin Belousov 60586be9f0dSKonstantin Belousov void 60686be9f0dSKonstantin Belousov dmar_barrier_exit(struct dmar_unit *dmar, u_int barrier_id) 60786be9f0dSKonstantin Belousov { 60886be9f0dSKonstantin Belousov BARRIER_F; 60986be9f0dSKonstantin Belousov 61086be9f0dSKonstantin Belousov DMAR_ASSERT_LOCKED(dmar); 61186be9f0dSKonstantin Belousov KASSERT((dmar->barrier_flags & (f_done | f_inproc)) == f_inproc, 61286be9f0dSKonstantin Belousov ("dmar%d barrier %d missed entry", dmar->unit, barrier_id)); 61386be9f0dSKonstantin Belousov dmar->barrier_flags |= f_done; 61486be9f0dSKonstantin Belousov if ((dmar->barrier_flags & f_wakeup) != 0) 61586be9f0dSKonstantin Belousov wakeup(&dmar->barrier_flags); 61686be9f0dSKonstantin Belousov dmar->barrier_flags &= ~(f_inproc | f_wakeup); 61786be9f0dSKonstantin Belousov DMAR_UNLOCK(dmar); 61886be9f0dSKonstantin Belousov } 61986be9f0dSKonstantin Belousov 62086be9f0dSKonstantin Belousov int dmar_match_verbose; 62186be9f0dSKonstantin Belousov 622af3b2549SHans Petter Selasky static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, ""); 623af3b2549SHans Petter Selasky SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD, 62486be9f0dSKonstantin Belousov &dmar_tbl_pagecnt, 0, 62586be9f0dSKonstantin Belousov "Count of pages used for DMAR pagetables"); 626af3b2549SHans Petter Selasky SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RWTUN, 62786be9f0dSKonstantin Belousov &dmar_match_verbose, 0, 62886be9f0dSKonstantin Belousov "Verbose matching of the PCI devices to DMAR paths"); 62986be9f0dSKonstantin Belousov #ifdef INVARIANTS 63086be9f0dSKonstantin Belousov int dmar_check_free; 631af3b2549SHans Petter Selasky SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RWTUN, 63286be9f0dSKonstantin Belousov &dmar_check_free, 0, 63386be9f0dSKonstantin Belousov "Check the GPA RBtree for free_down and free_after validity"); 63486be9f0dSKonstantin Belousov #endif 63586be9f0dSKonstantin Belousov 636