Matthias Kruk [Mon, 18 Nov 2019 08:25:01 +0000 (17:25 +0900)]
Make several amendments to the paging code to facilitate process memory management:
- Move definition of struct region to kernel-wide arch.h header
- Make page directories refer to their regions through a pointer array rather than a linked list
- Add pg_dir_foreach_region() function for iterating over the mappings in a page directory
- Add pg_dir_map_region() function for mapping a region from one page directory into another
- Add a reference counter to each region
- Add flags to regions so they can be marked as private, shared, or kernel-related
Matthias Kruk [Wed, 13 Nov 2019 07:35:01 +0000 (16:35 +0900)]
Add some methods for process_t types:
- process_set_pagedir() / process_get_pagedir() - Convenience functions to access the process's pagedir
- process_setuid() - Set the process's user id
- process_setgid() - Set the process's group id
Matthias Kruk [Tue, 12 Nov 2019 09:06:54 +0000 (18:06 +0900)]
Start implementation of facilities to support userspace processes
- Add crxstd.h header with prototypes for Corax-specific syscalls
- Add dummy NET process
- Add dummy STDIO process
- Start NET and STDIO processes from process daemon
Matthias Kruk [Mon, 4 Nov 2019 02:06:34 +0000 (11:06 +0900)]
Modify process_create() function to finalize sys_fork() implementation:
- Copy the contents of the user-mode stack
- Call task_prepare_fork to copy/modify the new task's kernel-mode stack
- Set the state of the new task to TASK_STATE_FORKED
- Set t_pgdir and other values that would normally be set by task_prepare
Matthias Kruk [Tue, 29 Oct 2019 05:07:20 +0000 (14:07 +0900)]
Minor improvements to the scheduler:
- Make _unq() return an error if it didn't succeed
- Add sched_dequeue() function
- Modify sched_tick() not to put tasks with TASK_STATE_EXIT back onto the ready queue
- Add a header with prototypes for the functions implemented in sched.c
Matthias Kruk [Sat, 26 Oct 2019 07:24:58 +0000 (16:24 +0900)]
Implement various IPC and scheduling improvements:
- Implement signalling/waiting facilities for processes and tasks
- Implement primitive message passing between processes
- Implement helper functions for accesing properties of a process
- Also keep the pid within the task structure, for faster access
- Add a wait-queue to the scheduler, to keep track of waiting processes
Matthias Kruk [Tue, 1 Oct 2019 17:20:15 +0000 (02:20 +0900)]
Save/restore the EBP register used in kernel-space during task switches, otherwise the new task will execute on the old stack (causing a page fault) after the C function that called task_switch returns
Matthias Kruk [Tue, 1 Oct 2019 09:13:09 +0000 (18:13 +0900)]
Improve interrupt handling and task switching code:
- Introduce definitions to make task_prepare and task_switch easier to understand
- Make interrupt handlers push cr3 onto the stack and restore it before an iret
- Make interrupt handlers adjust the stack pointers upon entry/exit since the tasks'
kernel-mode stacks are mapped at their linear addresses in the kernel's page directory
Matthias Kruk [Tue, 1 Oct 2019 07:01:49 +0000 (16:01 +0900)]
Don't perform arithmetic on the stack pointer arguments within task_prepare, i.e. the caller is expected to provide the correct addresses where the stacks may be placed
Matthias Kruk [Tue, 1 Oct 2019 06:42:37 +0000 (15:42 +0900)]
Switch to the kernel page directory when entering the kernel (i.e. separate the kernel and user address spaces to avoid side-channel attacks on speculative execution in certain CPUs)
Separate the architecture dependent and independent parts of the kernel more cleanly:
- Add pg_dir_get_pdbr() function
- Make definitions, types, and functions necessary for other parts of the
kernel visible to them by moving them into the kernel/include/arch.h header