Changeset 2bb8648 in mainline
- Timestamp:
- 2006-05-07T15:21:11Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31282f9
- Parents:
- ecf3722
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/mm
recf3722 r2bb8648 58 58 tables. 59 59 60 61 62 60 1.2 Single global page hash table 63 61 … … 66 64 There is only one global page hash table in the system shared by all address 67 65 spaces. 66 67 68 2. Memory allocators 68 69 69 70 2.1 General allocator -
generic/include/ddi/ddi.h
recf3722 r2bb8648 36 36 extern __native sys_physmem_map(ddi_memarg_t *uspace_mem_arg); 37 37 extern __native sys_iospace_enable(ddi_ioarg_t *uspace_io_arg); 38 extern __native sys_preempt_control(int enable); 38 39 39 40 /* -
generic/include/security/cap.h
recf3722 r2bb8648 42 42 #define __CAP_H__ 43 43 44 #include <syscall/sysarg64.h> 44 45 #include <arch/types.h> 45 46 #include <typedefs.h> … … 64 65 65 66 /** 66 * CAP_PREEMPT_CONTROL allows its holder to disable interrupts67 * CAP_PREEMPT_CONTROL allows its holder to disable/enable preemption. 67 68 */ 68 #define CAP_PREEMPT_CONTROL (1<<3) 69 #define CAP_PREEMPT_CONTROL (1<<3) 70 71 /** 72 * CAP_IRQ_REG entitles its holder to register IRQ handlers. 73 */ 74 #define CAP_IRQ_REG (1<<4) 69 75 70 76 typedef __u32 cap_t; … … 73 79 extern cap_t cap_get(task_t *t); 74 80 81 extern __native sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps); 82 extern __native sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps); 83 75 84 #endif -
generic/include/syscall/syscall.h
recf3722 r2bb8648 33 33 SYS_IO = 0, 34 34 SYS_TLS_SET = 1, /* Hardcoded in AMD64,IA32 uspace - psthread.S */ 35 SYS_PREEMPT_CONTROL,36 35 SYS_THREAD_CREATE, 37 36 SYS_THREAD_EXIT, … … 54 53 SYS_IPC_REGISTER_IRQ, 55 54 SYS_IPC_UNREGISTER_IRQ, 55 SYS_CAP_GRANT, 56 SYS_CAP_REVOKE, 56 57 SYS_MAP_PHYSMEM, 57 58 SYS_IOSPACE_ENABLE, 59 SYS_PREEMPT_CONTROL, 58 60 SYSCALL_END 59 61 } syscall_t; -
generic/src/ddi/ddi.c
recf3722 r2bb8648 212 212 return (__native) ddi_iospace_enable((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size); 213 213 } 214 215 /** Disable or enable preemption. 216 * 217 * @param enable If non-zero, the preemption counter will be decremented, leading to potential 218 * enabling of preemption. Otherwise the preemption counter will be incremented, 219 * preventing preemption from occurring. 220 * 221 * @return Zero on success or EPERM if callers capabilities are not sufficient. 222 */ 223 __native sys_preempt_control(int enable) 224 { 225 if (! cap_get(TASK) & CAP_PREEMPT_CONTROL) 226 return EPERM; 227 if (enable) 228 preemption_enable(); 229 else 230 preemption_disable(); 231 return 0; 232 } -
generic/src/ipc/sysipc.c
recf3722 r2bb8648 40 40 #include <print.h> 41 41 #include <syscall/copy.h> 42 #include <security/cap.h> 42 43 43 44 #define GET_CHECK_PHONE(phone,phoneid,err) { \ … … 491 492 __native sys_ipc_register_irq(__native irq, irq_code_t *ucode) 492 493 { 494 if (!(cap_get(TASK) & CAP_IRQ_REG)) 495 return EPERM; 496 493 497 if (irq >= IRQ_COUNT) 494 return -ELIMIT;498 return (__native) ELIMIT; 495 499 496 500 irq_ipc_bind_arch(irq); … … 502 506 __native sys_ipc_unregister_irq(__native irq) 503 507 { 508 if (!(cap_get(TASK) & CAP_IRQ_REG)) 509 return EPERM; 510 504 511 if (irq >= IRQ_COUNT) 505 return -ELIMIT;512 return (__native) ELIMIT; 506 513 507 514 ipc_irq_unregister(&TASK->answerbox, irq); -
generic/src/main/kinit.c
recf3722 r2bb8648 160 160 * Set capabilities to init userspace tasks. 161 161 */ 162 cap_set(utask, CAP_CAP | CAP_MEM_MANAGER | CAP_IO_MANAGER );162 cap_set(utask, CAP_CAP | CAP_MEM_MANAGER | CAP_IO_MANAGER | CAP_PREEMPT_CONTROL); 163 163 164 164 if (!ipc_phone_0) -
generic/src/mm/tlb.c
recf3722 r2bb8648 30 30 * @file tlb.c 31 31 * @brief Generic TLB shootdown algorithm. 32 * 33 * The algorithm implemented here is based on the CMU TLB shootdown 34 * algorithm and is further simplified (e.g. all CPUs receive all TLB 35 * shootdown messages). 32 36 */ 33 37 -
generic/src/security/cap.c
recf3722 r2bb8648 37 37 #include <proc/task.h> 38 38 #include <synch/spinlock.h> 39 #include <syscall/sysarg64.h> 40 #include <syscall/copy.h> 39 41 #include <arch.h> 40 42 #include <typedefs.h> 43 #include <errno.h> 41 44 42 45 /** Set capabilities. … … 78 81 return caps; 79 82 } 83 84 /** Grant capabilities to a task. 85 * 86 * The calling task must have the CAP_CAP capability. 87 * 88 * @param uspace_taskid_arg Userspace structure holding destination task ID. 89 * @param caps Capabilities to grant. 90 * 91 * @return Zero on success or an error code from @ref errno.h. 92 */ 93 __native sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps) 94 { 95 sysarg64_t taskid_arg; 96 task_t *t; 97 ipl_t ipl; 98 int rc; 99 100 if (!(cap_get(TASK) & CAP_CAP)) 101 return (__native) EPERM; 102 103 rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 104 if (rc != 0) 105 return (__native) rc; 106 107 ipl = interrupts_disable(); 108 spinlock_lock(&tasks_lock); 109 t = task_find_by_id((task_id_t) taskid_arg.value); 110 if (!t) { 111 spinlock_unlock(&tasks_lock); 112 interrupts_restore(ipl); 113 return (__native) ENOENT; 114 } 115 spinlock_unlock(&tasks_lock); 116 117 cap_set(t, cap_get(t) | caps); 118 119 interrupts_restore(ipl); 120 return 0; 121 } 122 123 /** Revoke capabilities from a task. 124 * 125 * The calling task must have the CAP_CAP capability or the caller must 126 * attempt to revoke capabilities from itself. 127 * 128 * @param uspace_taskid_arg Userspace structure holding destination task ID. 129 * @param caps Capabilities to revoke. 130 * 131 * @return Zero on success or an error code from @ref errno.h. 132 */ 133 __native sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps) 134 { 135 sysarg64_t taskid_arg; 136 task_t *t; 137 ipl_t ipl; 138 int rc; 139 140 rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 141 if (rc != 0) 142 return (__native) rc; 143 144 ipl = interrupts_disable(); 145 spinlock_lock(&tasks_lock); 146 t = task_find_by_id((task_id_t) taskid_arg.value); 147 if (!t) { 148 spinlock_unlock(&tasks_lock); 149 interrupts_restore(ipl); 150 return (__native) ENOENT; 151 } 152 spinlock_unlock(&tasks_lock); 153 154 /* 155 * Revoking capabilities is different from granting them in that 156 * a task can revoke capabilities from itself even if it 157 * doesn't have CAP_CAP. 158 */ 159 if (!(cap_get(TASK) & CAP_CAP) || !(t == TASK)) { 160 interrupts_restore(ipl); 161 return (__native) EPERM; 162 } 163 164 cap_set(t, cap_get(t) & ~caps); 165 166 interrupts_restore(ipl); 167 return 0; 168 } -
generic/src/syscall/syscall.c
recf3722 r2bb8648 44 44 #include <synch/futex.h> 45 45 #include <ddi/ddi.h> 46 #include <security/cap.h> 46 47 #include <syscall/copy.h> 47 48 … … 56 57 57 58 return count; 58 }59 60 static __native sys_preempt_control(int enable)61 {62 if (! cap_get(TASK) & CAP_PREEMPT_CONTROL)63 return EPERM;64 if (enable)65 preemption_enable();66 else67 preemption_disable();68 return 0;69 59 } 70 60 … … 82 72 sys_io, 83 73 sys_tls_set, 84 sys_preempt_control, 85 74 86 75 /* Thread and task related syscalls. */ 87 76 sys_thread_create, … … 112 101 sys_ipc_unregister_irq, 113 102 103 /* Capabilities related syscalls. */ 104 sys_cap_grant, 105 sys_cap_revoke, 106 114 107 /* DDI related syscalls. */ 115 108 sys_physmem_map, 116 sys_iospace_enable 109 sys_iospace_enable, 110 sys_preempt_control 117 111 };
Note:
See TracChangeset
for help on using the changeset viewer.