• Benjamin Herrenschmidt's avatar
    mm/memblock: properly handle overlaps and fix error path · 8f7a6605
    Benjamin Herrenschmidt authored
    Currently memblock_reserve() or memblock_free() don't handle overlaps of
    any kind.  There is some special casing for coalescing exactly adjacent
    regions but that's about it.
    
    This is annoying because typically memblock_reserve() is used to mark
    regions passed by the firmware as reserved and we all know how much we can
    trust our firmwares...
    
    Also, with the current code, if we do something it doesn't handle right
    such as trying to memblock_reserve() a large range spanning multiple
    existing smaller reserved regions for example, or doing overlapping
    reservations, it can silently corrupt the internal region array, causing
    odd errors much later on, such as allocations returning reserved regions
    etc...
    
    This patch rewrites the underlying functions that add or remove a region
    to the arrays.  The new code is a lot more robust as it fully handles
    overlapping regions.  It's also, imho, simpler than the previous
    implementation.
    
    In addition, while doing so, I ...
    8f7a6605
memblock.c 22.7 KB