Deleted Added
full compact
vm_fault.c (128992) vm_fault.c (129571)
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1994 John S. Dyson
5 * All rights reserved.
6 * Copyright (c) 1994 David Greenman
7 * All rights reserved.
8 *

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

67 * rights to redistribute these changes.
68 */
69
70/*
71 * Page fault handling module.
72 */
73
74#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1994 John S. Dyson
5 * All rights reserved.
6 * Copyright (c) 1994 David Greenman
7 * All rights reserved.
8 *

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

67 * rights to redistribute these changes.
68 */
69
70/*
71 * Page fault handling module.
72 */
73
74#include <sys/cdefs.h>
75__FBSDID("$FreeBSD: head/sys/vm/vm_fault.c 128992 2004-05-06 05:03:23Z alc $");
75__FBSDID("$FreeBSD: head/sys/vm/vm_fault.c 129571 2004-05-22 04:53:51Z alc $");
76
77#include <sys/param.h>
78#include <sys/systm.h>
79#include <sys/kernel.h>
80#include <sys/lock.h>
81#include <sys/mutex.h>
82#include <sys/proc.h>
83#include <sys/resourcevar.h>

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

1033}
1034
1035/*
1036 * vm_fault_wire:
1037 *
1038 * Wire down a range of virtual addresses in a map.
1039 */
1040int
76
77#include <sys/param.h>
78#include <sys/systm.h>
79#include <sys/kernel.h>
80#include <sys/lock.h>
81#include <sys/mutex.h>
82#include <sys/proc.h>
83#include <sys/resourcevar.h>

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

1033}
1034
1035/*
1036 * vm_fault_wire:
1037 *
1038 * Wire down a range of virtual addresses in a map.
1039 */
1040int
1041vm_fault_wire(map, start, end, user_wire)
1042 vm_map_t map;
1043 vm_offset_t start, end;
1044 boolean_t user_wire;
1041vm_fault_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
1042 boolean_t user_wire, boolean_t fictitious)
1045{
1046 vm_offset_t va;
1047 int rv;
1048
1049 /*
1050 * We simulate a fault to get the page and enter it in the physical
1051 * map. For user wiring, we only ask for read access on currently
1052 * read-only sections.
1053 */
1054 for (va = start; va < end; va += PAGE_SIZE) {
1055 rv = vm_fault(map, va,
1056 user_wire ? VM_PROT_READ : VM_PROT_READ | VM_PROT_WRITE,
1057 user_wire ? VM_FAULT_USER_WIRE : VM_FAULT_CHANGE_WIRING);
1058 if (rv) {
1059 if (va != start)
1043{
1044 vm_offset_t va;
1045 int rv;
1046
1047 /*
1048 * We simulate a fault to get the page and enter it in the physical
1049 * map. For user wiring, we only ask for read access on currently
1050 * read-only sections.
1051 */
1052 for (va = start; va < end; va += PAGE_SIZE) {
1053 rv = vm_fault(map, va,
1054 user_wire ? VM_PROT_READ : VM_PROT_READ | VM_PROT_WRITE,
1055 user_wire ? VM_FAULT_USER_WIRE : VM_FAULT_CHANGE_WIRING);
1056 if (rv) {
1057 if (va != start)
1060 vm_fault_unwire(map, start, va);
1058 vm_fault_unwire(map, start, va, fictitious);
1061 return (rv);
1062 }
1063 }
1064 return (KERN_SUCCESS);
1065}
1066
1067/*
1068 * vm_fault_unwire:
1069 *
1070 * Unwire a range of virtual addresses in a map.
1071 */
1072void
1059 return (rv);
1060 }
1061 }
1062 return (KERN_SUCCESS);
1063}
1064
1065/*
1066 * vm_fault_unwire:
1067 *
1068 * Unwire a range of virtual addresses in a map.
1069 */
1070void
1073vm_fault_unwire(map, start, end)
1074 vm_map_t map;
1075 vm_offset_t start, end;
1071vm_fault_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
1072 boolean_t fictitious)
1076{
1077 vm_paddr_t pa;
1078 vm_offset_t va;
1079 pmap_t pmap;
1080
1081 pmap = vm_map_pmap(map);
1082
1083 if (pmap != kernel_pmap)
1084 mtx_lock(&Giant);
1085 /*
1086 * Since the pages are wired down, we must be able to get their
1087 * mappings from the physical map system.
1088 */
1089 for (va = start; va < end; va += PAGE_SIZE) {
1090 pa = pmap_extract(pmap, va);
1091 if (pa != 0) {
1092 pmap_change_wiring(pmap, va, FALSE);
1073{
1074 vm_paddr_t pa;
1075 vm_offset_t va;
1076 pmap_t pmap;
1077
1078 pmap = vm_map_pmap(map);
1079
1080 if (pmap != kernel_pmap)
1081 mtx_lock(&Giant);
1082 /*
1083 * Since the pages are wired down, we must be able to get their
1084 * mappings from the physical map system.
1085 */
1086 for (va = start; va < end; va += PAGE_SIZE) {
1087 pa = pmap_extract(pmap, va);
1088 if (pa != 0) {
1089 pmap_change_wiring(pmap, va, FALSE);
1093 vm_page_lock_queues();
1094 vm_page_unwire(PHYS_TO_VM_PAGE(pa), 1);
1095 vm_page_unlock_queues();
1090 if (!fictitious) {
1091 vm_page_lock_queues();
1092 vm_page_unwire(PHYS_TO_VM_PAGE(pa), 1);
1093 vm_page_unlock_queues();
1094 }
1096 }
1097 }
1098 if (pmap != kernel_pmap)
1099 mtx_unlock(&Giant);
1100}
1101
1102/*
1103 * Routine:

--- 263 unchanged lines hidden ---
1095 }
1096 }
1097 if (pmap != kernel_pmap)
1098 mtx_unlock(&Giant);
1099}
1100
1101/*
1102 * Routine:

--- 263 unchanged lines hidden ---