Changes in kernel/generic/src/ddi/ddi.c [597fa24:5a5269d] in mainline
- File:
-
- 1 edited
-
kernel/generic/src/ddi/ddi.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r597fa24 r5a5269d 54 54 #include <align.h> 55 55 #include <errno.h> 56 #include <mem w.h>56 #include <mem.h> 57 57 #include <trace.h> 58 58 #include <bitops.h> … … 60 60 61 61 /** This lock protects the @c pareas ordered dictionary. */ 62 static MUTEX_INITIALIZE(pareas_lock, MUTEX_PASSIVE);62 static mutex_t pareas_lock; 63 63 64 64 /** Ordered dictionary of enabled physical memory areas by base address. */ … … 74 74 { 75 75 odict_initialize(&pareas, pareas_getkey, pareas_cmp); 76 mutex_initialize(&pareas_lock, MUTEX_PASSIVE); 76 77 } 77 78 … … 104 105 105 106 mutex_unlock(&pareas_lock); 106 }107 108 /** Norify physical area has been unmapped.109 *110 * @param parea Physical area111 */112 void ddi_parea_unmap_notify(parea_t *parea)113 {114 parea->mapped = false;115 if (parea->mapped_changed != NULL)116 parea->mapped_changed(parea->arg);117 107 } 118 108 … … 214 204 215 205 map: 216 backend_data.parea = parea;217 218 206 if (!as_area_create(TASK->as, flags, FRAMES2SIZE(pages), 219 207 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { … … 335 323 return EPERM; 336 324 325 irq_spinlock_lock(&tasks_lock, true); 326 337 327 task_t *task = task_find_by_id(id); 338 328 339 if (!task) 329 if ((!task) || (!container_check(CONTAINER, task->container))) { 330 /* 331 * There is no task with the specified ID 332 * or the task belongs to a different security 333 * context. 334 */ 335 irq_spinlock_unlock(&tasks_lock, true); 340 336 return ENOENT; 341 342 errno_t rc = ENOENT; 343 344 irq_spinlock_lock(&task->lock, true); 345 346 /* Check that the task belongs to the correct security context. */ 347 if (container_check(CONTAINER, task->container)) 348 rc = ddi_iospace_enable_arch(task, ioaddr, size); 349 337 } 338 339 /* Lock the task and release the lock protecting tasks dictionary. */ 340 irq_spinlock_exchange(&tasks_lock, &task->lock); 341 errno_t rc = ddi_iospace_enable_arch(task, ioaddr, size); 350 342 irq_spinlock_unlock(&task->lock, true); 351 task_release(task); 343 352 344 return rc; 353 345 } … … 372 364 return EPERM; 373 365 366 irq_spinlock_lock(&tasks_lock, true); 367 374 368 task_t *task = task_find_by_id(id); 375 369 376 if (!task) 370 if ((!task) || (!container_check(CONTAINER, task->container))) { 371 /* 372 * There is no task with the specified ID 373 * or the task belongs to a different security 374 * context. 375 */ 376 irq_spinlock_unlock(&tasks_lock, true); 377 377 return ENOENT; 378 379 errno_t rc = ENOENT; 380 381 irq_spinlock_lock(&task->lock, true); 382 383 /* Check that the task belongs to the correct security context. */ 384 if (container_check(CONTAINER, task->container)) 385 rc = ddi_iospace_disable_arch(task, ioaddr, size); 386 378 } 379 380 /* Lock the task and release the lock protecting tasks dictionary. */ 381 irq_spinlock_exchange(&tasks_lock, &task->lock); 382 errno_t rc = ddi_iospace_disable_arch(task, ioaddr, size); 387 383 irq_spinlock_unlock(&task->lock, true); 388 task_release(task); 384 389 385 return rc; 390 386 } … … 447 443 backend_data.frames = frames; 448 444 backend_data.anonymous = true; 449 backend_data.parea = NULL;450 445 451 446 if (!as_area_create(TASK->as, map_flags, size,
Note:
See TracChangeset
for help on using the changeset viewer.
