master
1/*
2 * Copyright (c) 2000-2016 Apple Computer, 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 * @OSF_COPYRIGHT@
30 */
31/*
32 * File: mach/vm_region.h
33 *
34 * Define the attributes of a task's memory region
35 *
36 */
37
38#ifndef _MACH_VM_REGION_H_
39#define _MACH_VM_REGION_H_
40
41#include <mach/boolean.h>
42#include <mach/vm_prot.h>
43#include <mach/vm_inherit.h>
44#include <mach/vm_behavior.h>
45#include <mach/vm_types.h>
46#include <mach/message.h>
47#include <mach/machine/vm_param.h>
48#include <mach/machine/vm_types.h>
49#include <mach/memory_object_types.h>
50
51#include <sys/cdefs.h>
52
53#pragma pack(push, 4)
54
55// LP64todo: all the current tools are 32bit, obviously never worked for 64b
56// so probably should be a real 32b ID vs. ptr.
57// Current users just check for equality
58typedef uint32_t vm32_object_id_t;
59
60/*
61 * Types defined:
62 *
63 * vm_region_info_t memory region attributes
64 */
65
66#define VM_REGION_INFO_MAX (1024)
67typedef int *vm_region_info_t;
68typedef int *vm_region_info_64_t;
69typedef int *vm_region_recurse_info_t;
70typedef int *vm_region_recurse_info_64_t;
71typedef int vm_region_flavor_t;
72typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
73
74
75#define VM_REGION_BASIC_INFO_64 9
76struct vm_region_basic_info_64 {
77 vm_prot_t protection;
78 vm_prot_t max_protection;
79 vm_inherit_t inheritance;
80 boolean_t shared;
81 boolean_t reserved;
82 memory_object_offset_t offset;
83 vm_behavior_t behavior;
84 unsigned short user_wired_count;
85};
86typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
87typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
88
89#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
90 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
91
92/*
93 * Passing VM_REGION_BASIC_INFO to vm_region_64
94 * automatically converts it to a VM_REGION_BASIC_INFO_64.
95 * Please use that explicitly instead.
96 */
97#define VM_REGION_BASIC_INFO 10
98
99/*
100 * This is the legacy basic info structure. It is
101 * deprecated because it passes only a 32-bit memory object
102 * offset back - too small for many larger objects (e.g. files).
103 */
104struct vm_region_basic_info {
105 vm_prot_t protection;
106 vm_prot_t max_protection;
107 vm_inherit_t inheritance;
108 boolean_t shared;
109 boolean_t reserved;
110 uint32_t offset; /* too small for a real offset */
111 vm_behavior_t behavior;
112 unsigned short user_wired_count;
113};
114
115typedef struct vm_region_basic_info *vm_region_basic_info_t;
116typedef struct vm_region_basic_info vm_region_basic_info_data_t;
117
118#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
119 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
120
121#define SM_COW 1
122#define SM_PRIVATE 2
123#define SM_EMPTY 3
124#define SM_SHARED 4
125#define SM_TRUESHARED 5
126#define SM_PRIVATE_ALIASED 6
127#define SM_SHARED_ALIASED 7
128#define SM_LARGE_PAGE 8
129
130/*
131 * For submap info, the SM flags above are overlayed when a submap
132 * is encountered. The field denotes whether or not machine level mapping
133 * information is being shared. PTE's etc. When such sharing is taking
134 * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
135 * back.
136 */
137
138
139
140
141#define VM_REGION_EXTENDED_INFO 13
142struct vm_region_extended_info {
143 vm_prot_t protection;
144 unsigned int user_tag;
145 unsigned int pages_resident;
146 unsigned int pages_shared_now_private;
147 unsigned int pages_swapped_out;
148 unsigned int pages_dirtied;
149 unsigned int ref_count;
150 unsigned short shadow_depth;
151 unsigned char external_pager;
152 unsigned char share_mode;
153 unsigned int pages_reusable;
154};
155typedef struct vm_region_extended_info *vm_region_extended_info_t;
156typedef struct vm_region_extended_info vm_region_extended_info_data_t;
157#define VM_REGION_EXTENDED_INFO_COUNT \
158 ((mach_msg_type_number_t) \
159 (sizeof (vm_region_extended_info_data_t) / sizeof (natural_t)))
160
161
162
163
164#define VM_REGION_TOP_INFO 12
165
166struct vm_region_top_info {
167 unsigned int obj_id;
168 unsigned int ref_count;
169 unsigned int private_pages_resident;
170 unsigned int shared_pages_resident;
171 unsigned char share_mode;
172};
173
174typedef struct vm_region_top_info *vm_region_top_info_t;
175typedef struct vm_region_top_info vm_region_top_info_data_t;
176
177#define VM_REGION_TOP_INFO_COUNT \
178 ((mach_msg_type_number_t) \
179 (sizeof(vm_region_top_info_data_t) / sizeof(natural_t)))
180
181
182
183/*
184 * vm_region_submap_info will return information on a submap or object.
185 * The user supplies a nesting level on the call. When a walk of the
186 * user's map is done and a submap is encountered, the nesting count is
187 * checked. If the nesting count is greater than 1 the submap is entered and
188 * the offset relative to the address in the base map is examined. If the
189 * nesting count is zero, the information on the submap is returned.
190 * The caller may thus learn about a submap and its contents by judicious
191 * choice of the base map address and nesting count. The nesting count
192 * allows penetration of recursively mapped submaps. If a submap is
193 * encountered as a mapped entry of another submap, the caller may bump
194 * the nesting count and call vm_region_recurse again on the target address
195 * range. The "is_submap" field tells the caller whether or not a submap
196 * has been encountered.
197 *
198 * Object only fields are filled in through a walking of the object shadow
199 * chain (where one is present), and a walking of the resident page queue.
200 *
201 */
202
203struct vm_region_submap_info {
204 vm_prot_t protection; /* present access protection */
205 vm_prot_t max_protection; /* max avail through vm_prot */
206 vm_inherit_t inheritance;/* behavior of map/obj on fork */
207 uint32_t offset; /* offset into object/map */
208 unsigned int user_tag; /* user tag on map entry */
209 unsigned int pages_resident; /* only valid for objects */
210 unsigned int pages_shared_now_private; /* only for objects */
211 unsigned int pages_swapped_out; /* only for objects */
212 unsigned int pages_dirtied; /* only for objects */
213 unsigned int ref_count; /* obj/map mappers, etc */
214 unsigned short shadow_depth; /* only for obj */
215 unsigned char external_pager; /* only for obj */
216 unsigned char share_mode; /* see enumeration */
217 boolean_t is_submap; /* submap vs obj */
218 vm_behavior_t behavior; /* access behavior hint */
219 vm32_object_id_t object_id; /* obj/map name, not a handle */
220 unsigned short user_wired_count;
221};
222
223typedef struct vm_region_submap_info *vm_region_submap_info_t;
224typedef struct vm_region_submap_info vm_region_submap_info_data_t;
225
226#define VM_REGION_SUBMAP_INFO_COUNT \
227 ((mach_msg_type_number_t) \
228 (sizeof(vm_region_submap_info_data_t) / sizeof(natural_t)))
229
230struct vm_region_submap_info_64 {
231 /* v0 fields */
232 vm_prot_t protection; /* present access protection */
233 vm_prot_t max_protection; /* max avail through vm_prot */
234 vm_inherit_t inheritance;/* behavior of map/obj on fork */
235 memory_object_offset_t offset; /* offset into object/map */
236 unsigned int user_tag; /* user tag on map entry */
237 unsigned int pages_resident; /* only valid for objects */
238 unsigned int pages_shared_now_private; /* only for objects */
239 unsigned int pages_swapped_out; /* only for objects */
240 unsigned int pages_dirtied; /* only for objects */
241 unsigned int ref_count; /* obj/map mappers, etc */
242 unsigned short shadow_depth; /* only for obj */
243 unsigned char external_pager; /* only for obj */
244 unsigned char share_mode; /* see enumeration */
245 boolean_t is_submap; /* submap vs obj */
246 vm_behavior_t behavior; /* access behavior hint */
247 vm32_object_id_t object_id; /* obj/map name, not a handle */
248 unsigned short user_wired_count;
249 unsigned short flags;
250 /* v1 fields */
251 unsigned int pages_reusable;
252 /* v2 fields */
253 vm_object_id_t object_id_full;
254};
255
256typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
257typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
258
259/*
260 * Note that this size is hard-coded at the MIG boundary in mach_types.defs
261 * so if we ever increase this you'll need to also bump the definition of
262 * vm_region_recurse_info_t.
263 */
264#define VM_REGION_SUBMAP_INFO_V2_SIZE \
265 (sizeof (vm_region_submap_info_data_64_t))
266
267/* v1 size is v2 size minus v2's new fields */
268#define VM_REGION_SUBMAP_INFO_V1_SIZE \
269 (VM_REGION_SUBMAP_INFO_V2_SIZE - \
270 sizeof (vm_object_id_t) /* object_id_full */ )
271
272/* v0 size is v1 size minus v1's new fields */
273#define VM_REGION_SUBMAP_INFO_V0_SIZE \
274 (VM_REGION_SUBMAP_INFO_V1_SIZE - \
275 sizeof (unsigned int) /* pages_reusable */ )
276
277#define VM_REGION_SUBMAP_INFO_V2_COUNT_64 \
278 ((mach_msg_type_number_t) \
279 (VM_REGION_SUBMAP_INFO_V2_SIZE / sizeof (natural_t)))
280#define VM_REGION_SUBMAP_INFO_V1_COUNT_64 \
281 ((mach_msg_type_number_t) \
282 (VM_REGION_SUBMAP_INFO_V1_SIZE / sizeof (natural_t)))
283#define VM_REGION_SUBMAP_INFO_V0_COUNT_64 \
284 ((mach_msg_type_number_t) \
285 (VM_REGION_SUBMAP_INFO_V0_SIZE / sizeof (natural_t)))
286
287/* set this to the latest version */
288#define VM_REGION_SUBMAP_INFO_COUNT_64 VM_REGION_SUBMAP_INFO_V2_COUNT_64
289
290#define VM_REGION_FLAG_JIT_ENABLED 0x1
291#define VM_REGION_FLAG_TPRO_ENABLED 0x2
292
293
294struct vm_region_submap_short_info_64 {
295 vm_prot_t protection; /* present access protection */
296 vm_prot_t max_protection; /* max avail through vm_prot */
297 vm_inherit_t inheritance;/* behavior of map/obj on fork */
298 memory_object_offset_t offset; /* offset into object/map */
299 unsigned int user_tag; /* user tag on map entry */
300 unsigned int ref_count; /* obj/map mappers, etc */
301 unsigned short shadow_depth; /* only for obj */
302 unsigned char external_pager; /* only for obj */
303 unsigned char share_mode; /* see enumeration */
304 boolean_t is_submap; /* submap vs obj */
305 vm_behavior_t behavior; /* access behavior hint */
306 vm32_object_id_t object_id; /* obj/map name, not a handle */
307 unsigned short user_wired_count;
308 unsigned short flags;
309};
310
311typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t;
312typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t;
313
314#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 \
315 ((mach_msg_type_number_t) \
316 (sizeof (vm_region_submap_short_info_data_64_t) / sizeof (natural_t)))
317
318struct mach_vm_read_entry {
319 mach_vm_address_t address;
320 mach_vm_size_t size;
321};
322
323struct vm_read_entry {
324 vm_address_t address;
325 vm_size_t size;
326};
327
328#ifdef VM32_SUPPORT
329struct vm32_read_entry {
330 vm32_address_t address;
331 vm32_size_t size;
332};
333#endif
334
335
336#define VM_MAP_ENTRY_MAX (256)
337
338typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
339typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
340#ifdef VM32_SUPPORT
341typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX];
342#endif
343
344#pragma pack(pop)
345
346
347#define VM_PAGE_INFO_MAX
348typedef int *vm_page_info_t;
349typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX];
350typedef int vm_page_info_flavor_t;
351
352#define VM_PAGE_INFO_BASIC 1
353struct vm_page_info_basic {
354 int disposition;
355 int ref_count;
356 vm_object_id_t object_id;
357 memory_object_offset_t offset;
358 int depth;
359 int __pad; /* pad to 64-bit boundary */
360};
361typedef struct vm_page_info_basic *vm_page_info_basic_t;
362typedef struct vm_page_info_basic vm_page_info_basic_data_t;
363
364#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \
365 (sizeof(vm_page_info_basic_data_t)/sizeof(int)))
366
367
368#endif /*_MACH_VM_REGION_H_*/