Re: [PATCH] x86: put initial_pg_tables into bss -v2

From: H. Peter Anvin
Date: Sun Mar 01 2009 - 18:30:08 EST


Yinghai Lu wrote:

No, this is garbage. If you're insisting on getting rid of the brk-like
allocation patterns,> YH
then you have to get an alternative dynamic
allocator available to the pre-paging code. Now, there is no reason we
couldn't execute C code before enabling paging, although the code would
either have to be PIC or linked at the physical address.

you can use find_e820_area()/reserve_early() pair to find right position for that.


This stuff is currently done before paging is enabled, and existing C code can't be run as-is. There are three ways to deal with that:

a) compile some of the code with -fPIC/-fPIE.
b) link some code twice with different offsets.
c) play really ugly games with segments (thus making the virtualization
guys unhappy.)

Pretty much, these options all suck. Another option, of course, is to generate a fixed amount of page tables just to get us into the C environment, generate a new set, *and reclaim the old ones*. That way we're not wasting memory if we're on a small-RAM machine.

It's still really ugly, though. A much easier and cleaner way would seem to be to calculate a far limit on the brk and then marking it as a formal (non-alloc) section in the linker script and vmlinux file. That way anything that examines the vmlinux file will see it as an exclusion section. We can (and should) even verify that we don't overflow the brk and panic if we do.

-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/