1*043036a2SApple OSS Distributions /*
2*043036a2SApple OSS Distributions * Copyright (c) 2024 Apple Inc. All rights reserved.
3*043036a2SApple OSS Distributions *
4*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*043036a2SApple OSS Distributions *
6*043036a2SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*043036a2SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*043036a2SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*043036a2SApple OSS Distributions * compliance with the License. The rights granted to you under the License
10*043036a2SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
11*043036a2SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
12*043036a2SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
13*043036a2SApple OSS Distributions * terms of an Apple operating system software license agreement.
14*043036a2SApple OSS Distributions *
15*043036a2SApple OSS Distributions * Please obtain a copy of the License at
16*043036a2SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*043036a2SApple OSS Distributions *
18*043036a2SApple OSS Distributions * The Original Code and all software distributed under the License are
19*043036a2SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*043036a2SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*043036a2SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*043036a2SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*043036a2SApple OSS Distributions * Please see the License for the specific language governing rights and
24*043036a2SApple OSS Distributions * limitations under the License.
25*043036a2SApple OSS Distributions *
26*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*043036a2SApple OSS Distributions */
28*043036a2SApple OSS Distributions
29*043036a2SApple OSS Distributions /*
30*043036a2SApple OSS Distributions * vm/configurator_vm_protect.c
31*043036a2SApple OSS Distributions *
32*043036a2SApple OSS Distributions * Test vm_protect with many different VM states.
33*043036a2SApple OSS Distributions */
34*043036a2SApple OSS Distributions
35*043036a2SApple OSS Distributions #include "configurator/vm_configurator_tests.h"
36*043036a2SApple OSS Distributions
37*043036a2SApple OSS Distributions T_GLOBAL_META(
38*043036a2SApple OSS Distributions T_META_NAMESPACE("xnu.vm.configurator"),
39*043036a2SApple OSS Distributions T_META_RADAR_COMPONENT_NAME("xnu"),
40*043036a2SApple OSS Distributions T_META_RADAR_COMPONENT_VERSION("VM"),
41*043036a2SApple OSS Distributions T_META_RUN_CONCURRENTLY(true),
42*043036a2SApple OSS Distributions T_META_ASROOT(true), /* required for vm submap sysctls */
43*043036a2SApple OSS Distributions T_META_ALL_VALID_ARCHS(true)
44*043036a2SApple OSS Distributions );
45*043036a2SApple OSS Distributions
46*043036a2SApple OSS Distributions
47*043036a2SApple OSS Distributions /*
48*043036a2SApple OSS Distributions * Update checker state to mirror a successful call to vm_protect.
49*043036a2SApple OSS Distributions */
50*043036a2SApple OSS Distributions static void
checker_perform_vm_protect(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size,bool set_max,vm_prot_t prot)51*043036a2SApple OSS Distributions checker_perform_vm_protect(
52*043036a2SApple OSS Distributions checker_list_t *checker_list,
53*043036a2SApple OSS Distributions mach_vm_address_t start,
54*043036a2SApple OSS Distributions mach_vm_size_t size,
55*043036a2SApple OSS Distributions bool set_max,
56*043036a2SApple OSS Distributions vm_prot_t prot)
57*043036a2SApple OSS Distributions {
58*043036a2SApple OSS Distributions entry_checker_range_t limit =
59*043036a2SApple OSS Distributions checker_list_find_and_clip(checker_list, start, size);
60*043036a2SApple OSS Distributions FOREACH_CHECKER(checker, limit) {
61*043036a2SApple OSS Distributions if (set_max) {
62*043036a2SApple OSS Distributions checker->max_protection = prot;
63*043036a2SApple OSS Distributions checker->protection &= checker->max_protection;
64*043036a2SApple OSS Distributions } else {
65*043036a2SApple OSS Distributions checker->protection = prot;
66*043036a2SApple OSS Distributions }
67*043036a2SApple OSS Distributions }
68*043036a2SApple OSS Distributions checker_list_simplify(checker_list, start, size);
69*043036a2SApple OSS Distributions }
70*043036a2SApple OSS Distributions
71*043036a2SApple OSS Distributions /*
72*043036a2SApple OSS Distributions * Perform and check a call to mach_vm_protect that is expected to succeed.
73*043036a2SApple OSS Distributions */
74*043036a2SApple OSS Distributions static test_result_t
vm_protect_successfully(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size,vm_prot_t prot)75*043036a2SApple OSS Distributions vm_protect_successfully(
76*043036a2SApple OSS Distributions checker_list_t *checker_list,
77*043036a2SApple OSS Distributions mach_vm_address_t start,
78*043036a2SApple OSS Distributions mach_vm_size_t size,
79*043036a2SApple OSS Distributions vm_prot_t prot)
80*043036a2SApple OSS Distributions {
81*043036a2SApple OSS Distributions kern_return_t kr;
82*043036a2SApple OSS Distributions
83*043036a2SApple OSS Distributions bool set_max = false;
84*043036a2SApple OSS Distributions
85*043036a2SApple OSS Distributions checker_perform_vm_protect(checker_list, start, size, set_max, prot);
86*043036a2SApple OSS Distributions kr = mach_vm_protect(mach_task_self(), start, size, set_max, prot);
87*043036a2SApple OSS Distributions if (kr != 0) {
88*043036a2SApple OSS Distributions T_FAIL("mach_vm_protect(%s) failed (%s)",
89*043036a2SApple OSS Distributions name_for_prot(prot), name_for_kr(kr));
90*043036a2SApple OSS Distributions return TestFailed;
91*043036a2SApple OSS Distributions }
92*043036a2SApple OSS Distributions
93*043036a2SApple OSS Distributions TEMP_CSTRING(name, "after vm_protect(%s)", name_for_prot(prot));
94*043036a2SApple OSS Distributions return verify_vm_state(checker_list, name);
95*043036a2SApple OSS Distributions }
96*043036a2SApple OSS Distributions
97*043036a2SApple OSS Distributions /*
98*043036a2SApple OSS Distributions * Perform and check mach_vm_protect that is expected to fail due to holes.
99*043036a2SApple OSS Distributions */
100*043036a2SApple OSS Distributions static test_result_t
vm_protect_with_holes(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)101*043036a2SApple OSS Distributions vm_protect_with_holes(
102*043036a2SApple OSS Distributions checker_list_t *checker_list,
103*043036a2SApple OSS Distributions mach_vm_address_t start,
104*043036a2SApple OSS Distributions mach_vm_size_t size)
105*043036a2SApple OSS Distributions {
106*043036a2SApple OSS Distributions kern_return_t kr;
107*043036a2SApple OSS Distributions
108*043036a2SApple OSS Distributions /*
109*043036a2SApple OSS Distributions * No checker updates here. vm_map_protect preflights its checks,
110*043036a2SApple OSS Distributions * so it fails with no side effects when the address range has holes.
111*043036a2SApple OSS Distributions */
112*043036a2SApple OSS Distributions
113*043036a2SApple OSS Distributions kr = mach_vm_protect(mach_task_self(), start, size, false, VM_PROT_READ);
114*043036a2SApple OSS Distributions if (kr != KERN_INVALID_ADDRESS) {
115*043036a2SApple OSS Distributions T_FAIL("mach_vm_protect(holes) expected %s, got %s\n",
116*043036a2SApple OSS Distributions name_for_kr(KERN_INVALID_ADDRESS), name_for_kr(kr));
117*043036a2SApple OSS Distributions return TestFailed;
118*043036a2SApple OSS Distributions }
119*043036a2SApple OSS Distributions
120*043036a2SApple OSS Distributions return verify_vm_state(checker_list, "after vm_protect");
121*043036a2SApple OSS Distributions }
122*043036a2SApple OSS Distributions
123*043036a2SApple OSS Distributions /*
124*043036a2SApple OSS Distributions * Perform and check mach_vm_protect that is expected to fail because
125*043036a2SApple OSS Distributions * the requested protections are more permissive than max_protection.
126*043036a2SApple OSS Distributions */
127*043036a2SApple OSS Distributions static test_result_t
vm_protect_beyond_max_prot(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size,vm_prot_t prot)128*043036a2SApple OSS Distributions vm_protect_beyond_max_prot(
129*043036a2SApple OSS Distributions checker_list_t *checker_list,
130*043036a2SApple OSS Distributions mach_vm_address_t start,
131*043036a2SApple OSS Distributions mach_vm_size_t size,
132*043036a2SApple OSS Distributions vm_prot_t prot)
133*043036a2SApple OSS Distributions {
134*043036a2SApple OSS Distributions kern_return_t kr;
135*043036a2SApple OSS Distributions
136*043036a2SApple OSS Distributions /*
137*043036a2SApple OSS Distributions * No checker updates here. vm_map_protect preflights its checks,
138*043036a2SApple OSS Distributions * so it fails with no effect.
139*043036a2SApple OSS Distributions */
140*043036a2SApple OSS Distributions
141*043036a2SApple OSS Distributions kr = mach_vm_protect(mach_task_self(), start, size, false /*set max*/, prot);
142*043036a2SApple OSS Distributions if (kr != KERN_PROTECTION_FAILURE) {
143*043036a2SApple OSS Distributions T_FAIL("mach_vm_protect(%s which is beyond max) expected %s, got %s\n",
144*043036a2SApple OSS Distributions name_for_prot(prot),
145*043036a2SApple OSS Distributions name_for_kr(KERN_PROTECTION_FAILURE), name_for_kr(kr));
146*043036a2SApple OSS Distributions return TestFailed;
147*043036a2SApple OSS Distributions }
148*043036a2SApple OSS Distributions
149*043036a2SApple OSS Distributions TEMP_CSTRING(name, "after vm_protect(%s)", name_for_prot(prot));
150*043036a2SApple OSS Distributions return verify_vm_state(checker_list, name);
151*043036a2SApple OSS Distributions }
152*043036a2SApple OSS Distributions
153*043036a2SApple OSS Distributions
154*043036a2SApple OSS Distributions /*
155*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
156*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_NONE
157*043036a2SApple OSS Distributions */
158*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_000(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)159*043036a2SApple OSS Distributions vm_protect_max_000(
160*043036a2SApple OSS Distributions checker_list_t *checker_list,
161*043036a2SApple OSS Distributions mach_vm_address_t start,
162*043036a2SApple OSS Distributions mach_vm_size_t size)
163*043036a2SApple OSS Distributions {
164*043036a2SApple OSS Distributions test_result_t results[4];
165*043036a2SApple OSS Distributions
166*043036a2SApple OSS Distributions results[0] = vm_protect_successfully(checker_list, start, size, VM_PROT_NONE);
167*043036a2SApple OSS Distributions results[1] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_READ);
168*043036a2SApple OSS Distributions results[2] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_WRITE);
169*043036a2SApple OSS Distributions results[3] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_READ | VM_PROT_WRITE);
170*043036a2SApple OSS Distributions
171*043036a2SApple OSS Distributions return worst_result(results, countof(results));
172*043036a2SApple OSS Distributions }
173*043036a2SApple OSS Distributions
174*043036a2SApple OSS Distributions /*
175*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
176*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_READ
177*043036a2SApple OSS Distributions */
178*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_r00(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)179*043036a2SApple OSS Distributions vm_protect_max_r00(
180*043036a2SApple OSS Distributions checker_list_t *checker_list,
181*043036a2SApple OSS Distributions mach_vm_address_t start,
182*043036a2SApple OSS Distributions mach_vm_size_t size)
183*043036a2SApple OSS Distributions {
184*043036a2SApple OSS Distributions test_result_t results[4];
185*043036a2SApple OSS Distributions
186*043036a2SApple OSS Distributions results[0] = vm_protect_successfully(checker_list, start, size, VM_PROT_NONE);
187*043036a2SApple OSS Distributions results[1] = vm_protect_successfully(checker_list, start, size, VM_PROT_READ);
188*043036a2SApple OSS Distributions results[2] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_WRITE);
189*043036a2SApple OSS Distributions results[3] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_READ | VM_PROT_WRITE);
190*043036a2SApple OSS Distributions
191*043036a2SApple OSS Distributions return worst_result(results, countof(results));
192*043036a2SApple OSS Distributions }
193*043036a2SApple OSS Distributions
194*043036a2SApple OSS Distributions /*
195*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
196*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_WRITE
197*043036a2SApple OSS Distributions */
198*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_0w0(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)199*043036a2SApple OSS Distributions vm_protect_max_0w0(
200*043036a2SApple OSS Distributions checker_list_t *checker_list,
201*043036a2SApple OSS Distributions mach_vm_address_t start,
202*043036a2SApple OSS Distributions mach_vm_size_t size)
203*043036a2SApple OSS Distributions {
204*043036a2SApple OSS Distributions test_result_t results[4];
205*043036a2SApple OSS Distributions
206*043036a2SApple OSS Distributions results[0] = vm_protect_successfully(checker_list, start, size, VM_PROT_NONE);
207*043036a2SApple OSS Distributions results[1] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_READ);
208*043036a2SApple OSS Distributions results[2] = vm_protect_successfully(checker_list, start, size, VM_PROT_WRITE);
209*043036a2SApple OSS Distributions results[3] = vm_protect_beyond_max_prot(checker_list, start, size, VM_PROT_READ | VM_PROT_WRITE);
210*043036a2SApple OSS Distributions
211*043036a2SApple OSS Distributions return worst_result(results, countof(results));
212*043036a2SApple OSS Distributions }
213*043036a2SApple OSS Distributions
214*043036a2SApple OSS Distributions
215*043036a2SApple OSS Distributions /*
216*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
217*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_READ | VM_PROT_WRITE
218*043036a2SApple OSS Distributions */
219*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_rw0(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)220*043036a2SApple OSS Distributions vm_protect_max_rw0(
221*043036a2SApple OSS Distributions checker_list_t *checker_list,
222*043036a2SApple OSS Distributions mach_vm_address_t start,
223*043036a2SApple OSS Distributions mach_vm_size_t size)
224*043036a2SApple OSS Distributions {
225*043036a2SApple OSS Distributions test_result_t results[4];
226*043036a2SApple OSS Distributions
227*043036a2SApple OSS Distributions results[0] = vm_protect_successfully(checker_list, start, size, VM_PROT_NONE);
228*043036a2SApple OSS Distributions results[1] = vm_protect_successfully(checker_list, start, size, VM_PROT_READ);
229*043036a2SApple OSS Distributions results[2] = vm_protect_successfully(checker_list, start, size, VM_PROT_WRITE);
230*043036a2SApple OSS Distributions results[3] = vm_protect_successfully(checker_list, start, size, VM_PROT_READ | VM_PROT_WRITE);
231*043036a2SApple OSS Distributions
232*043036a2SApple OSS Distributions return worst_result(results, countof(results));
233*043036a2SApple OSS Distributions }
234*043036a2SApple OSS Distributions
235*043036a2SApple OSS Distributions #if __x86_64__
236*043036a2SApple OSS Distributions /*
237*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
238*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXEC
239*043036a2SApple OSS Distributions */
240*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_rwx(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)241*043036a2SApple OSS Distributions vm_protect_max_rwx(
242*043036a2SApple OSS Distributions checker_list_t *checker_list,
243*043036a2SApple OSS Distributions mach_vm_address_t start,
244*043036a2SApple OSS Distributions mach_vm_size_t size)
245*043036a2SApple OSS Distributions {
246*043036a2SApple OSS Distributions /* TODO VM_PROT_EXEC */
247*043036a2SApple OSS Distributions return vm_protect_max_rw0(checker_list, start, size);
248*043036a2SApple OSS Distributions }
249*043036a2SApple OSS Distributions #endif /* __x86_64__ */
250*043036a2SApple OSS Distributions
251*043036a2SApple OSS Distributions /*
252*043036a2SApple OSS Distributions * Perform multiple successful and unsuccessful vm_protect operations
253*043036a2SApple OSS Distributions * on a region whose max_protections are VM_PROT_READ
254*043036a2SApple OSS Distributions * OR whose max protections are READ|WRITE|EXEC due to Intel submap unnesting.
255*043036a2SApple OSS Distributions */
256*043036a2SApple OSS Distributions static test_result_t
vm_protect_max_r00_or_unnested_submap(checker_list_t * checker_list,mach_vm_address_t start,mach_vm_size_t size)257*043036a2SApple OSS Distributions vm_protect_max_r00_or_unnested_submap(
258*043036a2SApple OSS Distributions checker_list_t *checker_list,
259*043036a2SApple OSS Distributions mach_vm_address_t start,
260*043036a2SApple OSS Distributions mach_vm_size_t size)
261*043036a2SApple OSS Distributions {
262*043036a2SApple OSS Distributions #if __x86_64__
263*043036a2SApple OSS Distributions return vm_protect_max_rwx(checker_list, start, size);
264*043036a2SApple OSS Distributions #else /* not __x86_64__ */
265*043036a2SApple OSS Distributions return vm_protect_max_r00(checker_list, start, size);
266*043036a2SApple OSS Distributions #endif /* not __x86_64__ */
267*043036a2SApple OSS Distributions }
268*043036a2SApple OSS Distributions
269*043036a2SApple OSS Distributions T_DECL(vm_protect,
270*043036a2SApple OSS Distributions "run vm_protect with various vm configurations")
271*043036a2SApple OSS Distributions {
272*043036a2SApple OSS Distributions vm_tests_t tests = {
273*043036a2SApple OSS Distributions .single_entry_1 = vm_protect_max_rw0,
274*043036a2SApple OSS Distributions .single_entry_2 = vm_protect_max_rw0,
275*043036a2SApple OSS Distributions .single_entry_3 = vm_protect_max_rw0,
276*043036a2SApple OSS Distributions .single_entry_4 = vm_protect_max_rw0,
277*043036a2SApple OSS Distributions
278*043036a2SApple OSS Distributions .multiple_entries_1 = vm_protect_max_rw0,
279*043036a2SApple OSS Distributions .multiple_entries_2 = vm_protect_max_rw0,
280*043036a2SApple OSS Distributions .multiple_entries_3 = vm_protect_max_rw0,
281*043036a2SApple OSS Distributions .multiple_entries_4 = vm_protect_max_rw0,
282*043036a2SApple OSS Distributions .multiple_entries_5 = vm_protect_max_rw0,
283*043036a2SApple OSS Distributions .multiple_entries_6 = vm_protect_max_rw0,
284*043036a2SApple OSS Distributions
285*043036a2SApple OSS Distributions .some_holes_1 = vm_protect_with_holes,
286*043036a2SApple OSS Distributions .some_holes_2 = vm_protect_with_holes,
287*043036a2SApple OSS Distributions .some_holes_3 = vm_protect_with_holes,
288*043036a2SApple OSS Distributions .some_holes_4 = vm_protect_with_holes,
289*043036a2SApple OSS Distributions .some_holes_5 = vm_protect_with_holes,
290*043036a2SApple OSS Distributions .some_holes_6 = vm_protect_with_holes,
291*043036a2SApple OSS Distributions .some_holes_7 = vm_protect_with_holes,
292*043036a2SApple OSS Distributions .some_holes_8 = vm_protect_with_holes,
293*043036a2SApple OSS Distributions .some_holes_9 = vm_protect_with_holes,
294*043036a2SApple OSS Distributions .some_holes_10 = vm_protect_with_holes,
295*043036a2SApple OSS Distributions .some_holes_11 = vm_protect_with_holes,
296*043036a2SApple OSS Distributions .some_holes_12 = vm_protect_with_holes,
297*043036a2SApple OSS Distributions
298*043036a2SApple OSS Distributions .all_holes_1 = vm_protect_with_holes,
299*043036a2SApple OSS Distributions .all_holes_2 = vm_protect_with_holes,
300*043036a2SApple OSS Distributions .all_holes_3 = vm_protect_with_holes,
301*043036a2SApple OSS Distributions .all_holes_4 = vm_protect_with_holes,
302*043036a2SApple OSS Distributions
303*043036a2SApple OSS Distributions .null_entry = vm_protect_max_rw0,
304*043036a2SApple OSS Distributions .nonresident_entry = vm_protect_max_rw0,
305*043036a2SApple OSS Distributions .resident_entry = vm_protect_max_rw0,
306*043036a2SApple OSS Distributions
307*043036a2SApple OSS Distributions .shared_entry = vm_protect_max_rw0,
308*043036a2SApple OSS Distributions .shared_entry_discontiguous = vm_protect_max_rw0,
309*043036a2SApple OSS Distributions .shared_entry_partial = vm_protect_max_rw0,
310*043036a2SApple OSS Distributions .shared_entry_pairs = vm_protect_max_rw0,
311*043036a2SApple OSS Distributions .shared_entry_x1000 = vm_protect_max_rw0,
312*043036a2SApple OSS Distributions
313*043036a2SApple OSS Distributions .cow_entry = vm_protect_max_rw0,
314*043036a2SApple OSS Distributions .cow_unreferenced = vm_protect_max_rw0,
315*043036a2SApple OSS Distributions .cow_nocow = vm_protect_max_rw0,
316*043036a2SApple OSS Distributions .nocow_cow = vm_protect_max_rw0,
317*043036a2SApple OSS Distributions .cow_unreadable = vm_protect_max_rw0,
318*043036a2SApple OSS Distributions .cow_unwriteable = vm_protect_max_rw0,
319*043036a2SApple OSS Distributions
320*043036a2SApple OSS Distributions .permanent_entry = vm_protect_max_rw0,
321*043036a2SApple OSS Distributions .permanent_before_permanent = vm_protect_max_rw0,
322*043036a2SApple OSS Distributions .permanent_before_allocation = vm_protect_max_rw0,
323*043036a2SApple OSS Distributions .permanent_before_allocation_2 = vm_protect_max_rw0,
324*043036a2SApple OSS Distributions .permanent_before_hole = vm_protect_with_holes,
325*043036a2SApple OSS Distributions .permanent_after_allocation = vm_protect_max_rw0,
326*043036a2SApple OSS Distributions .permanent_after_hole = vm_protect_with_holes,
327*043036a2SApple OSS Distributions
328*043036a2SApple OSS Distributions /*
329*043036a2SApple OSS Distributions * vm_protect without VM_PROT_COPY does not descend into submaps.
330*043036a2SApple OSS Distributions * The parent map's submap entry is r--/r--.
331*043036a2SApple OSS Distributions */
332*043036a2SApple OSS Distributions .single_submap_single_entry = vm_protect_max_r00_or_unnested_submap,
333*043036a2SApple OSS Distributions .single_submap_single_entry_first_pages = vm_protect_max_r00_or_unnested_submap,
334*043036a2SApple OSS Distributions .single_submap_single_entry_last_pages = vm_protect_max_r00_or_unnested_submap,
335*043036a2SApple OSS Distributions .single_submap_single_entry_middle_pages = vm_protect_max_r00_or_unnested_submap,
336*043036a2SApple OSS Distributions .single_submap_oversize_entry_at_start = vm_protect_max_r00_or_unnested_submap,
337*043036a2SApple OSS Distributions .single_submap_oversize_entry_at_end = vm_protect_max_r00_or_unnested_submap,
338*043036a2SApple OSS Distributions .single_submap_oversize_entry_at_both = vm_protect_max_r00_or_unnested_submap,
339*043036a2SApple OSS Distributions
340*043036a2SApple OSS Distributions .submap_before_allocation = vm_protect_max_r00_or_unnested_submap,
341*043036a2SApple OSS Distributions .submap_after_allocation = vm_protect_max_r00_or_unnested_submap,
342*043036a2SApple OSS Distributions .submap_before_hole = vm_protect_with_holes,
343*043036a2SApple OSS Distributions .submap_after_hole = vm_protect_with_holes,
344*043036a2SApple OSS Distributions .submap_allocation_submap_one_entry = vm_protect_max_r00_or_unnested_submap,
345*043036a2SApple OSS Distributions .submap_allocation_submap_two_entries = vm_protect_max_r00_or_unnested_submap,
346*043036a2SApple OSS Distributions .submap_allocation_submap_three_entries = vm_protect_max_r00_or_unnested_submap,
347*043036a2SApple OSS Distributions
348*043036a2SApple OSS Distributions .submap_before_allocation_ro = vm_protect_max_r00_or_unnested_submap,
349*043036a2SApple OSS Distributions .submap_after_allocation_ro = vm_protect_max_r00_or_unnested_submap,
350*043036a2SApple OSS Distributions .submap_before_hole_ro = vm_protect_with_holes,
351*043036a2SApple OSS Distributions .submap_after_hole_ro = vm_protect_with_holes,
352*043036a2SApple OSS Distributions .submap_allocation_submap_one_entry_ro = vm_protect_max_r00_or_unnested_submap,
353*043036a2SApple OSS Distributions .submap_allocation_submap_two_entries_ro = vm_protect_max_r00_or_unnested_submap,
354*043036a2SApple OSS Distributions .submap_allocation_submap_three_entries_ro = vm_protect_max_r00_or_unnested_submap,
355*043036a2SApple OSS Distributions
356*043036a2SApple OSS Distributions .protection_single_000_000 = vm_protect_max_000,
357*043036a2SApple OSS Distributions .protection_single_000_r00 = vm_protect_max_r00,
358*043036a2SApple OSS Distributions .protection_single_r00_r00 = vm_protect_max_r00,
359*043036a2SApple OSS Distributions .protection_single_000_0w0 = vm_protect_max_0w0,
360*043036a2SApple OSS Distributions .protection_single_0w0_0w0 = vm_protect_max_0w0,
361*043036a2SApple OSS Distributions .protection_single_000_rw0 = vm_protect_max_rw0,
362*043036a2SApple OSS Distributions .protection_single_r00_rw0 = vm_protect_max_rw0,
363*043036a2SApple OSS Distributions .protection_single_0w0_rw0 = vm_protect_max_rw0,
364*043036a2SApple OSS Distributions .protection_single_rw0_rw0 = vm_protect_max_rw0,
365*043036a2SApple OSS Distributions
366*043036a2SApple OSS Distributions .protection_pairs_000_000 = vm_protect_max_rw0,
367*043036a2SApple OSS Distributions .protection_pairs_000_r00 = vm_protect_max_rw0,
368*043036a2SApple OSS Distributions .protection_pairs_000_0w0 = vm_protect_max_rw0,
369*043036a2SApple OSS Distributions .protection_pairs_000_rw0 = vm_protect_max_rw0,
370*043036a2SApple OSS Distributions .protection_pairs_r00_000 = vm_protect_max_rw0,
371*043036a2SApple OSS Distributions .protection_pairs_r00_r00 = vm_protect_max_rw0,
372*043036a2SApple OSS Distributions .protection_pairs_r00_0w0 = vm_protect_max_rw0,
373*043036a2SApple OSS Distributions .protection_pairs_r00_rw0 = vm_protect_max_rw0,
374*043036a2SApple OSS Distributions .protection_pairs_0w0_000 = vm_protect_max_rw0,
375*043036a2SApple OSS Distributions .protection_pairs_0w0_r00 = vm_protect_max_rw0,
376*043036a2SApple OSS Distributions .protection_pairs_0w0_0w0 = vm_protect_max_rw0,
377*043036a2SApple OSS Distributions .protection_pairs_0w0_rw0 = vm_protect_max_rw0,
378*043036a2SApple OSS Distributions .protection_pairs_rw0_000 = vm_protect_max_rw0,
379*043036a2SApple OSS Distributions .protection_pairs_rw0_r00 = vm_protect_max_rw0,
380*043036a2SApple OSS Distributions .protection_pairs_rw0_0w0 = vm_protect_max_rw0,
381*043036a2SApple OSS Distributions .protection_pairs_rw0_rw0 = vm_protect_max_rw0,
382*043036a2SApple OSS Distributions };
383*043036a2SApple OSS Distributions
384*043036a2SApple OSS Distributions run_vm_tests("vm_protect", __FILE__, &tests, argc, argv);
385*043036a2SApple OSS Distributions }
386