Page 1 of 1

strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 6:29 am
by deadbeef
Hi all,

today I discovered that the E820 memory map returned by the BIOS of a HP Compaq dc7900 (version 78661, v01.16) is a bit strange:

I get something like that:

Code: Select all

01  base=0x00000000_00000000  length=0x00000000_0009F800  type=usable
02  base=0x00000000_0009F800  length=0x00000000_00000000  type=reserved
03  base=0x00000000_0009FC00  length=0x00000000_00000400  type=reserved
04  base=0x00000000_0009F800  length=0x00000000_00000400  type=usable
05  base=0x00000000_000E8000  length=0x00000000_00018000  type=reserved
06  base=0x00000000_00100000  length=0x00000000_7C8A1740  type=usable
07  base=0x00000000_7C9A1740  length=0x00000000_00002000  type=acpi_nvs
08  base=0x00000000_7C9A3740  length=0x00000000_00000060  type=acpi_nvs
09  base=0x00000000_7C9A37A0  length=0x00000000_0265C860  type=reserved
10  base=0xFFFFFFFF_F4000000  length=0x00000000_04000000  type=reserved
11  base=0xFFFFFFFF_FEC00000  length=0x00000000_00140000  type=reserved
I ignore entry 02 for it has length 0. I combine entries 07 and 08 for they are adjacent and have the same type.

That's all fine. What bothers me is the entries 10 and 11. There the base addresses have the upper 32 bits set, which seems wrong to me. How should I deal with these entries? (I have a 64 bit OS, so I care about the full 64 bit address.)

Oh, and second: For the memory region that lies between the region described by entries 09 and 10, i.e. 0x7F000000 - 0xF4000000, is it safe to assume it's usable memory? Or should I only allocate memory in regions that are reported in the E820 map and typed "usable" (type 1)?

Thanks in advance!

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 6:52 am
by Owen
The only memory regions that you can legally use are those marked as usable memory or ACPI reclaim (<-- and the latter only once you have finished using the contained data!). This is all defined by the ACPI spec; I suggest you go and look at the E820 section of it.

I would just ignore blatantly illegal E820 entries.

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 6:53 am
by Brendan
Hi,
deadbeef wrote:

Code: Select all

10  base=0xFFFFFFFF_F4000000  length=0x00000000_04000000  type=reserved
11  base=0xFFFFFFFF_FEC00000  length=0x00000000_00140000  type=reserved
That's all fine. What bothers me is the entries 10 and 11. There the base addresses have the upper 32 bits set, which seems wrong to me. How should I deal with these entries? (I have a 64 bit OS, so I care about the full 64 bit address.)
Those entries bother me too. They look like they should be for things like HPET, APICs, etc, and the firmware ROM; and the upper 32-bits of the base should be clear. It would be very unusual for APICs to be above 4 GiB, especially for backward compatibility (e.g. in case you felt like running an older 32-bit OS). It would also be very unusual for the firmware's ROM to be above 4 GiB, as the CPU itself starts executing at 0x00000000FFFFFFF0 at power on.
deadbeef wrote:Oh, and second: For the memory region that lies between the region described by entries 09 and 10, i.e. 0x7F000000 - 0xF4000000, is it safe to assume it's usable memory? Or should I only allocate memory in regions that are reported in the E820 map and typed "usable" (type 1)?
Only allocate areas that have "type = usable". The computer only has 2 GiB of RAM and parts of that unmentioned space are likely to be used by various PCI devices.


Cheers,

Brendan

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 7:00 am
by deadbeef
Thanks, Owen. I did look at the ACPI spec, that's from where I have the info to retrieve the shown map.

Okay, what about the strange "upper 32 bit set"-issue?

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 7:02 am
by deadbeef
Thanks Brendan. So... What is your suggestion to do with these interesting entries?

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 7:03 am
by gerryg400
Is there any chance that your printf is buggy wrt 64 bit negative numbers ?

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 7:14 am
by Combuster
First guess: you're converting a signed int to a long?

Re: strange E820 map from HP BIOS

Posted: Wed Apr 11, 2012 8:54 am
by deadbeef
Combuster wrote:First guess: you're converting a signed int to a long?
Argh! Yep, just found that myself. It was a bit buried deep in a call chain. That led me to the insight I should simplify my code :?
Now, works like a charm ;)
Thanks folks!