On Jul 24, 2013, at 4:27 AM, Laszlo Ersek <ler...@redhat.com> wrote:

> On 07/24/13 01:36, Andrew Fish wrote:
>> EFI requests mappings for physical address ranges in the memory map by
>> setting the attribute bit EFI_MEMORY_RUNTIME. The OS (or loader
>> depending on the OS design), after ExitBootServices() calls
>> SetVirtualAddressMap() to provide the firmware with the virtual mapping
>> for the physical address ranges. Prior to the SetVirtualAddressMap() EFI
>> Runtime Services are only called in physical mode, after
>> SetVirtualAddressMap() runtime services may only be called in virtual mode.
>> 
>> You can read up on this in the UEFI 2.4 spec.
> 
> I was recently thinking about this (my first (and to time, only)
> encounter has been svn r14425) -- how do you convert an array that's
> bigger than one page?
> 

The EFI_MEMORY_RUNTIME mapping is for an entire memory region, not individual 
pages. So the firmware gets the new virtual base address for the range for the 
region. The EFI driver then converts any internal pointers (based on what 
region they fall in) in the set virtual address map event, and the DXE Core 
re-applies the PE/COFF fixups for the new virtual base address for the image. 
The PE/COFF was linked at 0 (or 0x240) and relocated into its load address, 
thus the re-applies means adjust the relocations for the shift from the load 
address to the virtual address. 

Thus any code that does relative addressing must be defined in a single region. 
The DXE Core attempts to coalesce memory regions of the same type to make S4 
resume work better so you tend to see a lot of the runtime driver memory 
regions coalesced together in the memory map.

Thanks,

Andrew Fish

> The base pointer can be converted, but code using the array assumes the
> array is contiguous in address space (by way of the subscript operator
> []), which may not be true for virtual addresses if the array is bigger
> than one page.
> 
> One of Matthew Garrett's presentations mentioned this problem/question
> IIRC... Apologies if it has come up before on the list, I can't remember
> the answer.
> 
> Thanks!
> Laszlo


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to