Page 1 of 1
[Solved] E820 Memory Results
Posted: Wed Mar 14, 2018 5:01 pm
by piscus
I obtain information about the memory installed on my PC using the e820 mechanism provided by the BIOS. I have tried to attach an image showing my results (if the image is not displaying I will work on getting it up ASAP). However, my questions may be able to be answered with the image.
I believe I executed retrieved the data correctly, but am surprised by the results (see image below). Following is a list of questions and a screen shot of my results.
a) Regarding the status of the regions returned from the e820 function, the states are: Available and Reserved. However, some regions returned 4. Does anyone know what 4 means? Should this just be considered reserved?
b) I have 4 Gigabytes of memory installed. However, the maximum address returned is 0xBF77A000 + 0x7000 ( 0xBF781000 ). Why is this shown as the maximum amount of memory and not 0xFFFFFFFF? Further, if the only evidence of the memory installed is this map, how can I know for certain how much memory is installed?
c) Consider the last two regions in the picture below. Both are reserved. What is the reason that two reserved regions aren't merged into one large reserved region?
https://photos.app.goo.gl/sJ1VLmOKCRO4PZcF2
Re: E820 Memory Results
Posted: Wed Mar 14, 2018 6:10 pm
by BrightLight
piscus wrote:a) Regarding the status of the regions returned from the e820 function, the states are: Available and Reserved. However, some regions returned 4. Does anyone know what 4 means? Should this just be considered reserved?
Yes. The ACPI spec says memory type 4 means ACPI non-volatile area. This is normally used for MMIO for stuff like batteries, laptop lids, etc. Treat it like reserved.
piscus wrote:b) I have 4 Gigabytes of memory installed. However, the maximum address returned is 0xBF77A000 + 0x7000 ( 0xBF781000 ). Why is this shown as the maximum amount of memory and not 0xFFFFFFFF? Further, if the only evidence of the memory installed is this map, how can I know for certain how much memory is installed?
Somehow I doubt this, but I'll go for it. Are you assuming the size of the memory map entry to be 20 or 24? Because the spec really says it can be anything higher than 20.
piscus wrote:c) Consider the last two regions in the picture below. Both are reserved. What is the reason that two reserved regions aren't merged into one large reserved region?
There isn't necessarily a real reason. The firmware can do almost anything as long as it complies with the specs.
Your memory map looks sane to me actually. Are you sure the PC has 4 GB of RAM? Normally when it has 4 GB of RAM, the first 3 GB are mapped normally, and the last GB is in the 64-bit address space (from 4 GB to 5 GB), to allow PCI MMIO and ACPI tables/MMIO and APICs/HPET/etc to be located between 3-4 GB, for compatibility with 32-bit software.
Re: E820 Memory Results
Posted: Wed Mar 14, 2018 7:17 pm
by piscus
Omar, thanks for the response! That e820 map was produced on my Lenovo Thinkpad t410 (also a 64 Bit machine).
I am assuming the size of the memory map entry to be 20.
Regarding your question about the 4 Gigs, I double checked:
Since I have Linux installed on this PC, I did a 'cat /proc/meminfo' and got:
MemTotal: 3917488 kB
MemFree: 2108540 kB
MemAvailable: 2573120 kB
... etc.
3917488 kB --> 397488000 B --> 0xE9801F80 Bytes
This is pretty close to 4G which is where I am getting that number from.
Re: E820 Memory Results
Posted: Wed Mar 14, 2018 7:38 pm
by piscus
I was able to find the e820 map Linux created on boot via 'dmesg'
The Linux map is identical to mine... only up until a certain point. The Linux version has several more entries beyond my own. Now I'm thinking that some sort of bug is cutting me off early. I am going to investigate and I will post back if I find what the issue is and mark this Resolved.
Thanks again for the response to my questions Omar
Re: E820 Memory Results
Posted: Wed Mar 14, 2018 7:55 pm
by Rudster816
piscus wrote:I obtain information about the memory installed on my PC using the e820 mechanism provided by the BIOS. I have tried to attach an image showing my results (if the image is not displaying I will work on getting it up ASAP). However, my questions may be able to be answered with the image.
I believe I executed retrieved the data correctly, but am surprised by the results (see image below). Following is a list of questions and a screen shot of my results.
a) Regarding the status of the regions returned from the e820 function, the states are: Available and Reserved. However, some regions returned 4. Does anyone know what 4 means? Should this just be considered reserved?
b) I have 4 Gigabytes of memory installed. However, the maximum address returned is 0xBF77A000 + 0x7000 ( 0xBF781000 ). Why is this shown as the maximum amount of memory and not 0xFFFFFFFF? Further, if the only evidence of the memory installed is this map, how can I know for certain how much memory is installed?
c) Consider the last two regions in the picture below. Both are reserved. What is the reason that two reserved regions aren't merged into one large reserved region?
https://photos.app.goo.gl/sJ1VLmOKCRO4PZcF2
There are hardware devices that are mapped into the same address space as "regular RAM", so just because you have 4GB of RAM installed don't expect the maximum address to be 0xFFFFFFFF. The reason the BIOS returns two entries of the same type in adjacent regions is probably because the BIOS developers were lazy and didn't want to check to see if it was possible to merge a region before adding it. Either way its still a perfectly valid E820 map.
To know how much usable RAM is installed you just sum up the length of all the 'type 1' regions. This may differ slightly from what the user expects, e.g. it might not be exactly 16GB if they have 2x8GB sticks of RAM installed. The E820 function is the only way to get a reliable memory map that is useful enough to continue with. So long as the E820 function doesn't indicate an error the map it provides should be trusted but you have to account for weird things like overlapping regions, etc. If it returns an error or isn't available it really isn't worth trying to use other methods (IMHO, I'm sure others will disagree) to detect memory.
piscus wrote:Omar, thanks for the response! That e820 map was produced on my Lenovo Thinkpad t410 (also a 64 Bit machine).
Regarding your question about the 4 Gigs, I double checked:
Since I have Linux installed on this PC, I did a 'cat /proc/meminfo' and got:
MemTotal: 3917488 kB
MemFree: 2108540 kB
MemAvailable: 2573120 kB
... etc.
3917488 kB --> 397488000 B --> 0xE9801F80 Bytes
This is pretty close to 4G which is where I am getting that number from.
Try:
and see what it shows in Linux. Should be 100% identical to what the BIOS gave the kernel.
I suspect that you're somehow missing the last entry (or more) when you're printing your map. Can you post the code on how you call the E820 function? Is it possible you're incrementing the "entry count" after you check if EBX=0 so the last entry is missed?
Re: E820 Memory Results
Posted: Wed Mar 14, 2018 8:33 pm
by piscus
Thanks for the response Rudster. There was a silly error printing the memory map -- I was making a terrible assumption about the number of entries and cutting off the printing early. Turns out there are nearly 40 entries in my map and they do infact continue to increment up to the 4 gig mark.
I am happy with the help and responses to my questions. Thanks again all!