chaos4ever / chaos

The chaos Operating System
https://chaos4ever.github.io/
16 stars 6 forks source link

Map process page tables using magic PD entry #112

Closed perlun closed 6 years ago

perlun commented 6 years ago

This is a clever hack, inspired by OSDev: http://wiki.osdev.org/Page_Tables#Recursive_mapping (I also saw it on some other page there, but can't remember its location right now.)

It simplifies our code, since it means we never have to update any particular page table mapping when creating a new page table for a thread or process. When we add the page table into the page directory, we automatically can access the page table itself at a deterministic location, which is really convenient.

(Identity mapping all physical memory to virtual address 0 - 2 GiB would have been an even better approach, but it's a much more significant change that involves a lot of #defines to be changed, and I'm not willing to spend all that work right now. Besides, you could use this approach even with identity mapping since it will mean that each thread will always have its page table zone at the same virtual location, which again, makes the code easier to write and maintain...)

I have tested booting up the system with this change in place, and it seems to work fine for me; cluido boots etc.