]>
git.saurik.com Git - apple/xnu.git/blob - tests/jumbo_va_spaces_28530648.c
7 #include <darwintest.h>
8 #include <darwintest_utils.h>
10 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
12 #define GB (1ULL * 1024 * 1024 * 1024)
15 * This test expects the entitlement to be the enabling factor for a process to
16 * allocate at least this many GB of VA space. i.e. with the entitlement, n GB
17 * must be allocatable; whereas without it, it must be less.
18 * This value was determined experimentally to fit on applicable devices and to
19 * be clearly distinguishable from the default VA limit.
21 #define ALLOC_TEST_GB 53
24 "Verify that a required entitlement is present in order to be granted an extra-large "
26 T_META_NAMESPACE("xnu.vm"),
27 T_META_CHECK_LEAKS(false))
32 if (!dt_64_bit_kernel()) {
33 T_SKIP("This test is only applicable to arm64");
36 T_LOG("Attemping to allocate VA space in 1 GB chunks.");
38 for (i
= 0; i
< (ALLOC_TEST_GB
* 2); i
++) {
39 res
= mmap(NULL
, 1 * GB
, PROT_NONE
, MAP_PRIVATE
| MAP_ANON
, 0, 0);
40 if (res
== MAP_FAILED
) {
41 if (errno
!= ENOMEM
) {
43 T_LOG("mmap failed: stopped at %d of %d GB allocated", i
, ALLOC_TEST_GB
);
47 T_LOG("%d: %p\n", i
, res
);
52 T_EXPECT_GE_INT(i
, ALLOC_TEST_GB
, "Allocate at least %d GB of VA space", ALLOC_TEST_GB
);
54 T_EXPECT_LT_INT(i
, ALLOC_TEST_GB
, "Not permitted to allocate %d GB of VA space", ALLOC_TEST_GB
);