MMU: If we're identity mapping the kernel image, why not loading the kernel at a high half physical address already? #83
Replies: 6 comments 1 reply
-
Define "higher-half"... What's more tricky is if you want your kernel linked for an address that only exists virtually, like really high, e.g. greater than Every code that runs after MMU init is ideally statically linked to this high address for performance reasons. However, since the addresses will only exist virtually, the code that runs before MMU init cannot be linked/depend on to the target virtual address. A common trick is to compile the parts before MMU init as position independent code (PIC). In Rust, its actually not that trivial to only compile some parts of a binary as PIC and others not. Anyhow, Tutorial 16 will be all about that (remapping the kernel to higher half). I hope I find some time over the winter holidays to get it done. |
Beta Was this translation helpful? Give feedback.
-
I was thinking about these two options before we get to tutorial 16 (looking forward to it btw...):
|
Beta Was this translation helpful? Give feedback.
-
After more digging, and excluding the option of a boot loader, I'm. thinking about 2 implementation options:
|
Beta Was this translation helpful? Give feedback.
-
AFAICS, compiling PIC is currently only possible in crate granularity. Not per object files. At least in a comfortable way. So I'll probably end up with two binaries concatenated together ( Maybe there is a more elegant way, but this is all subject to experiments I'll still need to do. |
Beta Was this translation helpful? Give feedback.
-
How do you plan on making the translation table global static accessible to both? In. the meantime, I'll do some experimentation with placing code. with the linker using https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute and see if I can jump to the kernel code after the MMU is setup. |
Beta Was this translation helpful? Give feedback.
-
I will explore a few ideas, not sure yet. Maybe I build the second binary first, get the offset of the page tables struct in that binary and patch their location offset into the first binary somehow (e.g. through an additional linker symbol). Or something I haven't thought of yet :D |
Beta Was this translation helpful? Give feedback.
-
In the MMU tutorial it is mentioned that identity mapping the kernel image is to avoid complexity, which makes sense. However, since several tutorials we are assuming that the kernel is loaded at 0x8_0000 always. What keeps us from changing that and loading the kernel at a high-half physical address?
Beta Was this translation helpful? Give feedback.
All reactions