I forgot:
On 05.11.2013 15:59, Neal H. Walfield wrote:
At Tue, 05 Nov 2013 15:15:49 +0100, Martin Stein wrote:
The single "kernel"-thread executes solely in privileged CPU mode. Initially it disables the MMU and runs in physical address space. Before leaving privileged CPU mode the first time, it enables the MMU, using the address space of the root-task (core). Thus both, threads of the non-privileged root-task and the single "kernel" thread use the same virtual address space. For the purpose of simplification "kernel" thread and root-task threads also share data structures (e.g. raw page-tables or the interrupt-lookup table). This must be done carefully because "kernel" thread can always interrupt root-task threads and access shared objects without synchronization.
If I understand correctly, you are basically implementing a fail fast mechanism for the root task.
Thus, the root task can, say, walk the page tables, but to modify the page tables or to switch protection domains, it traps to the kernel? Similarly, I'm guessing the kernel doesn't walk any of the root task's data structure (or, it does so very conservatively).
Switching of address spaces is done when switching between privileged and non-privileged mode. When a thread is interrupted by privileged mode, root-task address-space gets applied before the kernel thread is called. As soon as kernel is done and switches back to non-privileged mode, the address space of the currently scheduled non-privileged context is applied. Only in case of a switch between root-task thread and kernel-thread, address space keeps the same.