Skip to content
  • Dan Williams's avatar
    devm_memremap_pages: fix vmem_altmap lifetime + alignment handling · eb7d78c9
    Dan Williams authored
    to_vmem_altmap() needs to return valid results until
    arch_remove_memory() completes.  It also needs to be valid for any pfn
    in a section regardless of whether that pfn maps to data.  This escape
    was a result of a bug in the unit test.
    
    The signature of this bug is that free_pagetable() fails to retrieve a
    vmem_altmap and goes off into the weeds:
    
     BUG: unable to handle kernel NULL pointer dereference at           (null)
     IP: [<ffffffff811d2629>] get_pfnblock_flags_mask+0x49/0x60
     [..]
     Call Trace:
      [<ffffffff811d3477>] free_hot_cold_page+0x97/0x1d0
      [<ffffffff811d367a>] __free_pages+0x2a/0x40
      [<ffffffff8191e669>] free_pagetable+0x8c/0xd4
      [<ffffffff8191ef4e>] remove_pagetable+0x37a/0x808
      [<ffffffff8191b210>] vmemmap_free+0x10/0x20
    
    Fixes: 4b94ffdc
    
     ("x86, mm: introduce vmem_altmap to augment vmemmap_populate()")
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Reported-by: default avatarJeff Moyer <jmoyer@redhat.com>
    Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    eb7d78c9