2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 * File: vm/vm_shared_memory_server.c
25 * Author: Chris Youngworth
27 * Support routines for an in-kernel shared memory allocator
30 #include <ipc/ipc_port.h>
31 #include <kern/thread.h>
32 #include <mach/shared_memory_server.h>
33 #include <kern/zalloc.h>
34 #include <mach/kern_return.h>
35 #include <mach/vm_inherit.h>
36 #include <vm/vm_kern.h>
37 #include <vm/vm_map.h>
38 #include <vm/vm_page.h>
41 vm_offset_t shared_file_text_region
;
42 vm_offset_t shared_file_data_region
;
44 ipc_port_t shared_text_region_handle
;
45 ipc_port_t shared_data_region_handle
;
46 vm_offset_t shared_file_mapping_array
= 0;
47 shared_region_mapping_t system_shared_region
;
49 ipc_port_t sfma_handle
= NULL
;
52 int shared_file_available_hash_ele
;
55 shared_file_create_system_region(
56 shared_region_mapping_t
*shared_region
)
58 ipc_port_t text_handle
;
59 ipc_port_t data_handle
;
62 vm_offset_t mapping_array
;
65 text_size
= 0x10000000;
66 data_size
= 0x10000000;
68 kret
= shared_file_init(&text_handle
,
69 text_size
, &data_handle
, data_size
, &mapping_array
);
72 kret
= shared_region_mapping_create(text_handle
,
73 text_size
, data_handle
, data_size
, mapping_array
,
74 GLOBAL_SHARED_TEXT_SEGMENT
, shared_region
,
75 0x9000000, 0x9000000);
78 (*shared_region
)->flags
= 0;
82 shared_file_boot_time_init(
85 long shared_text_region_size
;
86 long shared_data_region_size
;
88 shared_text_region_size
= 0x10000000;
89 shared_data_region_size
= 0x10000000;
90 shared_file_init(&shared_text_region_handle
,
91 shared_text_region_size
, &shared_data_region_handle
,
92 shared_data_region_size
, &shared_file_mapping_array
);
93 shared_region_mapping_create(shared_text_region_handle
,
94 shared_text_region_size
, shared_data_region_handle
,
95 shared_data_region_size
, shared_file_mapping_array
,
96 GLOBAL_SHARED_TEXT_SEGMENT
, &system_shared_region
,
97 0x9000000, 0x9000000);
98 system_shared_region
->flags
= SHARED_REGION_SYSTEM
;
99 vm_set_shared_region(current_task(), system_shared_region
);
104 /* called at boot time, allocates two regions, each 256 megs in size */
105 /* these regions are later mapped into task spaces, allowing them to */
106 /* share the contents of the regions. shared_file_init is part of */
107 /* a shared_memory_server which not only allocates the backing maps */
108 /* but also coordinates requests for space. */
113 ipc_port_t
*shared_text_region_handle
,
114 vm_size_t text_region_size
,
115 ipc_port_t
*shared_data_region_handle
,
116 vm_size_t data_region_size
,
117 vm_offset_t
*mapping_array
)
119 vm_offset_t aligned_address
;
120 shared_file_info_t
*sf_head
;
121 vm_offset_t table_mapping_address
;
127 vm_object_t buf_object
;
128 vm_map_entry_t entry
;
133 /* create text and data maps/regions */
134 if(kret
= vm_region_object_create(kernel_map
,
136 shared_text_region_handle
)) {
140 if(kret
= vm_region_object_create(kernel_map
,
142 shared_data_region_handle
)) {
143 ipc_port_release_send(*shared_text_region_handle
);
147 data_table_size
= data_region_size
>> 9;
148 hash_size
= data_region_size
>> 14;
149 table_mapping_address
= data_region_size
- data_table_size
;
151 if(shared_file_mapping_array
== 0) {
152 buf_object
= vm_object_allocate(data_table_size
);
154 if(vm_map_find_space(kernel_map
, &shared_file_mapping_array
,
155 data_table_size
, 0, &entry
) != KERN_SUCCESS
) {
156 panic("shared_file_init: no space");
158 *mapping_array
= shared_file_mapping_array
;
159 vm_map_unlock(kernel_map
);
160 entry
->object
.vm_object
= buf_object
;
163 for (b
= *mapping_array
, alloced
= 0;
164 alloced
< (hash_size
+
165 round_page(sizeof(struct sf_mapping
)));
166 alloced
+= PAGE_SIZE
, b
+= PAGE_SIZE
) {
167 vm_object_lock(buf_object
);
168 p
= vm_page_alloc(buf_object
, alloced
);
169 if (p
== VM_PAGE_NULL
) {
170 panic("shared_file_init: no space");
173 vm_object_unlock(buf_object
);
174 pmap_enter(kernel_pmap
, b
, p
->phys_addr
,
175 VM_PROT_READ
| VM_PROT_WRITE
, TRUE
);
179 /* initialize loaded file array */
180 sf_head
= (shared_file_info_t
*)*mapping_array
;
181 sf_head
->hash
= (queue_head_t
*)
182 (((int)*mapping_array
) +
183 sizeof(struct shared_file_info
));
184 sf_head
->hash_size
= hash_size
/sizeof(queue_head_t
);
185 mutex_init(&(sf_head
->lock
), (ETAP_VM_MAP
));
186 sf_head
->hash_init
= FALSE
;
189 mach_make_memory_entry(kernel_map
, &data_table_size
,
190 *mapping_array
, VM_PROT_READ
, &sfma_handle
,
193 if (vm_map_wire(kernel_map
, *mapping_array
,
195 (hash_size
+ round_page(sizeof(struct sf_mapping
))),
196 VM_PROT_DEFAULT
, FALSE
) != KERN_SUCCESS
) {
197 panic("shared_file_init: No memory for data table");
200 lsf_zone
= zinit(sizeof(struct load_file_ele
),
202 (hash_size
+ round_page(sizeof(struct sf_mapping
))),
203 0, "load_file_server");
205 zone_change(lsf_zone
, Z_EXHAUST
, TRUE
);
206 zone_change(lsf_zone
, Z_COLLECT
, FALSE
);
207 zone_change(lsf_zone
, Z_EXPAND
, FALSE
);
208 zone_change(lsf_zone
, Z_FOREIGN
, TRUE
);
210 *mapping_array
= shared_file_mapping_array
;
213 vm_map(((vm_named_entry_t
)
214 (*shared_data_region_handle
)->ip_kobject
)->backing
.map
,
215 &table_mapping_address
,
216 data_table_size
, 0, SHARED_LIB_ALIAS
,
217 sfma_handle
, 0, FALSE
,
218 VM_PROT_READ
, VM_PROT_READ
, VM_INHERIT_NONE
);
222 /* A call made from user space, copyin_shared_file requires the user to */
223 /* provide the address and size of a mapped file, the full path name of */
224 /* that file and a list of offsets to be mapped into shared memory. */
225 /* By requiring that the file be pre-mapped, copyin_shared_file can */
226 /* guarantee that the file is neither deleted nor changed after the user */
227 /* begins the call. */
231 vm_offset_t mapped_file
,
232 vm_size_t mapped_file_size
,
233 vm_offset_t
*base_address
,
235 sf_mapping_t
*mappings
,
236 vm_object_t file_object
,
237 shared_region_task_mappings_t sm_info
,
240 vm_map_entry_t entry
;
241 shared_file_info_t
*shared_file_header
;
242 load_struct_t
*file_entry
;
243 loaded_mapping_t
*file_mapping
;
248 /* wire hash entry pool only as needed, since we are the only */
249 /* users, we take a few liberties with the population of our */
251 static int allocable_hash_pages
;
252 static vm_offset_t hash_cram_address
;
255 shared_file_header
= (shared_file_info_t
*)sm_info
->region_mappings
;
257 mutex_lock(&shared_file_header
->lock
);
259 /* If this is the first call to this routine, take the opportunity */
260 /* to initialize the hash table which will be used to look-up */
261 /* mappings based on the file object */
263 if(shared_file_header
->hash_init
== FALSE
) {
264 vm_size_t hash_table_size
;
265 vm_size_t hash_table_offset
;
267 hash_table_size
= (shared_file_header
->hash_size
)
268 * sizeof(struct queue_entry
);
269 hash_table_offset
= hash_table_size
+
270 round_page(sizeof(struct sf_mapping
));
271 for (i
= 0; i
< shared_file_header
->hash_size
; i
++)
272 queue_init(&shared_file_header
->hash
[i
]);
274 allocable_hash_pages
=
275 ((hash_table_size
<<5) - hash_table_offset
)/PAGE_SIZE
;
277 sm_info
->region_mappings
+ hash_table_offset
;
278 shared_file_available_hash_ele
= 0;
280 shared_file_header
->hash_init
= TRUE
;
283 if ((shared_file_available_hash_ele
< 20) && (allocable_hash_pages
)) {
286 cram_size
= allocable_hash_pages
> 3 ?
287 3 : allocable_hash_pages
;
288 allocable_hash_pages
-= cram_size
;
289 cram_size
= cram_size
* PAGE_SIZE
;
290 if (vm_map_wire(kernel_map
, hash_cram_address
,
291 hash_cram_address
+cram_size
,
292 VM_PROT_DEFAULT
, FALSE
) != KERN_SUCCESS
) {
293 panic("shared_file_init: No memory for data table");
295 zcram(lsf_zone
, hash_cram_address
, cram_size
);
296 shared_file_available_hash_ele
297 += cram_size
/sizeof(struct load_file_ele
);
298 hash_cram_address
+= cram_size
;
302 /* Find the entry in the map associated with the current mapping */
303 /* of the file object */
305 if(vm_map_lookup_entry(current_map(), mapped_file
, &entry
)) {
306 vm_object_t mapped_object
;
307 if(entry
->is_sub_map
) {
308 mutex_unlock(&shared_file_header
->lock
);
309 return KERN_INVALID_ADDRESS
;
311 mapped_object
= entry
->object
.vm_object
;
312 while(mapped_object
->shadow
!= NULL
) {
313 mapped_object
= mapped_object
->shadow
;
315 /* check to see that the file object passed is indeed the */
316 /* same as the mapped object passed */
317 if(file_object
!= mapped_object
) {
318 if(sm_info
->flags
& SHARED_REGION_SYSTEM
) {
319 mutex_unlock(&shared_file_header
->lock
);
320 return KERN_PROTECTION_FAILURE
;
322 file_object
= mapped_object
;
326 mutex_unlock(&shared_file_header
->lock
);
327 return KERN_INVALID_ADDRESS
;
330 alternate
= (*flags
& ALTERNATE_LOAD_SITE
) ? TRUE
: FALSE
;
332 if (file_entry
= lsf_hash_lookup(shared_file_header
->hash
,
333 (void *) file_object
, shared_file_header
->hash_size
,
334 alternate
, sm_info
)) {
335 /* File is loaded, check the load manifest for exact match */
336 /* we simplify by requiring that the elements be the same */
337 /* size and in the same order rather than checking for */
338 /* semantic equivalence. */
340 /* If the file is being loaded in the alternate */
341 /* area, one load to alternate is allowed per mapped */
342 /* object the base address is passed back to the */
343 /* caller and the mappings field is filled in. If the */
344 /* caller does not pass the precise mappings_cnt */
345 /* and the Alternate is already loaded, an error */
348 file_mapping
= file_entry
->mappings
;
349 while(file_mapping
!= NULL
) {
351 mutex_unlock(&shared_file_header
->lock
);
352 return KERN_INVALID_ARGUMENT
;
354 if(((mappings
[i
].mapping_offset
)
355 & SHARED_DATA_REGION_MASK
) !=
356 file_mapping
->mapping_offset
||
358 file_mapping
->size
||
359 mappings
[i
].file_offset
!=
360 file_mapping
->file_offset
||
361 mappings
[i
].protection
!=
362 file_mapping
->protection
) {
365 file_mapping
= file_mapping
->next
;
369 mutex_unlock(&shared_file_header
->lock
);
370 return KERN_INVALID_ARGUMENT
;
372 *base_address
= (*base_address
& ~SHARED_TEXT_REGION_MASK
)
373 + file_entry
->base_address
;
374 *flags
= SF_PREV_LOADED
;
375 mutex_unlock(&shared_file_header
->lock
);
378 /* File is not loaded, lets attempt to load it */
379 ret
= lsf_load(mapped_file
, mapped_file_size
, base_address
,
384 if(ret
== KERN_NO_SPACE
) {
385 shared_region_mapping_t regions
;
386 regions
= (shared_region_mapping_t
)sm_info
->self
;
387 regions
->flags
|= SHARED_REGION_FULL
;
388 if(regions
== system_shared_region
) {
389 shared_file_boot_time_init();
390 /* current task must stay wit its current */
392 vm_set_shared_region(current_task(), regions
);
395 mutex_unlock(&shared_file_header
->lock
);
400 /* A hash lookup function for the list of loaded files in */
401 /* shared_memory_server space. */
405 queue_head_t
*hash_table
,
409 shared_region_task_mappings_t sm_info
)
411 register queue_t bucket
;
412 load_struct_t
*entry
;
413 shared_region_mapping_t target_region
;
416 bucket
= &(hash_table
[load_file_hash((int)file_object
, size
)]);
417 for (entry
= (load_struct_t
*)queue_first(bucket
);
418 !queue_end(bucket
, &entry
->links
);
419 entry
= (load_struct_t
*)queue_next(&entry
->links
)) {
420 if (entry
->file_object
== (int)file_object
) {
421 target_region
= (shared_region_mapping_t
)sm_info
->self
;
422 depth
= target_region
->depth
;
423 while(target_region
) {
424 if((!(sm_info
->self
)) ||
425 ((target_region
== entry
->regions_instance
) &&
426 (target_region
->depth
>= entry
->depth
))) {
428 if (entry
->base_address
>=
429 sm_info
->alternate_base
)
432 if (entry
->base_address
<
433 sm_info
->alternate_base
)
437 if(target_region
->object_chain
) {
438 target_region
= (shared_region_mapping_t
)
439 target_region
->object_chain
->object_chain_region
;
440 depth
= target_region
->object_chain
->depth
;
442 target_region
= NULL
;
448 return (load_struct_t
*)0;
452 lsf_remove_regions_mappings(
453 shared_region_mapping_t region
,
454 shared_region_task_mappings_t sm_info
)
457 register queue_t bucket
;
458 shared_file_info_t
*shared_file_header
;
459 load_struct_t
*entry
;
460 load_struct_t
*next_entry
;
461 load_struct_t
*prev_entry
;
463 shared_file_header
= (shared_file_info_t
*)sm_info
->region_mappings
;
465 mutex_lock(&shared_file_header
->lock
);
466 if(shared_file_header
->hash_init
== FALSE
) {
467 mutex_unlock(&shared_file_header
->lock
);
470 for(i
= 0; i
<shared_file_header
->hash_size
; i
++) {
471 bucket
= &shared_file_header
->hash
[i
];
472 for (entry
= (load_struct_t
*)queue_first(bucket
);
473 !queue_end(bucket
, &entry
->links
);) {
474 next_entry
= (load_struct_t
*)queue_next(&entry
->links
);
475 if(region
== entry
->regions_instance
) {
476 lsf_unload((void *)entry
->file_object
,
477 entry
->base_address
, sm_info
);
482 mutex_unlock(&shared_file_header
->lock
);
485 /* Removes a map_list, (list of loaded extents) for a file from */
486 /* the loaded file hash table. */
491 vm_offset_t base_offset
,
492 shared_region_task_mappings_t sm_info
)
494 register queue_t bucket
;
495 shared_file_info_t
*shared_file_header
;
496 load_struct_t
*entry
;
497 load_struct_t
*prev_entry
;
499 shared_file_header
= (shared_file_info_t
*)sm_info
->region_mappings
;
501 bucket
= &shared_file_header
->hash
502 [load_file_hash((int)file_object
, shared_file_header
->hash_size
)];
504 for (entry
= (load_struct_t
*)queue_first(bucket
);
505 !queue_end(bucket
, &entry
->links
);
506 entry
= (load_struct_t
*)queue_next(&entry
->links
)) {
507 if((!(sm_info
->self
)) || ((shared_region_mapping_t
)
508 sm_info
->self
== entry
->regions_instance
)) {
509 if ((entry
->file_object
== (int) file_object
) &&
510 (entry
->base_address
== base_offset
)) {
511 queue_remove(bucket
, entry
,
512 load_struct_ptr_t
, links
);
518 return (load_struct_t
*)0;
521 /* Inserts a new map_list, (list of loaded file extents), into the */
522 /* server loaded file hash table. */
526 load_struct_t
*entry
,
527 shared_region_task_mappings_t sm_info
)
529 shared_file_info_t
*shared_file_header
;
531 shared_file_header
= (shared_file_info_t
*)sm_info
->region_mappings
;
532 queue_enter(&shared_file_header
->hash
533 [load_file_hash(entry
->file_object
,
534 shared_file_header
->hash_size
)],
535 entry
, load_struct_ptr_t
, links
);
538 /* Looks up the file type requested. If already loaded and the */
539 /* file extents are an exact match, returns Success. If not */
540 /* loaded attempts to load the file extents at the given offsets */
541 /* if any extent fails to load or if the file was already loaded */
542 /* in a different configuration, lsf_load fails. */
546 vm_offset_t mapped_file
,
547 vm_size_t mapped_file_size
,
548 vm_offset_t
*base_address
,
549 sf_mapping_t
*mappings
,
553 shared_region_task_mappings_t sm_info
)
556 load_struct_t
*entry
;
557 vm_map_copy_t copy_object
;
558 loaded_mapping_t
*file_mapping
;
559 loaded_mapping_t
**tptr
;
561 ipc_port_t local_map
;
562 vm_offset_t original_alt_load_next
;
563 vm_offset_t alternate_load_next
;
565 entry
= (load_struct_t
*)zalloc(lsf_zone
);
566 shared_file_available_hash_ele
--;
567 entry
->file_object
= (int)file_object
;
568 entry
->mapping_cnt
= map_cnt
;
569 entry
->mappings
= NULL
;
570 entry
->links
.prev
= (queue_entry_t
) 0;
571 entry
->links
.next
= (queue_entry_t
) 0;
572 entry
->regions_instance
= (shared_region_mapping_t
)sm_info
->self
;
573 entry
->depth
=((shared_region_mapping_t
)sm_info
->self
)->depth
;
575 lsf_hash_insert(entry
, sm_info
);
576 tptr
= &(entry
->mappings
);
579 alternate_load_next
= sm_info
->alternate_next
;
580 original_alt_load_next
= alternate_load_next
;
581 if (flags
& ALTERNATE_LOAD_SITE
) {
582 int max_loadfile_offset
;
584 *base_address
= ((*base_address
) & ~SHARED_TEXT_REGION_MASK
) +
585 sm_info
->alternate_next
;
586 max_loadfile_offset
= 0;
587 for(i
= 0; i
<map_cnt
; i
++) {
588 if(((mappings
[i
].mapping_offset
589 & SHARED_TEXT_REGION_MASK
)+ mappings
[i
].size
) >
590 max_loadfile_offset
) {
591 max_loadfile_offset
=
592 (mappings
[i
].mapping_offset
593 & SHARED_TEXT_REGION_MASK
)
597 if((alternate_load_next
+ round_page(max_loadfile_offset
)) >=
598 (sm_info
->data_size
- (sm_info
->data_size
>>9))) {
600 return KERN_NO_SPACE
;
602 alternate_load_next
+= round_page(max_loadfile_offset
);
605 if (((*base_address
) & SHARED_TEXT_REGION_MASK
) >
606 sm_info
->alternate_base
) {
607 entry
->base_address
=
608 (*base_address
) & SHARED_TEXT_REGION_MASK
;
609 lsf_unload(file_object
, entry
->base_address
, sm_info
);
610 return KERN_INVALID_ARGUMENT
;
614 entry
->base_address
= (*base_address
) & SHARED_TEXT_REGION_MASK
;
616 /* copyin mapped file data */
617 for(i
= 0; i
<map_cnt
; i
++) {
618 vm_offset_t target_address
;
619 vm_offset_t region_mask
;
621 if(mappings
[i
].protection
& VM_PROT_COW
) {
622 local_map
= (ipc_port_t
)sm_info
->data_region
;
623 region_mask
= SHARED_DATA_REGION_MASK
;
624 if((mappings
[i
].mapping_offset
625 & GLOBAL_SHARED_SEGMENT_MASK
) != 0x10000000) {
626 lsf_unload(file_object
,
627 entry
->base_address
, sm_info
);
628 return KERN_INVALID_ARGUMENT
;
631 region_mask
= SHARED_TEXT_REGION_MASK
;
632 local_map
= (ipc_port_t
)sm_info
->text_region
;
633 if(mappings
[i
].mapping_offset
634 & GLOBAL_SHARED_SEGMENT_MASK
) {
635 lsf_unload(file_object
,
636 entry
->base_address
, sm_info
);
637 return KERN_INVALID_ARGUMENT
;
640 if(!(mappings
[i
].protection
& VM_PROT_ZF
)
641 && ((mapped_file
+ mappings
[i
].file_offset
+
643 (mapped_file
+ mapped_file_size
))) {
644 lsf_unload(file_object
, entry
->base_address
, sm_info
);
645 return KERN_INVALID_ARGUMENT
;
647 target_address
= ((mappings
[i
].mapping_offset
) & region_mask
)
648 + entry
->base_address
;
649 if(vm_allocate(((vm_named_entry_t
)local_map
->ip_kobject
)
650 ->backing
.map
, &target_address
,
651 mappings
[i
].size
, FALSE
)) {
652 lsf_unload(file_object
, entry
->base_address
, sm_info
);
655 target_address
= ((mappings
[i
].mapping_offset
) & region_mask
)
656 + entry
->base_address
;
657 if(!(mappings
[i
].protection
& VM_PROT_ZF
)) {
658 if(vm_map_copyin(current_map(),
659 mapped_file
+ mappings
[i
].file_offset
,
660 round_page(mappings
[i
].size
), FALSE
, ©_object
)) {
661 vm_deallocate(((vm_named_entry_t
)local_map
->ip_kobject
)
662 ->backing
.map
, target_address
, mappings
[i
].size
);
663 lsf_unload(file_object
, entry
->base_address
, sm_info
);
666 if(vm_map_copy_overwrite(((vm_named_entry_t
)
667 local_map
->ip_kobject
)->backing
.map
, target_address
,
668 copy_object
, FALSE
)) {
669 vm_deallocate(((vm_named_entry_t
)local_map
->ip_kobject
)
670 ->backing
.map
, target_address
, mappings
[i
].size
);
671 lsf_unload(file_object
, entry
->base_address
, sm_info
);
675 vm_map_protect(((vm_named_entry_t
)local_map
->ip_kobject
)
676 ->backing
.map
, target_address
,
677 round_page(target_address
+ mappings
[i
].size
),
678 (mappings
[i
].protection
&
679 (VM_PROT_READ
| VM_PROT_EXECUTE
)),
681 vm_map_protect(((vm_named_entry_t
)local_map
->ip_kobject
)
682 ->backing
.map
, target_address
,
683 round_page(target_address
+ mappings
[i
].size
),
684 (mappings
[i
].protection
&
685 (VM_PROT_READ
| VM_PROT_EXECUTE
)),
687 file_mapping
= (loaded_mapping_t
*)zalloc(lsf_zone
);
688 if(file_mapping
== 0)
689 panic("lsf_load: OUT OF MAPPINGS!");
690 shared_file_available_hash_ele
--;
691 file_mapping
->mapping_offset
= (mappings
[i
].mapping_offset
)
693 file_mapping
->size
= mappings
[i
].size
;
694 file_mapping
->file_offset
= mappings
[i
].file_offset
;
695 file_mapping
->protection
= mappings
[i
].protection
;
696 file_mapping
->next
= NULL
;
697 *tptr
= file_mapping
;
698 tptr
= &(file_mapping
->next
);
700 shared_region_mapping_set_alt_next(sm_info
->self
, alternate_load_next
);
706 /* finds the file_object extent list in the shared memory hash table */
707 /* If one is found the associated extents in shared memory are deallocated */
708 /* and the extent list is freed */
713 vm_offset_t base_offset
,
714 shared_region_task_mappings_t sm_info
)
716 load_struct_t
*entry
;
717 ipc_port_t local_map
;
718 loaded_mapping_t
*map_ele
;
719 loaded_mapping_t
*back_ptr
;
721 entry
= lsf_hash_delete(file_object
, base_offset
, sm_info
);
723 map_ele
= entry
->mappings
;
724 while(map_ele
!= NULL
) {
725 if(map_ele
->protection
& VM_PROT_COW
) {
726 local_map
= (ipc_port_t
)sm_info
->data_region
;
728 local_map
= (ipc_port_t
)sm_info
->text_region
;
730 vm_deallocate(((vm_named_entry_t
)local_map
->ip_kobject
)
731 ->backing
.map
, entry
->base_address
+
732 map_ele
->mapping_offset
,
735 map_ele
= map_ele
->next
;
736 zfree(lsf_zone
, (vm_offset_t
)back_ptr
);
737 shared_file_available_hash_ele
++;
739 zfree(lsf_zone
, (vm_offset_t
)entry
);
740 shared_file_available_hash_ele
++;