Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2

From: H. Peter Anvin
Date: Thu May 29 2008 - 15:01:59 EST


Yinghai Lu wrote:
On Thu, May 29, 2008 at 6:37 AM, Jeremy Fitzhardinge <jeremy@xxxxxxxx> wrote:
Yinghai Lu wrote:
can we use e820 entries for that? So the domain builder could have
several entries for E820_RAM and E820_RESERVED...

I tried this, but it doesn't work; the kernel crashes during boot,
presumably because it's trying to use the reserved memory as heap. I
suspect the e820 maps are not registered early enough or something...

(One thought: if reserving in the E820 map were enough, then couldn't we use
it for all the early reservations?)

"e820 reserved entries" means kernel will only read it.

reserve_early will be converted to bootmem via reserve_bootmem[_generic]
and later it could be freed and be reused.


Hang on...

E820_RESERVED is supposed to mean "nothing touches this address space; the kernel cannot use it either as RAM nor for I/O allocations."

The kernel *cannot* assume it is safe to read. There might be an I/O device there.

Now, to support using the E820 map for early reservations, we can simply define new "fake" E820 types. The easiest way to do that, is to pre-sanitize the map so that all unknown-type entries are collapsed into a "fake" type E820_UNKNOWN:

/* Real E820 types */
#define E820_NONE 0
#define E820_RAM 1
#define E820_RESERVED 2
#define E820_ACPI 3
#define E820_NVS 4

/* Fake E820 types */
#define E820_UNKNOWN 5
#define E820_BOOTMEM 6 /* Pre-bootmem allocation in kernel */

/* .... */

/* Look for unknown types */
if (e820->type >= E820_UNKNOWN)
e820->type = E820_UNKNOWN;

/* Now all numbers above E820_UNKNOWN are available for the kernel */

We can either do this sanitization in the kernel proper, in which case the values we pick have no real importance, as they can change from one version to the next, or in the boot code (Xen domain builder, ELILO, etc.) The latter case would allow us to pass in new types, but in that case, we want to pick a Linux-specific range much higher up the numberspace, for obvious reasons.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/