Deleted Added
full compact
vm_map.c (117724) vm_map.c (118771)
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 53 unchanged lines hidden (view full) ---

62 * rights to redistribute these changes.
63 */
64
65/*
66 * Virtual memory mapping module.
67 */
68
69#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 53 unchanged lines hidden (view full) ---

62 * rights to redistribute these changes.
63 */
64
65/*
66 * Virtual memory mapping module.
67 */
68
69#include <sys/cdefs.h>
70__FBSDID("$FreeBSD: head/sys/vm/vm_map.c 117724 2003-07-18 10:47:58Z phk $");
70__FBSDID("$FreeBSD: head/sys/vm/vm_map.c 118771 2003-08-11 07:14:08Z bms $");
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/ktr.h>
75#include <sys/lock.h>
76#include <sys/mutex.h>
77#include <sys/proc.h>
78#include <sys/vmmeter.h>

--- 1520 unchanged lines hidden (view full) ---

1599
1600/*
1601 * vm_map_unwire:
1602 *
1603 * Implements both kernel and user unwiring.
1604 */
1605int
1606vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/ktr.h>
75#include <sys/lock.h>
76#include <sys/mutex.h>
77#include <sys/proc.h>
78#include <sys/vmmeter.h>

--- 1520 unchanged lines hidden (view full) ---

1599
1600/*
1601 * vm_map_unwire:
1602 *
1603 * Implements both kernel and user unwiring.
1604 */
1605int
1606vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
1607 boolean_t user_unwire)
1607 int flags)
1608{
1609 vm_map_entry_t entry, first_entry, tmp_entry;
1610 vm_offset_t saved_start;
1611 unsigned int last_timestamp;
1612 int rv;
1608{
1609 vm_map_entry_t entry, first_entry, tmp_entry;
1610 vm_offset_t saved_start;
1611 unsigned int last_timestamp;
1612 int rv;
1613 boolean_t need_wakeup, result;
1613 boolean_t need_wakeup, result, user_unwire;
1614
1614
1615 user_unwire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE;
1615 vm_map_lock(map);
1616 VM_MAP_RANGE_CHECK(map, start, end);
1617 if (!vm_map_lookup_entry(map, start, &first_entry)) {
1616 vm_map_lock(map);
1617 VM_MAP_RANGE_CHECK(map, start, end);
1618 if (!vm_map_lookup_entry(map, start, &first_entry)) {
1618 vm_map_unlock(map);
1619 return (KERN_INVALID_ADDRESS);
1619 if (flags & VM_MAP_WIRE_HOLESOK)
1620 first_entry = map->header.next;
1621 else {
1622 vm_map_unlock(map);
1623 return (KERN_INVALID_ADDRESS);
1624 }
1620 }
1621 last_timestamp = map->timestamp;
1622 entry = first_entry;
1623 while (entry != &map->header && entry->start < end) {
1624 if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
1625 /*
1626 * We have not yet clipped the entry.
1627 */

--- 39 unchanged lines hidden (view full) ---

1667 vm_map_clip_end(map, entry, end);
1668 /*
1669 * Mark the entry in case the map lock is released. (See
1670 * above.)
1671 */
1672 entry->eflags |= MAP_ENTRY_IN_TRANSITION;
1673 /*
1674 * Check the map for holes in the specified region.
1625 }
1626 last_timestamp = map->timestamp;
1627 entry = first_entry;
1628 while (entry != &map->header && entry->start < end) {
1629 if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
1630 /*
1631 * We have not yet clipped the entry.
1632 */

--- 39 unchanged lines hidden (view full) ---

1672 vm_map_clip_end(map, entry, end);
1673 /*
1674 * Mark the entry in case the map lock is released. (See
1675 * above.)
1676 */
1677 entry->eflags |= MAP_ENTRY_IN_TRANSITION;
1678 /*
1679 * Check the map for holes in the specified region.
1680 * If VM_MAP_WIRE_HOLESOK was specified, skip this check.
1675 */
1681 */
1676 if (entry->end < end && (entry->next == &map->header ||
1677 entry->next->start > entry->end)) {
1682 if (((flags & VM_MAP_WIRE_HOLESOK) == 0) &&
1683 (entry->end < end && (entry->next == &map->header ||
1684 entry->next->start > entry->end))) {
1678 end = entry->end;
1679 rv = KERN_INVALID_ADDRESS;
1680 goto done;
1681 }
1682 /*
1683 * Require that the entry is wired.
1684 */
1685 if (entry->wired_count == 0 || (user_unwire &&

--- 42 unchanged lines hidden (view full) ---

1728
1729/*
1730 * vm_map_wire:
1731 *
1732 * Implements both kernel and user wiring.
1733 */
1734int
1735vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
1685 end = entry->end;
1686 rv = KERN_INVALID_ADDRESS;
1687 goto done;
1688 }
1689 /*
1690 * Require that the entry is wired.
1691 */
1692 if (entry->wired_count == 0 || (user_unwire &&

--- 42 unchanged lines hidden (view full) ---

1735
1736/*
1737 * vm_map_wire:
1738 *
1739 * Implements both kernel and user wiring.
1740 */
1741int
1742vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
1736 boolean_t user_wire)
1743 int flags)
1737{
1738 vm_map_entry_t entry, first_entry, tmp_entry;
1739 vm_offset_t saved_end, saved_start;
1740 unsigned int last_timestamp;
1741 int rv;
1744{
1745 vm_map_entry_t entry, first_entry, tmp_entry;
1746 vm_offset_t saved_end, saved_start;
1747 unsigned int last_timestamp;
1748 int rv;
1742 boolean_t need_wakeup, result;
1749 boolean_t need_wakeup, result, user_wire;
1743
1750
1751 user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE;
1744 vm_map_lock(map);
1745 VM_MAP_RANGE_CHECK(map, start, end);
1746 if (!vm_map_lookup_entry(map, start, &first_entry)) {
1752 vm_map_lock(map);
1753 VM_MAP_RANGE_CHECK(map, start, end);
1754 if (!vm_map_lookup_entry(map, start, &first_entry)) {
1747 vm_map_unlock(map);
1748 return (KERN_INVALID_ADDRESS);
1755 if (flags & VM_MAP_WIRE_HOLESOK)
1756 first_entry = map->header.next;
1757 else {
1758 vm_map_unlock(map);
1759 return (KERN_INVALID_ADDRESS);
1760 }
1749 }
1750 last_timestamp = map->timestamp;
1751 entry = first_entry;
1752 while (entry != &map->header && entry->start < end) {
1753 if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
1754 /*
1755 * We have not yet clipped the entry.
1756 */

--- 94 unchanged lines hidden (view full) ---

1851 goto done;
1852 }
1853 } else if (!user_wire ||
1854 (entry->eflags & MAP_ENTRY_USER_WIRED) == 0) {
1855 entry->wired_count++;
1856 }
1857 /*
1858 * Check the map for holes in the specified region.
1761 }
1762 last_timestamp = map->timestamp;
1763 entry = first_entry;
1764 while (entry != &map->header && entry->start < end) {
1765 if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
1766 /*
1767 * We have not yet clipped the entry.
1768 */

--- 94 unchanged lines hidden (view full) ---

1863 goto done;
1864 }
1865 } else if (!user_wire ||
1866 (entry->eflags & MAP_ENTRY_USER_WIRED) == 0) {
1867 entry->wired_count++;
1868 }
1869 /*
1870 * Check the map for holes in the specified region.
1871 * If VM_MAP_WIRE_HOLESOK was specified, skip this check.
1859 */
1872 */
1860 if (entry->end < end && (entry->next == &map->header ||
1861 entry->next->start > entry->end)) {
1873 if (((flags & VM_MAP_WIRE_HOLESOK) == 0) &&
1874 (entry->end < end && (entry->next == &map->header ||
1875 entry->next->start > entry->end))) {
1862 end = entry->end;
1863 rv = KERN_INVALID_ADDRESS;
1864 goto done;
1865 }
1866 entry = entry->next;
1867 }
1868 rv = KERN_SUCCESS;
1869done:

--- 519 unchanged lines hidden (view full) ---

2389 old_map->infork = 1;
2390
2391 vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset);
2392 bcopy(&vm1->vm_startcopy, &vm2->vm_startcopy,
2393 (caddr_t) &vm1->vm_endcopy - (caddr_t) &vm1->vm_startcopy);
2394 new_map = &vm2->vm_map; /* XXX */
2395 new_map->timestamp = 1;
2396
1876 end = entry->end;
1877 rv = KERN_INVALID_ADDRESS;
1878 goto done;
1879 }
1880 entry = entry->next;
1881 }
1882 rv = KERN_SUCCESS;
1883done:

--- 519 unchanged lines hidden (view full) ---

2403 old_map->infork = 1;
2404
2405 vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset);
2406 bcopy(&vm1->vm_startcopy, &vm2->vm_startcopy,
2407 (caddr_t) &vm1->vm_endcopy - (caddr_t) &vm1->vm_startcopy);
2408 new_map = &vm2->vm_map; /* XXX */
2409 new_map->timestamp = 1;
2410
2411 /* Do not inherit the MAP_WIREFUTURE property. */
2412 if ((new_map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE)
2413 new_map->flags &= ~MAP_WIREFUTURE;
2414
2397 old_entry = old_map->header.next;
2398
2399 while (old_entry != &old_map->header) {
2400 if (old_entry->eflags & MAP_ENTRY_IS_SUB_MAP)
2401 panic("vm_map_fork: encountered a submap");
2402
2403 switch (old_entry->inheritance) {
2404 case VM_INHERIT_NONE:

--- 294 unchanged lines hidden (view full) ---

2699 new_stack_entry->start);
2700 if (is_procstack)
2701 vm->vm_ssize += btoc(new_stack_entry->end -
2702 new_stack_entry->start);
2703 }
2704 }
2705
2706 vm_map_unlock(map);
2415 old_entry = old_map->header.next;
2416
2417 while (old_entry != &old_map->header) {
2418 if (old_entry->eflags & MAP_ENTRY_IS_SUB_MAP)
2419 panic("vm_map_fork: encountered a submap");
2420
2421 switch (old_entry->inheritance) {
2422 case VM_INHERIT_NONE:

--- 294 unchanged lines hidden (view full) ---

2717 new_stack_entry->start);
2718 if (is_procstack)
2719 vm->vm_ssize += btoc(new_stack_entry->end -
2720 new_stack_entry->start);
2721 }
2722 }
2723
2724 vm_map_unlock(map);
2725 /*
2726 * Heed the MAP_WIREFUTURE flag if it was set for this process.
2727 */
2728 if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE))
2729 vm_map_wire(map, addr, stack_entry->start,
2730 (p->p_flag & P_SYSTEM ?
2731 VM_MAP_WIRE_SYSTEM|VM_MAP_WIRE_NOHOLES :
2732 VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES));
2733
2707 return (rv);
2708}
2709
2710/*
2711 * Unshare the specified VM space for exec. If other processes are
2712 * mapped to it, then create a new one. The new vmspace is null.
2713 */
2714void

--- 335 unchanged lines hidden ---
2734 return (rv);
2735}
2736
2737/*
2738 * Unshare the specified VM space for exec. If other processes are
2739 * mapped to it, then create a new one. The new vmspace is null.
2740 */
2741void

--- 335 unchanged lines hidden ---