1 /*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /**
29 * This file is meant to contain all of the PPL entry points and PPL-specific
30 * functionality.
31 *
32 * Every single function in the pmap that chooses between running a "*_ppl()" or
33 * "*_internal()" function variant will be placed into this file. This file also
34 * contains the ppl_handler_table, as well as a few PPL-only entry/exit helper
35 * functions.
36 *
37 * See doc/ppl.md for more information about how these PPL entry points work.
38 */
39 #include <kern/ledger.h>
40
41 #include <vm/vm_object_xnu.h>
42 #include <vm/vm_page.h>
43 #include <vm/vm_pageout.h>
44
45 #include <arm64/sptm/pmap/pmap_internal.h>
46
47 /**
48 * PMAP_SUPPORT_PROTOTYPES() will automatically create prototypes for the
49 * _internal() and _ppl() variants of a PPL entry point. It also automatically
50 * generates the code for the _ppl() variant which is what is used to jump into
51 * the PPL.
52 *
53 * See doc/ppl.md for more information about how these PPL entry points work.
54 */
55
56 PMAP_SUPPORT_PROTOTYPES(
57 kern_return_t,
58 mapping_free_prime, (void), MAPPING_FREE_PRIME_INDEX);
59
60 /**
61 * See pmap_cpu_data_init_internal()'s function header for more info.
62 */
63 void
pmap_cpu_data_init(void)64 pmap_cpu_data_init(void)
65 {
66 pmap_cpu_data_init_internal(cpu_number());
67 }
68
69 /**
70 * Prime the pv_entry_t free lists with a healthy amount of objects first thing
71 * during boot. These objects will be used to keep track of physical-to-virtual
72 * mappings.
73 */
74 void
mapping_free_prime(void)75 mapping_free_prime(void)
76 {
77 kern_return_t kr = KERN_FAILURE;
78
79 kr = mapping_free_prime_internal();
80
81 if (kr != KERN_SUCCESS) {
82 panic("%s: failed, no pages available? kr=%d", __func__, kr);
83 }
84 }
85
86 /**
87 * SPTM TODO: delete this function once the SPTM pmap becomes the sole pmap implementation.
88 * See pmap_ledger_verify_size_internal()'s function header for more information.
89 */
90 __attribute__((noreturn))
91 void
pmap_ledger_verify_size(size_t size)92 pmap_ledger_verify_size(size_t size)
93 {
94 panic("%s: unsupported on non-PPL systems, size=%lu", __func__, size);
95 __builtin_unreachable();
96 }
97
98 /**
99 * SPTM TODO: delete this function once the SPTM pmap becomes the sole pmap implementation.
100 * See pmap_ledger_alloc_internal()'s function header for more information.
101 */
102 ledger_t
pmap_ledger_alloc(void)103 pmap_ledger_alloc(void)
104 {
105 panic("%s: unsupported on non-PPL systems", __func__);
106 __builtin_unreachable();
107 }
108
109 /**
110 * SPTM TODO: delete this function once the SPTM pmap becomes the sole pmap implementation.
111 * See pmap_ledger_free_internal()'s function header for more information.
112 */
113 __attribute__((noreturn))
114 void
pmap_ledger_free(ledger_t ledger)115 pmap_ledger_free(ledger_t ledger)
116 {
117 panic("%s: unsupported on non-PPL systems, ledger=%p", __func__, ledger);
118 __builtin_unreachable();
119 }
120