• Will Deacon's avatar
    arm64: Fix /proc/iomem for reserved but not memory regions · d91680e6
    Will Deacon authored
    We describe ranges of 'reserved' memory to userspace via /proc/iomem.
    Commit 50d7ba36 ("arm64: export memblock_reserve()d regions via
    /proc/iomem") updated the logic to export regions that were reserved
    because their contents should be preserved. This allowed kexec-tools
    to tell the difference between 'reserved' memory that must be
    preserved and not overwritten, (e.g. the ACPI tables), and 'nomap'
    memory that must not be touched without knowing the memory-attributes
    (e.g. RAS CPER regions).
    
    The above commit wrongly assumed that memblock_reserve() would not
    be used to reserve regions that aren't memory. It turns out this is
    exactly what early_init_dt_reserve_memory_arch() will do if it finds
    a DT reserved-memory that was also carved out of the memory node, which
    results in a WARN_ON_ONCE() and the region being reserved instead of
    ignored. The ramoops description on hikey and dragonboard-410c both do
    this, so we can't simply write this configuration off as "buggy firmware".
    
    Avoid this issue by rewriting reserve_memblock_reserved_regions() so
    that only the portions of reserved regions which overlap with mapped
    memory are actually reserved.
    
    Fixes: 50d7ba36 ("arm64: export memblock_reserve()d regions via /proc/iomem")
    Reported-by: default avatarJohn Stultz <john.stultz@linaro.org>
    Reported-by: default avatarPaolo Pisati <p.pisati@gmail.com>
    CC: Akashi Takahiro <takahiro.akashi@linaro.org>
    CC: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Reviewed-by: default avatarJames Morse <james.morse@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    d91680e6
setup.c 10.7 KB