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.\" 27*6b5007c8SKonstantin Belousov.Dd December 16, 2018 288019c643SBruce M Simpson.Dt PMAP_ENTER 9 29b4ca3754SRuslan Ermilov.Os 308019c643SBruce M Simpson.Sh NAME 318019c643SBruce M Simpson.Nm pmap_enter 328019c643SBruce M Simpson.Nd insert a virtual page into a physical map 338019c643SBruce M Simpson.Sh SYNOPSIS 348019c643SBruce M Simpson.In sys/param.h 358019c643SBruce M Simpson.In vm/vm.h 368019c643SBruce M Simpson.In vm/pmap.h 373834f923SKonstantin Belousov.Ft int 381772ac3fSRuslan Ermilov.Fo pmap_enter 393834f923SKonstantin Belousov.Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t m" "vm_prot_t prot" 403834f923SKonstantin Belousov.Fa "u_int flags" "int8_t psind" 411772ac3fSRuslan Ermilov.Fc 428019c643SBruce M Simpson.Sh DESCRIPTION 438019c643SBruce M SimpsonThe 448019c643SBruce M Simpson.Fn pmap_enter 453834f923SKonstantin Belousovfunction creates a mapping in the physical map 463834f923SKonstantin Belousov.Fa pmap 473834f923SKonstantin Belousovfrom the virtual address 483834f923SKonstantin Belousov.Fa va 493834f923SKonstantin Belousovto the physical page 503834f923SKonstantin Belousov.Fa m 518019c643SBruce M Simpsonwith the protection 528019c643SBruce M Simpson.Fa prot . 533834f923SKonstantin BelousovAny previous mapping at the virtual address 543834f923SKonstantin Belousov.Fa va 553834f923SKonstantin Belousovis destroyed. 563834f923SKonstantin Belousov.Pp 573834f923SKonstantin BelousovThe 583834f923SKonstantin Belousov.Fa flags 593834f923SKonstantin Belousovargument may have the following values: 603834f923SKonstantin Belousov.Bl -tag -width ".Dv PMAP_ENTER_NOSLEEP" 613834f923SKonstantin Belousov.It Dv VM_PROT_READ 623834f923SKonstantin BelousovA read access to the given virtual address triggered the call. 633834f923SKonstantin Belousov.It Dv VM_PROT_WRITE 643834f923SKonstantin BelousovA write access to the given virtual address triggered the call. 653834f923SKonstantin Belousov.It Dv VM_PROT_EXECUTE 663834f923SKonstantin BelousovAn execute access to the given virtual address triggered the call. 673834f923SKonstantin Belousov.It Dv PMAP_ENTER_WIRED 683834f923SKonstantin BelousovThe mapping should be marked as wired. 693834f923SKonstantin Belousov.It Dv PMAP_ENTER_NOSLEEP 703834f923SKonstantin BelousovThis function may not sleep during creation of the mapping. 713834f923SKonstantin BelousovIf the mapping cannot be created without sleeping, an appropriate 723834f923SKonstantin BelousovMach VM error is returned. 733834f923SKonstantin Belousov.El 743834f923SKonstantin BelousovIf the 753834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 763834f923SKonstantin Belousovflag is not specified, this function must create the requested mapping 773834f923SKonstantin Belousovbefore returning. 783834f923SKonstantin BelousovIt may not fail. 793834f923SKonstantin BelousovIn order to create the requested mapping, this function may destroy 803834f923SKonstantin Belousovany non-wired mapping in any pmap. 813834f923SKonstantin Belousov.Pp 823834f923SKonstantin BelousovThe 833834f923SKonstantin Belousov.Fa psind 843834f923SKonstantin Belousovparameter specifies the page size that should be used by the mapping. 853834f923SKonstantin BelousovThe supported page sizes are described by the global array 863834f923SKonstantin Belousov.Dv pagesizes[] . 873834f923SKonstantin BelousovThe desired page size is specified by passing the index of the array 883834f923SKonstantin Belousovelement that equals the desired page size. 893834f923SKonstantin Belousov.Pp 903834f923SKonstantin BelousovWhen the 913834f923SKonstantin Belousov.Fn pmap_enter 923834f923SKonstantin Belousovfunction destroys or updates a managed mapping, including an existing 933834f923SKonstantin Belousovmapping at virtual address 943834f923SKonstantin Belousov.Fa va , 953834f923SKonstantin Belousovit updates the 963834f923SKonstantin Belousov.Ft vm_page 973834f923SKonstantin Belousovstructure corresponding to the previously mapped physical page. 983834f923SKonstantin BelousovIf the physical page was accessed through the managed mapping, 993834f923SKonstantin Belousovthen the 1003834f923SKonstantin Belousov.Ft vm_page 1013834f923SKonstantin Belousovstructure's 1023834f923SKonstantin Belousov.Dv PGA_REFERENCED 1033834f923SKonstantin Belousovaflag is set. 1043834f923SKonstantin BelousovIf the physical page was modified through the managed mapping, then the 1053834f923SKonstantin Belousov.Fn vm_page_dirty 1063834f923SKonstantin Belousovfunction is called on the 1073834f923SKonstantin Belousov.Ft vm_page 1083834f923SKonstantin Belousovstructure. 1093834f923SKonstantin Belousov.Pp 1103834f923SKonstantin BelousovThe 1113834f923SKonstantin Belousov.Dv PGA_WRITEABLE 1123834f923SKonstantin Belousovaflag must be set for the page 1133834f923SKonstantin Belousov.Fa m 1143834f923SKonstantin Belousovif the new mapping is managed and writeable. 1153834f923SKonstantin BelousovIt is advised to clear 1163834f923SKonstantin Belousov.Dv PGA_WRITEABLE 1173834f923SKonstantin Belousovfor destroyed mappings if the implementation can ensure 1183834f923SKonstantin Belousovthat no other writeable managed mappings for the previously 1193834f923SKonstantin Belousovmapped pages exist. 1203834f923SKonstantin Belousov.Pp 121*6b5007c8SKonstantin BelousovIf the request modifies an existing mapping to use a different physical 122*6b5007c8SKonstantin Belousovpage, an implementation of 123*6b5007c8SKonstantin Belousov.Nm 124*6b5007c8SKonstantin Belousovmust invalidate the previous mapping before installing the new one. 125*6b5007c8SKonstantin BelousovThis ensures that all threads sharing the pmap keep a consistent 126*6b5007c8SKonstantin Belousovview of the mapping, which is necessary for the correct handling 127*6b5007c8SKonstantin Belousovof CoW (copy on write) faults. 128*6b5007c8SKonstantin Belousov.Pp 1293834f923SKonstantin BelousovIf the page 1303834f923SKonstantin Belousov.Fa m 1313834f923SKonstantin Belousovis managed, the page must be busied by the caller 1323834f923SKonstantin Belousovor the owning object must be locked. 1333834f923SKonstantin BelousovIn the later case, the 1343834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 1353834f923SKonstantin Belousovmust be specified by the caller. 1363834f923SKonstantin Belousov.Pp 1373834f923SKonstantin BelousovThe 1383834f923SKonstantin Belousov.Fn pmap_enter 1393834f923SKonstantin Belousovfunction must handle the multiprocessor TLB consistency for the 1403834f923SKonstantin Belousovgiven address. 1413834f923SKonstantin Belousov.Sh NOTES 1422c64e266SKonstantin BelousovOn arm and i386 architectures the existing implementation 1433834f923SKonstantin Belousovof the 1443834f923SKonstantin Belousov.Nm 1453834f923SKonstantin Belousovfunction is incomplete, only value 0 for 1463834f923SKonstantin Belousov.Fa psind 1473834f923SKonstantin Belousovis supported. 1482c64e266SKonstantin BelousovOther supported architectures, except amd64, have 1493834f923SKonstantin Belousov.Dv pagesizes[] 1503834f923SKonstantin Belousovarray of size 1. 1513834f923SKonstantin Belousov.Sh RETURN VALUES 1523834f923SKonstantin BelousovIf successful, the 1533834f923SKonstantin Belousov.Fn pmap_enter 1543834f923SKonstantin Belousovfunction returns 1553834f923SKonstantin Belousov.Er KERN_SUCCESS . 1563834f923SKonstantin BelousovIf the 1573834f923SKonstantin Belousov.Dv PMAP_ENTER_NOSLEEP 1583834f923SKonstantin Belousovflag was specified and the resources required for the mapping cannot 1593834f923SKonstantin Belousovbe acquired without sleeping, 1603834f923SKonstantin Belousov.Dv KERN_RESOURCE_SHORTAGE 1613834f923SKonstantin Belousovis returned. 1628019c643SBruce M Simpson.Sh SEE ALSO 1638019c643SBruce M Simpson.Xr pmap 9 1648019c643SBruce M Simpson.Sh AUTHORS 1653834f923SKonstantin BelousovThis manual page was first written by 1663834f923SKonstantin Belousov.An Bruce M Simpson Aq Mt bms@spc.org 1673834f923SKonstantin Belousovand then rewritten by 1683834f923SKonstantin Belousov.An Alan Cox Aq Mt alc@FreeBSD.org 1693834f923SKonstantin Belousovand 1703834f923SKonstantin Belousov.An Konstantin Belousov Aq Mt kib@FreeBSD.org . 171