1 /* 2 * Copyright (c) 2023 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 #ifndef _VM_SHARED_REGION_INTERNAL_H_ 30 #define _VM_SHARED_REGION_INTERNAL_H_ 31 32 #include <sys/cdefs.h> 33 #include <vm/vm_shared_region_xnu.h> 34 35 __BEGIN_DECLS 36 37 #ifdef MACH_KERNEL_PRIVATE 38 extern kern_return_t vm_shared_region_slide_page( 39 vm_shared_region_slide_info_t si, 40 vm_offset_t vaddr, 41 mach_vm_offset_t uservaddr, 42 uint32_t pageIndex, 43 uint64_t jop_key); 44 45 #endif /* MACH_KERNEL_PRIVATE */ 46 47 #ifdef XNU_KERNEL_PRIVATE 48 extern kern_return_t vm_shared_region_enter( 49 struct _vm_map *map, 50 struct task *task, 51 boolean_t is_64bit, 52 void *fsroot, 53 cpu_type_t cpu, 54 cpu_subtype_t cpu_subtype, 55 boolean_t reslide, 56 boolean_t is_driverkit, 57 uint32_t rsr_version); 58 extern void vm_shared_region_remove( 59 struct task *task, 60 struct vm_shared_region *sr); 61 extern vm_map_t vm_shared_region_vm_map( 62 struct vm_shared_region *shared_region); 63 extern vm_shared_region_t vm_shared_region_lookup( 64 void *root_dir, 65 cpu_type_t cpu, 66 cpu_subtype_t cpu_subtype, 67 boolean_t is_64bit, 68 int target_page_shift, 69 boolean_t reslide, 70 boolean_t is_driverkit, 71 uint32_t rsr_version); 72 extern kern_return_t vm_shared_region_start_address( 73 struct vm_shared_region *shared_region, 74 mach_vm_offset_t *start_address); 75 extern void vm_shared_region_undo_mappings( 76 vm_map_t sr_map, 77 mach_vm_offset_t sr_base_address, 78 struct _sr_file_mappings *srf_mappings, 79 struct _sr_file_mappings *srf_mappings_count, 80 unsigned int mappings_count); 81 __attribute__((noinline)) 82 extern kern_return_t vm_shared_region_map_file( 83 struct vm_shared_region *shared_region, 84 int sr_mappings_count, 85 struct _sr_file_mappings *sr_mappings); 86 extern void *vm_shared_region_root_dir( 87 struct vm_shared_region *shared_region); 88 extern kern_return_t vm_commpage_enter( 89 struct _vm_map *map, 90 struct task *task, 91 boolean_t is64bit); 92 int vm_shared_region_slide(uint32_t, 93 mach_vm_offset_t, 94 mach_vm_size_t, 95 mach_vm_offset_t, 96 mach_vm_size_t, 97 mach_vm_offset_t, 98 memory_object_control_t, 99 vm_prot_t); 100 extern void vm_shared_region_pivot(void); 101 #if __has_feature(ptrauth_calls) 102 __attribute__((noinline)) 103 extern kern_return_t vm_shared_region_auth_remap(vm_shared_region_t sr); 104 #endif /* __has_feature(ptrauth_calls) */ 105 extern void vm_shared_region_reference(vm_shared_region_t sr); 106 107 #endif /* XNU_KERNEL_PRIVATE */ 108 __END_DECLS 109 110 #endif /* _VM_SHARED_REGION_INTERNAL_H_ */ 111