docs: documented process isolation concepts
This commit is contained in:
parent
3b54058223
commit
c88c4e9819
|
@ -115,6 +115,37 @@ No detailed Information available (cpu_state null reference)
|
|||
```
|
||||
The `Error Message` could still be helpful, but good luck finding that bug.
|
||||
|
||||
## Memory Layout
|
||||
NoxOS uses a higher half kernel, this means, that the kernels executable is mapped above `0x800000000000`.
|
||||
All kernel and bootloader resources are also mapped in the higher half.
|
||||
This leaves the lower half for process specific mappings
|
||||
|
||||
|
||||
## Process Memory Isolation
|
||||
Every process has its own virtual memory space (page map).
|
||||
This space contains always the following mappings (except in the kernels main process):
|
||||
|
||||
| Name | Address | Permissions |
|
||||
|---------------------------|--------------------|-------------------|
|
||||
| Process executable | 0x0000010000000000 | as defined in ELF |
|
||||
| Thread data (stack, etc.) | 0x0000010100000000 | Read/Write |
|
||||
| Kernel executable | 0xFFFFFFFF80000000 | Read/Exec |
|
||||
| Kernel Heap | 0xFFFFFFFFF0000000 | Read/Write |
|
||||
|
||||
### Thread data
|
||||
Every thread has a _Thread Data_ region, that contains thread specific stuff like a stack.
|
||||
|
||||
The first threads _Thread Data_ region is at `0x0000010100000000`, the seconds at `0x0000010200000000` and so on.
|
||||
|
||||
In this setup, every _Thread Data_ region has a virtual size of 4GB.
|
||||
|
||||
### Context switching
|
||||
Switching between threads is a bit tricky, when the threads stacks are in different page maps.
|
||||
When performing a context switch, the memory region `0x0000010000000000` <--> `0x0000020000000000`
|
||||
is dirty mapped (the PML4 entries are copied) from the next processes' into the kernels page map.
|
||||
This region contains all _Thread Data_ regions and the processes' executable mappings.
|
||||
Due to this dirty mapping the next interrupt handler can always access the current processes' or threads' data.
|
||||
|
||||
## Syscalls
|
||||
NoxOS will use interrupt based syscalls.
|
||||
To perform a syscall, write its ID into the `rax` register and call interrupt 0x80.
|
||||
|
|
Loading…
Reference in New Issue