/trunk/kernel/generic/include/proc/thread.h |
---|
146,7 → 146,6 |
int priority; /**< Thread's priority. Implemented as index to CPU->rq */ |
uint32_t tid; /**< Thread ID. */ |
context_id_t context; /**< Thread security context */ |
thread_arch_t arch; /**< Architecture-specific data. */ |
/trunk/kernel/generic/include/arch.h |
---|
43,12 → 43,17 |
#include <arch/cpu.h> |
#include <arch/asm.h> |
#define DEFAULT_CONTEXT 0 |
#define CPU THE->cpu |
#define THREAD THE->thread |
#define TASK THE->task |
#define AS THE->as |
#define CONTEXT (THE->task ? THE->task->context : DEFAULT_CONTEXT) |
#define PREEMPTION_DISABLED THE->preemption_disabled |
#define context_check(ctx1, ctx2) ((ctx1) == (ctx2)) |
/** |
* For each possible kernel stack, structure |
* of the following type will be placed at |
60,10 → 65,9 |
task_t *task; /**< Current task. */ |
cpu_t *cpu; /**< Executing cpu. */ |
as_t *as; /**< Current address space. */ |
context_id_t context; /**< Current security context. */ |
}; |
#define THE ((the_t *)(get_stack_base())) |
#define THE ((the_t *)(get_stack_base())) |
extern void the_initialize(the_t *the); |
extern void the_copy(the_t *src, the_t *dst); |
/trunk/kernel/generic/src/ddi/ddi.c |
---|
129,9 → 129,11 |
t = task_find_by_id(id); |
if (!t) { |
if ((!t) || (!context_check(CONTEXT, t->context))) { |
/* |
* There is no task with the specified ID. |
* There is no task with the specified ID |
* or the task belongs to a different security |
* context. |
*/ |
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |
/trunk/kernel/generic/src/proc/the.c |
---|
58,7 → 58,6 |
the->thread = NULL; |
the->task = NULL; |
the->as = NULL; |
the->context = 0; |
} |
/** Copy THE structure |
/trunk/kernel/generic/src/proc/task.c |
---|
115,15 → 115,15 |
ta->name = name; |
ta->main_thread = NULL; |
ta->refcount = 0; |
ta->context = THE->context; |
ta->context = CONTEXT; |
ta->capabilities = 0; |
ta->accept_new_threads = true; |
ipc_answerbox_init(&ta->answerbox); |
for (i=0; i < IPC_MAX_PHONES;i++) |
for (i = 0; i < IPC_MAX_PHONES; i++) |
ipc_phone_init(&ta->phones[i]); |
if (ipc_phone_0) |
if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context))) |
ipc_phone_connect(&ta->phones[0], ipc_phone_0); |
atomic_set(&ta->active_calls, 0); |
/trunk/kernel/generic/src/proc/thread.c |
---|
318,7 → 318,6 |
memcpy(t->name, name, THREAD_NAME_BUFLEN); |
t->context = THE->context; |
t->thread_code = func; |
t->thread_arg = arg; |
t->ticks = -1; |
534,8 → 533,8 |
thread_t *t; |
t = (thread_t *) node->value[i]; |
printf("%s: address=%#zx, tid=%zd, context=%ld, state=%s, task=%#zx, code=%#zx, stack=%#zx, cpu=", |
t->name, t, t->tid, t->context, thread_states[t->state], t->task, t->thread_code, t->kstack); |
printf("%s: address=%#zx, tid=%zd, state=%s, task=%#zx, context=%ld, code=%#zx, stack=%#zx, cpu=", |
t->name, t, t->tid, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack); |
if (t->cpu) |
printf("cpu%zd", t->cpu->id); |
else |
/trunk/kernel/generic/src/security/cap.c |
---|
111,7 → 111,7 |
ipl = interrupts_disable(); |
spinlock_lock(&tasks_lock); |
t = task_find_by_id((task_id_t) taskid_arg.value); |
if (!t) { |
if ((!t) || (!context_check(CONTEXT, t->context))) { |
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |
return (unative_t) ENOENT; |
122,9 → 122,6 |
spinlock_unlock(&t->lock); |
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |
return 0; |
} |
153,7 → 150,7 |
ipl = interrupts_disable(); |
spinlock_lock(&tasks_lock); |
t = task_find_by_id((task_id_t) taskid_arg.value); |
if (!t) { |
if ((!t) || (!context_check(CONTEXT, t->context))) { |
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |
return (unative_t) ENOENT; |