sched: implement user-configurable fs and gs segment base addresses
This commit is contained in:
@@ -287,3 +287,75 @@ kern_status_t sys_thread_start(kern_handle_t thread_handle)
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
kern_status_t sys_thread_config_get(
|
||||
kern_handle_t thread_handle,
|
||||
kern_config_key_t key,
|
||||
void *ptr,
|
||||
size_t len)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct task *self = current_task();
|
||||
|
||||
if (!validate_access_w(self, ptr, len)) {
|
||||
return KERN_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
struct object *thread_obj;
|
||||
handle_flags_t thread_flags;
|
||||
task_lock_irqsave(self, &flags);
|
||||
kern_status_t status = task_resolve_handle(
|
||||
self,
|
||||
thread_handle,
|
||||
&thread_obj,
|
||||
&thread_flags);
|
||||
if (status != KERN_OK) {
|
||||
task_unlock_irqrestore(self, flags);
|
||||
return status;
|
||||
}
|
||||
|
||||
struct thread *thread = thread_cast(thread_obj);
|
||||
task_unlock_irqrestore(self, flags);
|
||||
|
||||
status = thread_config_get(thread, key, ptr, len);
|
||||
|
||||
object_unref(thread_obj);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
kern_status_t sys_thread_config_set(
|
||||
kern_handle_t thread_handle,
|
||||
kern_config_key_t key,
|
||||
const void *ptr,
|
||||
size_t len)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct task *self = current_task();
|
||||
|
||||
if (!validate_access_w(self, ptr, len)) {
|
||||
return KERN_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
struct object *thread_obj;
|
||||
handle_flags_t thread_flags;
|
||||
task_lock_irqsave(self, &flags);
|
||||
kern_status_t status = task_resolve_handle(
|
||||
self,
|
||||
thread_handle,
|
||||
&thread_obj,
|
||||
&thread_flags);
|
||||
if (status != KERN_OK) {
|
||||
task_unlock_irqrestore(self, flags);
|
||||
return status;
|
||||
}
|
||||
|
||||
struct thread *thread = thread_cast(thread_obj);
|
||||
task_unlock_irqrestore(self, flags);
|
||||
|
||||
status = thread_config_set(thread, key, ptr, len);
|
||||
|
||||
object_unref(thread_obj);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user