[UEFI] Holes and missing regions in GetMemoryMap?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
psjarlo
Posts: 13
Joined: Wed Sep 04, 2019 9:51 am

[UEFI] Holes and missing regions in GetMemoryMap?

Post by psjarlo »

I think I know the answer to this but I want to check;

I am using EFI boot services GetMemoryMap and it returns me a list of regions that I can separate out as usable RAM, reserved, etc.
However, the amount of memory reported (even when taking all the types into account) is not at all what I've set in the VM I'm running.

From discussions elsewhere and in the Linux kernel it appears that this is "as expected" because the boot services simply don't map out all of RAM, just some of it and that it will depend on firmware. I'm using VirtualBox and VMWare which I believe both use Tianocore (OVMF I suppose).

The other alternative I know of is a full E820 solution, but I was hoping I wouldn't have to deal with that by booting as EFI.

Is this The Way..?
Octocontrabass
Member
Member
Posts: 5567
Joined: Mon Mar 25, 2013 7:01 pm

Re: [UEFI] Holes and missing regions in GetMemoryMap?

Post by Octocontrabass »

psjarlo wrote:However, the amount of memory reported (even when taking all the types into account) is not at all what I've set in the VM I'm running.
What amount is reported? What amount did you configure the VM for? It probably won't match, since the memory map includes some non-RAM MMIO and doesn't include RAM that's only available in SMM, but it should be pretty close. Big differences usually indicate a bug in your code.
psjarlo
Posts: 13
Joined: Wed Sep 04, 2019 9:51 am

Re: [UEFI] Holes and missing regions in GetMemoryMap?

Post by psjarlo »

You have to love the rubber ducky...

As you suggested it could be a bug I edited the code into my reply and and while virtually explaining it to you, I found it...

I was iterating the descriptor list using a pointer and index "desc" instead of adding the reported size of each descriptor on each round...so I was basically interpreting garbage.

#-o
Post Reply