In an attempt to simplify EFI emmory range management and EFI memory map walk, I have rewritten how EFI memory map is managed in the kernel. Here is how I have approached this code. I am walking the EFI memory map and from there I am constructing a linked list of valid memory ranges for kernel to use. To find space to store this linked list in, from within reserve_memory(), I walk the EFI memory map and look for the smallest granule aligned block that will be sufficient to hold the linked list. Amount of space I am allocating for linked list is the number of entries in efi_memmap + another few for safety margin. I then mark this memory reserved. I have added two new functions - efi_gather_memory() which walks the EFI memory map and builds a linked list of kernel usable memory map, and efi_trim_memory() which applies the "max_addr=" and "mem=" restrictions by splitting the linked list of kernel uable memory ranges appropriately. Each node in this linked list has a field called "ignore". To trim a memory range, I can split the list at approrpiate point and mark every node in the list from that point onwards as ignored by setting this field. I rewrote efi_memmap_walk() to use the new kern_memmap list. I have also replaced occurences of "md->num_pages << EFI_PAGE_SHIFT" with a macro. One issue I have not been able to come up with a good solution for is what to do if I fail to allocate memory for the linked list of memory ranges. The only time this will happen is if I can not find a single memory range that is larger than granule size. If that were to happen, I do not see how the machine will boot even if we did not need space for EFI memory map. So for now I have shelved this issue and simply do a machine_restart() if this were to happen ever. Tony, please apply. -- Khalid ==================================================================== Khalid Aziz Linux and Open Source Lab (970)898-9214 Hewlett-Packard khalid_aziz@hp.com Fort Collins, CO "The Linux kernel is subject to relentless development" - Alessandro Rubini