I'm doing some experimenting with UEFI and haven't been able to wrap my head around the virtual addressing..
I have written uefi application that contains the string "CatsAreAwesome". I have the application print the virtual address of that string. It varies each execution so i'll stick with one specific example in this. The code prints that the string is at virtual address 0x120ac3c0. If I pause the VM and scan the vmem file I find two instances of the string at address 0x1209e410 and 0x12ab000
From calling getmemorymap in UEFI I find that the memory section those two fall in are
TYPE PhysStart PhysEnd VirtStart VirtEnd
EfiConventionalMemory 1209C000 120A4000 0 8000
EfiLoaderCode 120A4000 120B1000 0 D000
I don't understand how the translation is working. Virtual start for those two sections are 0, which I would have thought meant identity mapped, but the virtual and physical addresses don't line up so that's obviously not correct. Can someone explain to me how the translation is working? How would I go from virtual to physical or vise versa?
My application prints the string, and gathers the memorymap so the map was gathered while the application was running. The application then waits for user input, I paused the vm during this time, so the physical addresses were found while the application was running.
Looking at the EDK2 code, it seems that
VirtualStart
is always set to zero until theSetVirtualAddressMap
runtime services function is called.