rust-osdev / bootloader

An experimental pure-Rust x86 bootloader
Apache License 2.0
1.32k stars 202 forks source link

Global Page Flag & Kernel Mapping #145

Open MarcoCicognani opened 3 years ago

MarcoCicognani commented 3 years ago

Hi, as I written in the title it would be a good idea to enable global pages and map the kernel using this flag. Doing this any kernel mapping would be implicitly duplicated across all the address spaces.

Keep it up! Waiting UEFI rework's release

bjorn3 commented 3 years ago

Not every kernel may want to do this. For example it could use kernel page table isolation as mitigation for Meltdown. In addition the kernel can map itself using this flag.

MarcoCicognani commented 3 years ago

Sure! Then it could be a configurable feature like recursive or physical mapping

phil-opp commented 3 years ago

We typically only provide functionality in the bootloader that is impossible or difficult to implement in the kernel itself. For example, it is not possible to set up a physical memory mapping without access to the page tables in the first place. Setting the global bit, on the other hand, can be done relatively easily from the kernel itself by iterating over the non-empty page table entries and setting the global bit for each.

So adding support for this in the bootloader would be purely a convenience feature. It might be worth it if enough people want it, but I'm not sure if the approach is still common enough today (given Meltdown and similar vulnerabilities).