Changes in kernel/generic/src/ddi/ddi.c [c0699467:473d5d2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
rc0699467 r473d5d2 41 41 42 42 #include <ddi/ddi.h> 43 #include <ddi/ddi_arg.h> 43 44 #include <proc/task.h> 44 45 #include <security/cap.h> … … 121 122 backend_data.frames = pages; 122 123 123 /* 124 * Check if the memory region is explicitly enabled 125 * for mapping by any parea structure. 126 */ 127 128 mutex_lock(&parea_lock); 129 btree_node_t *nodep; 130 parea_t *parea = (parea_t *) btree_search(&parea_btree, 131 (btree_key_t) pf, &nodep); 132 133 if ((parea != NULL) && (parea->frames >= pages)) { 134 if ((!priv) && (!parea->unpriv)) { 135 mutex_unlock(&parea_lock); 136 return EPERM; 137 } 138 139 goto map; 140 } 141 142 parea = NULL; 143 mutex_unlock(&parea_lock); 144 145 /* 146 * Check if the memory region is part of physical 147 * memory generally enabled for mapping. 148 */ 149 124 /* Find the zone of the physical memory */ 150 125 irq_spinlock_lock(&zones.lock, true); 151 126 size_t znum = find_zone(ADDR2PFN(pf), pages, 0); … … 178 153 } 179 154 155 if (zone_flags_available(zones.info[znum].flags)) { 156 /* 157 * Frames are part of physical memory, check 158 * if the memory region is enabled for mapping. 159 */ 160 irq_spinlock_unlock(&zones.lock, true); 161 162 mutex_lock(&parea_lock); 163 btree_node_t *nodep; 164 parea_t *parea = (parea_t *) btree_search(&parea_btree, 165 (btree_key_t) pf, &nodep); 166 167 if ((!parea) || (parea->frames < pages)) { 168 mutex_unlock(&parea_lock); 169 return ENOENT; 170 } 171 172 if (!priv) { 173 if (!parea->unpriv) { 174 mutex_unlock(&parea_lock); 175 return EPERM; 176 } 177 } 178 179 mutex_unlock(&parea_lock); 180 goto map; 181 } 182 180 183 irq_spinlock_unlock(&zones.lock, true); 181 184 return ENOENT; … … 185 188 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { 186 189 /* 187 * The address space area was notcreated.190 * The address space area could not have been created. 188 191 * We report it using ENOMEM. 189 192 */ 190 191 if (parea != NULL)192 mutex_unlock(&parea_lock);193 194 193 return ENOMEM; 195 194 } … … 198 197 * Mapping is created on-demand during page fault. 199 198 */ 200 201 if (parea != NULL) { 202 parea->mapped = true; 203 mutex_unlock(&parea_lock); 204 } 205 206 return EOK; 199 return 0; 207 200 } 208 201
Note:
See TracChangeset
for help on using the changeset viewer.