Skip to content
  • Lianbo Jiang's avatar
    kexec: Improve & fix crash_exclude_mem_range() to handle overlapping ranges · a2e9a95d
    Lianbo Jiang authored
    
    
    The crash_exclude_mem_range() function can only handle one memory region a time.
    
    It will fail in the case in which the passed in area covers several memory
    regions. In this case, it will only exclude the first region, then return,
    but leave the later regions unsolved.
    
    E.g in a NEC system with two usable RAM regions inside the low 1M:
    
      ...
      BIOS-e820: [mem 0x0000000000000000-0x000000000003efff] usable
      BIOS-e820: [mem 0x000000000003f000-0x000000000003ffff] reserved
      BIOS-e820: [mem 0x0000000000040000-0x000000000009ffff] usable
    
    It will only exclude the memory region [0, 0x3efff], the memory region
    [0x40000, 0x9ffff] will still be added into /proc/vmcore, which may cause
    the following failure when dumping vmcore:
    
     ioremap on RAM at 0x0000000000040000 - 0x0000000000040fff
     WARNING: CPU: 0 PID: 665 at arch/x86/mm/ioremap.c:186 __ioremap_caller+0x2c7/0x2e0
     ...
     RIP: 0010:__ioremap_caller+0x2c7/0x2e0
     ...
     cp: error reading '/proc/vmcore': Cannot allocate memory
     kdump: saving vmcore failed
    
    In order to fix this bug, let's extend the crash_exclude_mem_range()
    to handle the overlapping ranges.
    
    [ mingo: Amended the changelog. ]
    
    Signed-off-by: default avatarLianbo Jiang <lijiang@redhat.com>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Acked-by: default avatarDave Young <dyoung@redhat.com>
    Link: https://lore.kernel.org/r/20200804044933.1973-3-lijiang@redhat.com
    a2e9a95d