]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/vm/vm_protos.h
xnu-4903.231.4.tar.gz
[apple/xnu.git] / osfmk / vm / vm_protos.h
index fa8c278724a4d2b1c20f642d9ff8305b0ea5a607..cf4ad88ce994d854d054b4ec659bf942cbd55c3d 100644 (file)
 #include <mach/mach_types.h>
 #include <kern/kern_types.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * This file contains various type definitions and routine prototypes
  * that are needed to avoid compilation warnings for VM code (in osfmk,
@@ -58,12 +62,7 @@ extern kern_return_t device_data_action(
 extern kern_return_t device_close(
        uintptr_t     device_handle);
 
-/*
- * default_pager
- */
-extern int start_def_pager(
-       char *bs_device);
-extern int default_pager_init_flag;
+extern boolean_t vm_swap_files_pinned(void);
 
 /*
  * osfmk
@@ -74,11 +73,19 @@ extern mach_port_name_t ipc_port_copyout_send(
        ipc_space_t     space);
 extern task_t port_name_to_task(
        mach_port_name_t name);
+extern task_t port_name_to_task_inspect(
+       mach_port_name_t name);
+extern void ipc_port_release_send(
+       ipc_port_t      port);
 #endif /* _IPC_IPC_PORT_H_ */
 
 extern ipc_space_t  get_task_ipcspace(
        task_t t);
 
+#if CONFIG_MEMORYSTATUS
+extern int max_task_footprint_mb;      /* Per-task limit on physical memory consumption in megabytes */
+#endif /* CONFIG_MEMORYSTATUS */
+
 /* Some loose-ends VM stuff */
 
 extern vm_map_t                kalloc_map;
@@ -86,13 +93,31 @@ extern vm_size_t    msg_ool_size_small;
 extern vm_map_t                zone_map;
 
 extern void consider_machine_adjust(void);
-extern pmap_t get_map_pmap(vm_map_t);
 extern vm_map_offset_t get_map_min(vm_map_t);
 extern vm_map_offset_t get_map_max(vm_map_t);
 extern vm_map_size_t get_vmmap_size(vm_map_t);
+#if CONFIG_COREDUMP
 extern int get_vmmap_entries(vm_map_t);
+#endif
+extern int get_map_nentries(vm_map_t);
+
+extern vm_map_offset_t vm_map_page_mask(vm_map_t);
 
+extern kern_return_t vm_map_purgable_control(
+                               vm_map_t                map,
+                               vm_map_offset_t         address,
+                               vm_purgable_t           control,
+                               int                     *state);
+
+extern kern_return_t
+vnode_pager_get_object_vnode(
+       memory_object_t mem_obj,
+       uintptr_t * vnodeaddr,
+       uint32_t * vid);
+
+#if CONFIG_COREDUMP
 extern boolean_t coredumpok(vm_map_t map, vm_offset_t va);
+#endif
 
 /*
  * VM routines that used to be published to
@@ -127,31 +152,90 @@ extern mach_vm_offset_t mach_get_vm_start(vm_map_t);
 extern mach_vm_offset_t mach_get_vm_end(vm_map_t);
 
 #if CONFIG_CODE_DECRYPTION
+#define VM_MAP_DEBUG_APPLE_PROTECT     MACH_ASSERT
+#if VM_MAP_DEBUG_APPLE_PROTECT
+extern int vm_map_debug_apple_protect;
+#endif /* VM_MAP_DEBUG_APPLE_PROTECT */
 struct pager_crypt_info;
 extern kern_return_t vm_map_apple_protected(
-                                           vm_map_t    map,
-                                           vm_map_offset_t     start,
-                                           vm_map_offset_t     end,
-                                           struct pager_crypt_info *crypt_info);
+       vm_map_t                map,
+       vm_map_offset_t         start,
+       vm_map_offset_t         end,
+       vm_object_offset_t      crypto_backing_offset,
+       struct pager_crypt_info *crypt_info);
 extern void apple_protect_pager_bootstrap(void);
-extern memory_object_t apple_protect_pager_setup(vm_object_t backing_object,
-                                                struct pager_crypt_info *crypt_info);
+extern memory_object_t apple_protect_pager_setup(
+       vm_object_t             backing_object,
+       vm_object_offset_t      backing_offset,
+       vm_object_offset_t      crypto_backing_offset,
+       struct pager_crypt_info *crypt_info,
+       vm_object_offset_t      crypto_start,
+       vm_object_offset_t      crypto_end);
 #endif /* CONFIG_CODE_DECRYPTION */
 
+struct vm_shared_region_slide_info;
+extern kern_return_t vm_map_shared_region(
+       vm_map_t                map,
+       vm_map_offset_t         start,
+       vm_map_offset_t         end,
+       vm_object_offset_t      backing_offset,
+       struct vm_shared_region_slide_info *slide_info);
+extern void shared_region_pager_bootstrap(void);
+extern memory_object_t shared_region_pager_setup(
+       vm_object_t             backing_object,
+       vm_object_offset_t      backing_offset,
+       struct vm_shared_region_slide_info *slide_info);
+
 struct vnode;
 extern void swapfile_pager_bootstrap(void);
 extern memory_object_t swapfile_pager_setup(struct vnode *vp);
 extern memory_object_control_t swapfile_pager_control(memory_object_t mem_obj);
 
+#if __arm64__ || ((__ARM_ARCH_7K__ >= 2) && defined(PLATFORM_WatchOS))
+#define SIXTEENK_PAGE_SIZE     0x4000
+#define SIXTEENK_PAGE_MASK     0x3FFF
+#define SIXTEENK_PAGE_SHIFT    14
+#endif /* __arm64__ || ((__ARM_ARCH_7K__ >= 2) && defined(PLATFORM_WatchOS)) */
+
+#if __arm64__
+#define FOURK_PAGE_SIZE                0x1000
+#define FOURK_PAGE_MASK                0xFFF
+#define FOURK_PAGE_SHIFT       12
+
+extern unsigned int page_shift_user32;
+
+#define VM_MAP_DEBUG_FOURK     MACH_ASSERT
+#if VM_MAP_DEBUG_FOURK
+extern int vm_map_debug_fourk;
+#endif /* VM_MAP_DEBUG_FOURK */
+extern void fourk_pager_bootstrap(void);
+extern memory_object_t fourk_pager_create(void);
+extern vm_object_t fourk_pager_to_vm_object(memory_object_t mem_obj);
+extern kern_return_t fourk_pager_populate(
+       memory_object_t mem_obj,
+       boolean_t overwrite,
+       int index,
+       vm_object_t new_backing_object,
+       vm_object_offset_t new_backing_offset,
+       vm_object_t *old_backing_object,
+       vm_object_offset_t *old_backing_offset);
+#endif /* __arm64__ */
 
 /*
  * bsd
  */
 struct vnode;
-extern void vnode_pager_shutdown(void);
 extern void *upl_get_internal_page_list(
        upl_t upl);
 
+extern void vnode_setswapmount(struct vnode *);
+extern int64_t vnode_getswappin_avail(struct vnode *);
+
+extern void vnode_pager_was_dirtied(
+        struct vnode *,
+       vm_object_offset_t,
+       vm_object_offset_t);
+
 typedef int pager_return_t;
 extern pager_return_t  vnode_pagein(
        struct vnode *, upl_t,
@@ -172,21 +256,33 @@ extern boolean_t vnode_pager_isSSD(
        struct vnode *);
 extern void vnode_pager_throttle(
        void);
-extern uint32_t vnode_pager_return_hard_throttle_limit(
+extern uint32_t vnode_pager_return_throttle_io_limit(
        struct vnode *,
-       uint32_t     *,
-       uint32_t);
-extern kern_return_t vnode_pager_get_pathname(
+       uint32_t     *);
+extern kern_return_t vnode_pager_get_name(
        struct vnode    *vp,
        char            *pathname,
-       vm_size_t       *length_p);
-extern kern_return_t vnode_pager_get_filename(
+       vm_size_t       pathname_len,
+       char            *filename,
+       vm_size_t       filename_len,
+       boolean_t       *truncated_path_p);
+struct timespec;
+extern kern_return_t vnode_pager_get_mtime(
        struct vnode    *vp,
-       const char      **filename);
+       struct timespec *mtime,
+       struct timespec *cs_mtime);
 extern kern_return_t vnode_pager_get_cs_blobs(
        struct vnode    *vp,
        void            **blobs);
 
+#if CONFIG_IOSCHED
+void vnode_pager_issue_reprioritize_io(
+       struct vnode    *devvp, 
+       uint64_t        blkno, 
+       uint32_t        len,
+       int             priority);
+#endif
+
 #if CHECK_CS_VALIDATION_BITMAP 
 /* used by the vnode_pager_cs_validation_bitmap routine*/
 #define CS_BITMAP_SET  1
@@ -195,7 +291,7 @@ extern kern_return_t vnode_pager_get_cs_blobs(
 
 #endif /* CHECK_CS_VALIDATION_BITMAP */
 
-extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
+extern void vnode_pager_bootstrap(void);
 extern kern_return_t
 vnode_pager_data_unlock(
        memory_object_t         mem_obj,
@@ -209,26 +305,37 @@ extern kern_return_t vnode_pager_init(
 extern kern_return_t vnode_pager_get_object_size(
        memory_object_t,
        memory_object_offset_t *);
+
+#if CONFIG_IOSCHED
+extern kern_return_t vnode_pager_get_object_devvp(
+        memory_object_t,
+        uintptr_t *);
+#endif
+
+extern void vnode_pager_dirtied(
+       memory_object_t,
+       vm_object_offset_t,
+       vm_object_offset_t);
 extern kern_return_t vnode_pager_get_isinuse(
        memory_object_t,
        uint32_t *);
 extern kern_return_t vnode_pager_get_isSSD(
        memory_object_t,
        boolean_t *);
-extern kern_return_t vnode_pager_check_hard_throttle(
+extern kern_return_t vnode_pager_get_throttle_io_limit(
        memory_object_t,
-       uint32_t *,
-       uint32_t);
-extern kern_return_t vnode_pager_get_object_pathname(
+       uint32_t *);
+extern kern_return_t vnode_pager_get_object_name(
        memory_object_t mem_obj,
        char            *pathname,
-       vm_size_t       *length_p);
-extern kern_return_t vnode_pager_get_object_filename(
-       memory_object_t mem_obj,
-       const char      **filename);
-extern kern_return_t vnode_pager_get_object_cs_blobs(
+       vm_size_t       pathname_len,
+       char            *filename,
+       vm_size_t       filename_len,
+       boolean_t       *truncated_path_p);
+extern kern_return_t vnode_pager_get_object_mtime(
        memory_object_t mem_obj,
-       void            **blobs);
+       struct timespec *mtime,
+       struct timespec *cs_mtime);
 
 #if CHECK_CS_VALIDATION_BITMAP 
 extern kern_return_t vnode_pager_cs_check_validation_bitmap( 
@@ -279,8 +386,9 @@ extern kern_return_t vnode_pager_terminate(
        memory_object_t);
 extern void vnode_pager_vrele(
        struct vnode *vp);
-extern void vnode_pager_release_from_cache(
-       int     *);
+extern struct vnode *vnode_pager_lookup_vnode(
+       memory_object_t);
+
 extern int  ubc_map(
        struct vnode *vp,
        int flags);
@@ -290,83 +398,6 @@ extern void ubc_unmap(
 struct vm_map_entry;
 extern struct vm_object *find_vnode_object(struct vm_map_entry *entry);
 
-extern void   dp_memory_object_reference(memory_object_t);
-extern void   dp_memory_object_deallocate(memory_object_t);
-#ifndef _memory_object_server_
-extern kern_return_t   dp_memory_object_init(memory_object_t,
-                                            memory_object_control_t,
-                                            memory_object_cluster_size_t);
-extern kern_return_t dp_memory_object_terminate(memory_object_t);
-extern kern_return_t   dp_memory_object_data_request(memory_object_t, 
-                                                     memory_object_offset_t,
-                                                     memory_object_cluster_size_t,
-                                                     vm_prot_t,
-                                                     memory_object_fault_info_t);
-extern kern_return_t dp_memory_object_data_return(memory_object_t,
-                                                   memory_object_offset_t,
-                                                   memory_object_cluster_size_t,
-                                                   memory_object_offset_t *,
-                                                   int *,
-                                                   boolean_t,
-                                                   boolean_t,
-                                                   int);
-extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
-                                                     memory_object_offset_t,
-                                                     memory_object_cluster_size_t);
-extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
-                                                 memory_object_offset_t,
-                                                 memory_object_size_t,
-                                                 vm_prot_t);
-extern kern_return_t dp_memory_object_synchronize(memory_object_t,
-                                                 memory_object_offset_t,
-                                                 memory_object_size_t,
-                                                 vm_sync_t);
-extern kern_return_t dp_memory_object_map(memory_object_t,
-                                         vm_prot_t);
-extern kern_return_t dp_memory_object_last_unmap(memory_object_t);
-#endif /* _memory_object_server_ */
-#ifndef _memory_object_default_server_
-extern kern_return_t default_pager_memory_object_create(
-       memory_object_default_t,
-       vm_size_t,
-       memory_object_t *);
-#endif /* _memory_object_default_server_ */
-
-#if CONFIG_FREEZE
-extern unsigned int default_pager_swap_pages_free(void);
-struct default_freezer_handle;
-struct vm_page;
-__private_extern__ void        default_freezer_init(void);
-__private_extern__ struct default_freezer_handle* default_freezer_handle_allocate(void);
-__private_extern__ kern_return_t
-default_freezer_handle_init(
-       struct  default_freezer_handle *df_handle);
-__private_extern__ void
-default_freezer_handle_deallocate(
-       struct default_freezer_handle *df_handle);
-__private_extern__ void
-default_freezer_pageout(
-       struct default_freezer_handle *df_handle);
-__private_extern__ kern_return_t
-default_freezer_pack(
-       unsigned int            *purgeable_count,
-       unsigned int            *wired_count,
-       unsigned int            *clean_count,
-       unsigned int            *dirty_count,
-       unsigned int            dirty_budget,
-       boolean_t               *shared,
-       vm_object_t             src_object,
-       struct default_freezer_handle *df_handle);
-__private_extern__ void
-default_freezer_unpack(
-       struct default_freezer_handle *df_handle);      
-__private_extern__ void
-default_freezer_pack_page(
-       struct vm_page* p,
-       struct default_freezer_handle *df_handle);
-
-#endif /* CONFIG_FREEZE */
-
 extern void   device_pager_reference(memory_object_t);
 extern void   device_pager_deallocate(memory_object_t);
 extern kern_return_t   device_pager_init(memory_object_t,
@@ -409,7 +440,14 @@ extern memory_object_t device_pager_setup(
        uintptr_t,
        vm_size_t,
        int);
-extern void device_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
+extern void device_pager_bootstrap(void);
+extern boolean_t is_device_pager_ops(const struct memory_object_pager_ops *pager_ops);
+
+extern kern_return_t pager_map_to_phys_contiguous(
+       memory_object_control_t object,
+       memory_object_offset_t  offset,
+       addr64_t                base_vaddr,
+       vm_size_t               size);
 
 extern kern_return_t memory_object_create_named(
        memory_object_t pager,
@@ -427,21 +465,55 @@ extern int macx_swapinfo(
        boolean_t               *encrypted_p);
 
 extern void log_stack_execution_failure(addr64_t vaddr, vm_prot_t prot);
-extern void log_unnest_badness(vm_map_t, vm_map_offset_t, vm_map_offset_t);
-
+extern void log_unnest_badness(
+       vm_map_t map,
+       vm_map_offset_t start_unnest,
+       vm_map_offset_t end_unnest,
+       boolean_t is_nested_map,
+       vm_map_offset_t lowest_unnestable_addr);
+
+struct proc;
 extern int cs_allow_invalid(struct proc *p);
-extern int cs_invalid_page(addr64_t vaddr);
-extern boolean_t cs_validate_page(void *blobs,
-                                 memory_object_t pager,
-                                 memory_object_offset_t offset, 
-                                 const void *data,
-                                 boolean_t *tainted);
+extern int cs_invalid_page(addr64_t vaddr, boolean_t *cs_killed);
+
+#define CS_VALIDATE_TAINTED    0x00000001
+#define CS_VALIDATE_NX         0x00000002
+extern boolean_t cs_validate_range(struct vnode *vp,
+                                  memory_object_t pager,
+                                  memory_object_offset_t offset,
+                                  const void *data,
+                                  vm_size_t size,
+                                  unsigned *result);
+#if PMAP_CS
+extern kern_return_t cs_associate_blob_with_mapping(
+       void *pmap,
+       vm_map_offset_t start,
+       vm_map_size_t size,
+       vm_object_offset_t offset,
+       void *blobs_p);
+#endif /* PMAP_CS */
+
+extern kern_return_t memory_entry_purgeable_control_internal(
+       ipc_port_t      entry_port,
+       vm_purgable_t   control,
+       int             *state);
+
+extern kern_return_t memory_entry_access_tracking_internal(
+       ipc_port_t      entry_port,
+       int             *access_tracking,
+       uint32_t        *access_tracking_reads,
+       uint32_t        *access_tracking_writes);
 
 extern kern_return_t mach_memory_entry_purgable_control(
        ipc_port_t      entry_port,
        vm_purgable_t   control,
        int             *state);
 
+extern kern_return_t mach_memory_entry_get_page_counts(
+       ipc_port_t      entry_port,
+       unsigned int    *resident_page_count,
+       unsigned int    *dirty_page_count);
+
 extern kern_return_t mach_memory_entry_page_op(
        ipc_port_t              entry_port,
        vm_object_offset_t      offset,
@@ -467,12 +539,122 @@ extern void vm_paging_map_init(void);
 extern int macx_backing_store_compaction(int flags);
 extern unsigned int mach_vm_ctl_page_free_wanted(void);
 
-extern void no_paging_space_action(void);
+extern int no_paging_space_action(void);
 
 #define VM_TOGGLE_CLEAR                0
 #define VM_TOGGLE_SET          1
 #define VM_TOGGLE_GETVALUE     999
 int vm_toggle_entry_reuse(int, int*);
+
+#define        SWAP_WRITE              0x00000000      /* Write buffer (pseudo flag). */
+#define        SWAP_READ               0x00000001      /* Read buffer. */
+#define        SWAP_ASYNC              0x00000002      /* Start I/O, do not wait. */
+
+extern void vm_compressor_pager_init(void);
+extern kern_return_t compressor_memory_object_create(
+       memory_object_size_t,
+       memory_object_t *);
+
+extern boolean_t vm_compressor_low_on_space(void);
+extern boolean_t vm_compressor_out_of_space(void);
+extern int      vm_swap_low_on_space(void);
+void            do_fastwake_warmup_all(void);
+#if CONFIG_JETSAM
+extern int proc_get_memstat_priority(struct proc*, boolean_t);
+#endif /* CONFIG_JETSAM */
+
+/* the object purger. purges the next eligible object from memory. */
+/* returns TRUE if an object was purged, otherwise FALSE. */
+boolean_t vm_purgeable_object_purge_one_unlocked(int force_purge_below_group);
+void vm_purgeable_disown(task_t task);
+void vm_purgeable_nonvolatile_owner_update(task_t      owner,
+                                          int          delta);
+void vm_purgeable_volatile_owner_update(task_t         owner,
+                                       int             delta);
+
+
+struct trim_list {
+       uint64_t        tl_offset;
+       uint64_t        tl_length;
+       struct trim_list *tl_next;
+};
+
+u_int32_t vnode_trim_list(struct vnode *vp, struct trim_list *tl, boolean_t route_only);
+
+#define MAX_SWAPFILENAME_LEN   1024
+#define SWAPFILENAME_INDEX_LEN 2       /* Doesn't include the terminating NULL character */
+
+extern char    swapfilename[MAX_SWAPFILENAME_LEN + 1];
+
+struct vm_counters {
+       unsigned int    do_collapse_compressor;
+       unsigned int    do_collapse_compressor_pages;
+       unsigned int    do_collapse_terminate;
+       unsigned int    do_collapse_terminate_failure;
+       unsigned int    should_cow_but_wired;
+       unsigned int    create_upl_extra_cow;
+       unsigned int    create_upl_extra_cow_pages;
+       unsigned int    create_upl_lookup_failure_write;
+       unsigned int    create_upl_lookup_failure_copy;
+};
+extern struct vm_counters vm_counters;
+
+#if CONFIG_SECLUDED_MEMORY
+struct vm_page_secluded_data {
+       int     eligible_for_secluded;
+       int     grab_success_free;
+       int     grab_success_other;
+       int     grab_failure_locked;
+       int     grab_failure_state;
+       int     grab_failure_dirty;
+       int     grab_for_iokit;
+       int     grab_for_iokit_success;
+};
+extern struct vm_page_secluded_data vm_page_secluded;
+
+extern int num_tasks_can_use_secluded_mem;
+
+/* boot-args */
+extern int secluded_for_apps;
+extern int secluded_for_iokit;
+extern int secluded_for_filecache;
+#if 11
+extern int secluded_for_fbdp;
+#endif
+
+extern void            memory_object_mark_eligible_for_secluded(
+       memory_object_control_t         control,
+       boolean_t                       eligible_for_secluded);
+
+#endif /* CONFIG_SECLUDED_MEMORY */
+
+#define MAX_PAGE_RANGE_QUERY   (1ULL * 1024 * 1024 * 1024) /* 1 GB */
+
+extern kern_return_t mach_make_memory_entry_internal(
+       vm_map_t                target_map,
+       memory_object_size_t    *size,
+       memory_object_offset_t offset,
+       vm_prot_t               permission,
+       ipc_port_t              *object_handle,
+       ipc_port_t              parent_handle);
+
+#define        roundup(x, y)   ((((x) % (y)) == 0) ? \
+                       (x) : ((x) + ((y) - ((x) % (y)))))
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * Flags for the VM swapper/reclaimer.
+ * Used by vm_swap_consider_defragment()
+ * to force defrag/reclaim by the swap
+ * GC thread.
+ */
+#define VM_SWAP_FLAGS_NONE             0
+#define VM_SWAP_FLAGS_FORCE_DEFRAG     1
+#define VM_SWAP_FLAGS_FORCE_RECLAIM    2
+
 #endif /* _VM_VM_PROTOS_H_ */
 
 #endif /* XNU_KERNEL_PRIVATE */