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