strange E820 map from HP BIOS

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
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

strange E820 map from HP BIOS

Post 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!
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: strange E820 map from HP BIOS

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: strange E820 map from HP BIOS

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: strange E820 map from HP BIOS

Post 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?
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: strange E820 map from HP BIOS

Post by deadbeef »

Thanks Brendan. So... What is your suggestion to do with these interesting entries?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: strange E820 map from HP BIOS

Post by gerryg400 »

Is there any chance that your printf is buggy wrt 64 bit negative numbers ?
If a trainstation is where trains stop, what is a workstation ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: strange E820 map from HP BIOS

Post by Combuster »

First guess: you're converting a signed int to a long?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: strange E820 map from HP BIOS

Post 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!
Post Reply