xref: /xnu-8792.81.2/osfmk/man/memory_object_lock_request.html (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions<h2>memory_object_lock_request</h2>
2*19c3b8c2SApple OSS Distributions<hr>
3*19c3b8c2SApple OSS Distributions<p>
4*19c3b8c2SApple OSS Distributions<strong>Function</strong> - Restrict access to memory object data.
5*19c3b8c2SApple OSS Distributions<h3>SYNOPSIS</h3>
6*19c3b8c2SApple OSS Distributions<pre>
7*19c3b8c2SApple OSS Distributions<strong>kern_return_t   memory_object_lock_request</strong>
8*19c3b8c2SApple OSS Distributions                <strong>(memory_object_control_t</strong>         <var>memory_control</var>,
9*19c3b8c2SApple OSS Distributions                 <strong>vm_offset_t</strong>                             <var>offset</var>,
10*19c3b8c2SApple OSS Distributions                 <strong>vm_size_t</strong>                                 <var>size</var>,
11*19c3b8c2SApple OSS Distributions                 <strong>memory_object_return_t</strong>           <var>should_return</var>,
12*19c3b8c2SApple OSS Distributions                 <strong>boolean_t</strong>                         <var>should_flush</var>,
13*19c3b8c2SApple OSS Distributions                 <strong>vm_prot_t</strong>                           <var>lock_value</var>,
14*19c3b8c2SApple OSS Distributions                 <strong>mach_port_t</strong>                         <var>reply_port</var><strong>);</strong>
15*19c3b8c2SApple OSS Distributions</pre>
16*19c3b8c2SApple OSS Distributions<h3>PARAMETERS</h3>
17*19c3b8c2SApple OSS Distributions<dl>
18*19c3b8c2SApple OSS Distributions<p>
19*19c3b8c2SApple OSS Distributions<dt> <var>memory_control</var>
20*19c3b8c2SApple OSS Distributions<dd>
21*19c3b8c2SApple OSS Distributions[in memory-cache-control send right]
22*19c3b8c2SApple OSS DistributionsThe memory cache control port
23*19c3b8c2SApple OSS Distributionsto be used by the memory manager for cache management requests.
24*19c3b8c2SApple OSS DistributionsThis port is provided by the kernel in a <strong>memory_object_init</strong> call.
25*19c3b8c2SApple OSS Distributions<p>
26*19c3b8c2SApple OSS Distributions<dt> <var>offset</var>
27*19c3b8c2SApple OSS Distributions<dd>
28*19c3b8c2SApple OSS Distributions[in scalar]
29*19c3b8c2SApple OSS DistributionsThe offset within the memory object, in bytes.
30*19c3b8c2SApple OSS Distributions<p>
31*19c3b8c2SApple OSS Distributions<dt> <var>size</var>
32*19c3b8c2SApple OSS Distributions<dd>
33*19c3b8c2SApple OSS Distributions[in scalar]
34*19c3b8c2SApple OSS DistributionsThe number of bytes of data (starting at <var>offset</var>) to be
35*19c3b8c2SApple OSS Distributionsaffected.  The number must convert to an integral number of memory object
36*19c3b8c2SApple OSS Distributionspages.
37*19c3b8c2SApple OSS Distributions<p>
38*19c3b8c2SApple OSS Distributions<dt> <var>should_return</var>
39*19c3b8c2SApple OSS Distributions<dd>
40*19c3b8c2SApple OSS Distributions[in scalar]
41*19c3b8c2SApple OSS DistributionsClean indicator.  Values are:
42*19c3b8c2SApple OSS Distributions<dl>
43*19c3b8c2SApple OSS Distributions<p>
44*19c3b8c2SApple OSS Distributions<dt> <strong>MEMORY_OBJECT_RETURN_NONE</strong>
45*19c3b8c2SApple OSS Distributions<dd>
46*19c3b8c2SApple OSS DistributionsDon't return any pages.  If <var>should_flush</var> is <strong>TRUE</strong>, pages will
47*19c3b8c2SApple OSS Distributionsbe discarded.
48*19c3b8c2SApple OSS Distributions<p>
49*19c3b8c2SApple OSS Distributions<dt> <strong>MEMORY_OBJECT_RETURN_DIRTY</strong>
50*19c3b8c2SApple OSS Distributions<dd>
51*19c3b8c2SApple OSS DistributionsReturn only dirty (modified) pages.  If <var>should_flush</var> is <strong>TRUE</strong>,
52*19c3b8c2SApple OSS Distributionsprecious pages will be discarded; otherwise, the kernel
53*19c3b8c2SApple OSS Distributionsmaintains responsibility for precious pages.
54*19c3b8c2SApple OSS Distributions<p>
55*19c3b8c2SApple OSS Distributions<dt> <strong>MEMORY_OBJECT_RETURN_ALL</strong>
56*19c3b8c2SApple OSS Distributions<dd>
57*19c3b8c2SApple OSS DistributionsBoth dirty and precious pages are returned.  If <var>should_flush</var> is
58*19c3b8c2SApple OSS Distributions<strong>FALSE</strong>, the kernel maintains responsibility for the precious
59*19c3b8c2SApple OSS Distributionspages.
60*19c3b8c2SApple OSS Distributions<p>
61*19c3b8c2SApple OSS Distributions<dt> <strong>MEMORY_OBJECT_RETURN_ANYTHING</strong>
62*19c3b8c2SApple OSS Distributions<dd>
63*19c3b8c2SApple OSS DistributionsAny resident pages are returned.   If <var>should_flush</var> is <strong>TRUE</strong>,
64*19c3b8c2SApple OSS Distributionsprecious pages will be discarded; otherwise, the kernel
65*19c3b8c2SApple OSS Distributionsmaintains responsibility for precious pages.
66*19c3b8c2SApple OSS Distributions</dl>
67*19c3b8c2SApple OSS Distributions<p>
68*19c3b8c2SApple OSS Distributions<dt> <var>should_flush</var>
69*19c3b8c2SApple OSS Distributions<dd>
70*19c3b8c2SApple OSS Distributions[in scalar]
71*19c3b8c2SApple OSS DistributionsFlush indicator.  If true, the kernel discards all pages within
72*19c3b8c2SApple OSS Distributionsthe range.
73*19c3b8c2SApple OSS Distributions<p>
74*19c3b8c2SApple OSS Distributions<dt> <var>lock_value</var>
75*19c3b8c2SApple OSS Distributions<dd>
76*19c3b8c2SApple OSS Distributions[in scalar]
77*19c3b8c2SApple OSS DistributionsOne or more forms of access <var>not</var> permitted for the specified
78*19c3b8c2SApple OSS Distributionsdata.  Valid values are:
79*19c3b8c2SApple OSS Distributions<dl>
80*19c3b8c2SApple OSS Distributions<p>
81*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_NO_CHANGE</strong>
82*19c3b8c2SApple OSS Distributions<dd>
83*19c3b8c2SApple OSS DistributionsDo not change the protection of any pages.
84*19c3b8c2SApple OSS Distributions<p>
85*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_NONE</strong>
86*19c3b8c2SApple OSS Distributions<dd>
87*19c3b8c2SApple OSS DistributionsProhibits no access (that is, all forms of access are permitted).
88*19c3b8c2SApple OSS Distributions<p>
89*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_READ</strong>
90*19c3b8c2SApple OSS Distributions<dd>
91*19c3b8c2SApple OSS DistributionsProhibits read access.
92*19c3b8c2SApple OSS Distributions<p>
93*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_WRITE</strong>
94*19c3b8c2SApple OSS Distributions<dd>
95*19c3b8c2SApple OSS DistributionsProhibits write access.
96*19c3b8c2SApple OSS Distributions<p>
97*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_EXECUTE</strong>
98*19c3b8c2SApple OSS Distributions<dd>
99*19c3b8c2SApple OSS DistributionsProhibits execute access.
100*19c3b8c2SApple OSS Distributions<p>
101*19c3b8c2SApple OSS Distributions<dt> <strong>VM_PROT_ALL</strong>
102*19c3b8c2SApple OSS Distributions<dd>
103*19c3b8c2SApple OSS DistributionsProhibits all forms of access.
104*19c3b8c2SApple OSS Distributions</dl>
105*19c3b8c2SApple OSS Distributions<p>
106*19c3b8c2SApple OSS Distributions<dt> <var>reply_port</var>
107*19c3b8c2SApple OSS Distributions<dd>
108*19c3b8c2SApple OSS Distributions[in reply receive (to be converted to send) right]
109*19c3b8c2SApple OSS DistributionsThe response port to
110*19c3b8c2SApple OSS Distributionsbe used by the kernel on a call to <strong>memory_object_lock_completed</strong>,
111*19c3b8c2SApple OSS Distributionsor <strong>MACH_PORT_NULL</strong> if no response is required.
112*19c3b8c2SApple OSS Distributions</dl>
113*19c3b8c2SApple OSS Distributions<h3>DESCRIPTION</h3>
114*19c3b8c2SApple OSS Distributions<p>
115*19c3b8c2SApple OSS DistributionsThe <strong>memory_object_lock_request</strong> function allows the memory manager to
116*19c3b8c2SApple OSS Distributionsmake the following requests of the kernel:
117*19c3b8c2SApple OSS Distributions<ul>
118*19c3b8c2SApple OSS Distributions<li>
119*19c3b8c2SApple OSS DistributionsClean the pages within the specified range by writing back all changed (that
120*19c3b8c2SApple OSS Distributionsis, dirty) and precious pages.  The kernel uses the
121*19c3b8c2SApple OSS Distributions<strong>memory_object_data_return</strong> call to write back the data.
122*19c3b8c2SApple OSS DistributionsThe <var>should_return</var> parameter must be set to
123*19c3b8c2SApple OSS Distributionsnon-zero.
124*19c3b8c2SApple OSS Distributions     <p>
125*19c3b8c2SApple OSS Distributions<li>
126*19c3b8c2SApple OSS DistributionsFlush all cached data within the specified range.  The kernel invalidates the
127*19c3b8c2SApple OSS Distributionsrange of data and revokes all uses of that data.  The <var>should_flush</var>
128*19c3b8c2SApple OSS Distributionsparameter must be set to true.
129*19c3b8c2SApple OSS Distributions     <p>
130*19c3b8c2SApple OSS Distributions<li>
131*19c3b8c2SApple OSS DistributionsAlter access restrictions specified in the <strong>memory_object_data_supply</strong>
132*19c3b8c2SApple OSS Distributionscall
133*19c3b8c2SApple OSS Distributionsor a previous <strong>memory_object_lock_request</strong> call.  The
134*19c3b8c2SApple OSS Distributions<var>lock_value</var> parameter
135*19c3b8c2SApple OSS Distributionsmust specify the new access restrictions.  Note that this parameter can be
136*19c3b8c2SApple OSS Distributionsused to unlock previously locked data.
137*19c3b8c2SApple OSS Distributions</ul>
138*19c3b8c2SApple OSS Distributions<p>
139*19c3b8c2SApple OSS DistributionsOnce the kernel performs all of the actions requested by this
140*19c3b8c2SApple OSS Distributionscall, it issues a
141*19c3b8c2SApple OSS Distributions<strong>memory_object_lock_completed</strong> call using the <var>reply_to</var> port.
142*19c3b8c2SApple OSS Distributions<h3>NOTES</h3>
143*19c3b8c2SApple OSS Distributions<p>
144*19c3b8c2SApple OSS DistributionsThe <strong>memory_object_lock_request</strong> call affects only data
145*19c3b8c2SApple OSS Distributionsthat is cached at the
146*19c3b8c2SApple OSS Distributionstime of the call.  Access restrictions cannot be applied to pages
147*19c3b8c2SApple OSS Distributionsfor which data
148*19c3b8c2SApple OSS Distributionshas not been provided.
149*19c3b8c2SApple OSS Distributions<p>
150*19c3b8c2SApple OSS DistributionsWhen a running thread requires an access that is currently prohibited,
151*19c3b8c2SApple OSS Distributionsthe kernel
152*19c3b8c2SApple OSS Distributionsissues a <strong>memory_object_data_unlock</strong> call specifying
153*19c3b8c2SApple OSS Distributionsthe access required.  The
154*19c3b8c2SApple OSS Distributionsmemory manager can then use <strong>memory_object_lock_request</strong> to relax its
155*19c3b8c2SApple OSS Distributionsaccess restrictions on the data.
156*19c3b8c2SApple OSS Distributions<p>
157*19c3b8c2SApple OSS DistributionsTo indicate that an unlock request is invalid (that is, requires
158*19c3b8c2SApple OSS Distributionspermission that can
159*19c3b8c2SApple OSS Distributionsnever be granted), the memory manager must first flush the page.  When the
160*19c3b8c2SApple OSS Distributionskernel requests the data again with the higher permission, the
161*19c3b8c2SApple OSS Distributionsmemory manager can
162*19c3b8c2SApple OSS Distributionsindicate the error by responding with a call to
163*19c3b8c2SApple OSS Distributions<strong>memory_object_data_error</strong>.
164*19c3b8c2SApple OSS Distributions<h3>RETURN VALUES</h3>
165*19c3b8c2SApple OSS Distributions<p>
166*19c3b8c2SApple OSS DistributionsOnly generic errors apply.
167*19c3b8c2SApple OSS Distributions<h3>RELATED INFORMATION</h3>
168*19c3b8c2SApple OSS Distributions<p>
169*19c3b8c2SApple OSS DistributionsFunctions:
170*19c3b8c2SApple OSS Distributions<a href="memory_object_data_supply.html"><strong>memory_object_data_supply</strong></a>,
171*19c3b8c2SApple OSS Distributions<a href="memory_object_data_unlock.html"><strong>memory_object_data_unlock</strong></a>,
172*19c3b8c2SApple OSS Distributions<a href="MO_lock_completed.html"><strong>memory_object_lock_completed</strong></a>.
173*19c3b8c2SApple OSS Distributions
174