18019c643SBruce M Simpson.\" 28019c643SBruce M Simpson.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org> 33834f923SKonstantin Belousov.\" Copyright (c) 2014 The FreeBSD Foundation 48019c643SBruce M Simpson.\" All rights reserved. 58019c643SBruce M Simpson.\" 68019c643SBruce M Simpson.\" Redistribution and use in source and binary forms, with or without 78019c643SBruce M Simpson.\" modification, are permitted provided that the following conditions 88019c643SBruce M Simpson.\" are met: 98019c643SBruce M Simpson.\" 1. Redistributions of source code must retain the above copyright 108019c643SBruce M Simpson.\" notice, this list of conditions and the following disclaimer. 118019c643SBruce M Simpson.\" 2. Redistributions in binary form must reproduce the above copyright 128019c643SBruce M Simpson.\" notice, this list of conditions and the following disclaimer in the 138019c643SBruce M Simpson.\" documentation and/or other materials provided with the distribution. 148019c643SBruce M Simpson.\" 158019c643SBruce M Simpson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168019c643SBruce M Simpson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 178019c643SBruce M Simpson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 188019c643SBruce M Simpson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 198019c643SBruce M Simpson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 208019c643SBruce M Simpson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 218019c643SBruce M Simpson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 228019c643SBruce M Simpson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 238019c643SBruce M Simpson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 248019c643SBruce M Simpson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 258019c643SBruce M Simpson.\" SUCH DAMAGE. 268019c643SBruce M Simpson.\" 278019c643SBruce M Simpson.\" $FreeBSD$ 288019c643SBruce M Simpson.\" 29*6b5007c8SKonstantin Belousov.Dd December 16, 2018 308019c643SBruce M Simpson.Dt PMAP_ENTER 9 31b4ca3754SRuslan Ermilov.Os 328019c643SBruce M Simpson.Sh NAME 338019c643SBruce M Simpson.Nm pmap_enter 348019c643SBruce M Simpson.Nd insert a virtual page into a physical map 358019c643SBruce M Simpson.Sh SYNOPSIS 368019c643SBruce M Simpson.In sys/param.h 378019c643SBruce M Simpson.In vm/vm.h 388019c643SBruce M Simpson.In vm/pmap.h 393834f923SKonstantin Belousov.Ft int 401772ac3fSRuslan Ermilov.Fo pmap_enter 413834f923SKonstantin Belousov.Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t m" "vm_prot_t prot" 423834f923SKonstantin Belousov.Fa "u_int flags" "int8_t psind" 431772ac3fSRuslan Ermilov.Fc 448019c643SBruce M Simpson.Sh DESCRIPTION 458019c643SBruce M SimpsonThe 468019c643SBruce M Simpson.Fn pmap_enter 473834f923SKonstantin Belousovfunction creates a mapping in the physical map 483834f923SKonstantin Belousov.Fa pmap 493834f923SKonstantin Belousovfrom the virtual address 503834f923SKonstantin Belousov.Fa va 513834f923SKonstantin Belousovto the physical page 523834f923SKonstantin Belousov.Fa m 538019c643SBruce M Simpsonwith the protection 548019c643SBruce M Simpson.Fa prot . 553834f923SKonstantin BelousovAny previous mapping at the virtual address 563834f923SKonstantin Belousov.Fa va 573834f923SKonstantin Belousovis destroyed. 583834f923SKonstantin Belousov.Pp 593834f923SKonstantin BelousovThe 603834f923SKonstantin Belousov.Fa flags 613834f923SKonstantin Belousovargument may have the following values: 623834f923SKonstantin Belousov.Bl -tag -width ".Dv PMAP_ENTER_NOSLEEP" 633834f923SKonstantin Belousov.It Dv VM_PROT_READ 643834f923SKonstantin BelousovA read access to the given virtual address triggered the call. 653834f923SKonstantin Belousov.It Dv VM_PROT_WRITE 663834f923SKonstantin BelousovA write access to the given virtual address triggered the call. 673834f923SKonstantin Belousov.It Dv VM_PROT_EXECUTE 683834f923SKonstantin BelousovAn execute access to the given virtual address triggered the call. 693834f923SKonstantin Belousov.It Dv PMAP_ENTER_WIRED 703834f923SKonstantin BelousovThe mapping should be marked as wired. 713834f923SKonstantin Belousov.It Dv PMAP_ENTER_NOSLEEP 723834f923SKonstantin BelousovThis function may not sleep during creation of the mapping. 733834f923SKonstantin BelousovIf the mapping cannot be created without sleeping, an appropriate 743834f923SKonstantin BelousovMach VM error is returned. 753834f923SKonstantin Belousov.El 763834f923SKonstantin BelousovIf the 773834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 783834f923SKonstantin Belousovflag is not specified, this function must create the requested mapping 793834f923SKonstantin Belousovbefore returning. 803834f923SKonstantin BelousovIt may not fail. 813834f923SKonstantin BelousovIn order to create the requested mapping, this function may destroy 823834f923SKonstantin Belousovany non-wired mapping in any pmap. 833834f923SKonstantin Belousov.Pp 843834f923SKonstantin BelousovThe 853834f923SKonstantin Belousov.Fa psind 863834f923SKonstantin Belousovparameter specifies the page size that should be used by the mapping. 873834f923SKonstantin BelousovThe supported page sizes are described by the global array 883834f923SKonstantin Belousov.Dv pagesizes[] . 893834f923SKonstantin BelousovThe desired page size is specified by passing the index of the array 903834f923SKonstantin Belousovelement that equals the desired page size. 913834f923SKonstantin Belousov.Pp 923834f923SKonstantin BelousovWhen the 933834f923SKonstantin Belousov.Fn pmap_enter 943834f923SKonstantin Belousovfunction destroys or updates a managed mapping, including an existing 953834f923SKonstantin Belousovmapping at virtual address 963834f923SKonstantin Belousov.Fa va , 973834f923SKonstantin Belousovit updates the 983834f923SKonstantin Belousov.Ft vm_page 993834f923SKonstantin Belousovstructure corresponding to the previously mapped physical page. 1003834f923SKonstantin BelousovIf the physical page was accessed through the managed mapping, 1013834f923SKonstantin Belousovthen the 1023834f923SKonstantin Belousov.Ft vm_page 1033834f923SKonstantin Belousovstructure's 1043834f923SKonstantin Belousov.Dv PGA_REFERENCED 1053834f923SKonstantin Belousovaflag is set. 1063834f923SKonstantin BelousovIf the physical page was modified through the managed mapping, then the 1073834f923SKonstantin Belousov.Fn vm_page_dirty 1083834f923SKonstantin Belousovfunction is called on the 1093834f923SKonstantin Belousov.Ft vm_page 1103834f923SKonstantin Belousovstructure. 1113834f923SKonstantin Belousov.Pp 1123834f923SKonstantin BelousovThe 1133834f923SKonstantin Belousov.Dv PGA_WRITEABLE 1143834f923SKonstantin Belousovaflag must be set for the page 1153834f923SKonstantin Belousov.Fa m 1163834f923SKonstantin Belousovif the new mapping is managed and writeable. 1173834f923SKonstantin BelousovIt is advised to clear 1183834f923SKonstantin Belousov.Dv PGA_WRITEABLE 1193834f923SKonstantin Belousovfor destroyed mappings if the implementation can ensure 1203834f923SKonstantin Belousovthat no other writeable managed mappings for the previously 1213834f923SKonstantin Belousovmapped pages exist. 1223834f923SKonstantin Belousov.Pp 123*6b5007c8SKonstantin BelousovIf the request modifies an existing mapping to use a different physical 124*6b5007c8SKonstantin Belousovpage, an implementation of 125*6b5007c8SKonstantin Belousov.Nm 126*6b5007c8SKonstantin Belousovmust invalidate the previous mapping before installing the new one. 127*6b5007c8SKonstantin BelousovThis ensures that all threads sharing the pmap keep a consistent 128*6b5007c8SKonstantin Belousovview of the mapping, which is necessary for the correct handling 129*6b5007c8SKonstantin Belousovof CoW (copy on write) faults. 130*6b5007c8SKonstantin Belousov.Pp 1313834f923SKonstantin BelousovIf the page 1323834f923SKonstantin Belousov.Fa m 1333834f923SKonstantin Belousovis managed, the page must be busied by the caller 1343834f923SKonstantin Belousovor the owning object must be locked. 1353834f923SKonstantin BelousovIn the later case, the 1363834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 1373834f923SKonstantin Belousovmust be specified by the caller. 1383834f923SKonstantin Belousov.Pp 1393834f923SKonstantin BelousovThe 1403834f923SKonstantin Belousov.Fn pmap_enter 1413834f923SKonstantin Belousovfunction must handle the multiprocessor TLB consistency for the 1423834f923SKonstantin Belousovgiven address. 1433834f923SKonstantin Belousov.Sh NOTES 1442c64e266SKonstantin BelousovOn arm and i386 architectures the existing implementation 1453834f923SKonstantin Belousovof the 1463834f923SKonstantin Belousov.Nm 1473834f923SKonstantin Belousovfunction is incomplete, only value 0 for 1483834f923SKonstantin Belousov.Fa psind 1493834f923SKonstantin Belousovis supported. 1502c64e266SKonstantin BelousovOther supported architectures, except amd64, have 1513834f923SKonstantin Belousov.Dv pagesizes[] 1523834f923SKonstantin Belousovarray of size 1. 1533834f923SKonstantin Belousov.Sh RETURN VALUES 1543834f923SKonstantin BelousovIf successful, the 1553834f923SKonstantin Belousov.Fn pmap_enter 1563834f923SKonstantin Belousovfunction returns 1573834f923SKonstantin Belousov.Er KERN_SUCCESS . 1583834f923SKonstantin BelousovIf the 1593834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 1603834f923SKonstantin Belousovflag was specified and the resources required for the mapping cannot 1613834f923SKonstantin Belousovbe acquired without sleeping, 1623834f923SKonstantin Belousov.Dv KERN_RESOURCE_SHORTAGE 1633834f923SKonstantin Belousovis returned. 1648019c643SBruce M Simpson.Sh SEE ALSO 1658019c643SBruce M Simpson.Xr pmap 9 1668019c643SBruce M Simpson.Sh AUTHORS 1673834f923SKonstantin BelousovThis manual page was first written by 1683834f923SKonstantin Belousov.An Bruce M Simpson Aq Mt bms@spc.org 1693834f923SKonstantin Belousovand then rewritten by 1703834f923SKonstantin Belousov.An Alan Cox Aq Mt alc@FreeBSD.org 1713834f923SKonstantin Belousovand 1723834f923SKonstantin Belousov.An Konstantin Belousov Aq Mt kib@FreeBSD.org . 173