s-matyukevich/raspberry-pi-os

Help implementing virtual memory for local peripherals

vulcanp opened this issue · 1 comments

I have been trying to make virtual memory work with addresses above 0x40000000 in order to use the local timer which was one of the exercises in lesson03 and also as a exercise for muself. I am new to all this but If I understand correctly i would need another entry in the PGD table which points to a new PUD table which then points to another PMD table and then i use the create_block_map to map from 0x40000000 to 0x80000000 at maximum since PUD can map up to 1GB. This mean i need 2 extra tables. I have modified the code that i think its responsible for all this: the linker script and created another macro to place this new 2 tables after the first PMD table and make sure the new entry in PGD points to PUD and PUD to PMD however when i try to access the local timer register it just creates and invalid exception.

I am testing using qemu so i have modified the solution by @xdfm1 and create also code for the identity mapping of this new region. Any help would be really appreciated.

I found the answer to my problem. I was creating another descriptor in the PGD when what i needed was another descriptor in the PUD table which points to a new PMD for the new addresses. Didnt need to make identity mapping because that's stored in ttbr0 and i am using the local peripherals in EL1.