sched: implement user-configurable fs and gs segment base addresses
This commit is contained in:
@@ -11,6 +11,8 @@ static const virt_addr_t syscall_table[] = {
|
||||
SYSCALL_TABLE_ENTRY(TASK_CREATE_THREAD, task_create_thread),
|
||||
SYSCALL_TABLE_ENTRY(TASK_GET_ADDRESS_SPACE, task_get_address_space),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_START, thread_start),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_CONFIG_GET, thread_config_get),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_CONFIG_SET, thread_config_set),
|
||||
SYSCALL_TABLE_ENTRY(VM_OBJECT_CREATE, vm_object_create),
|
||||
SYSCALL_TABLE_ENTRY(VM_OBJECT_READ, vm_object_read),
|
||||
SYSCALL_TABLE_ENTRY(VM_OBJECT_WRITE, vm_object_write),
|
||||
|
||||
@@ -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