• David Hildenbrand's avatar
    memblock: add MEMBLOCK_DRIVER_MANAGED to mimic IORESOURCE_SYSRAM_DRIVER_MANAGED · f7892d8e
    David Hildenbrand authored
    Let's add a flag that corresponds to IORESOURCE_SYSRAM_DRIVER_MANAGED,
    indicating that we're dealing with a memory region that is never
    indicated in the firmware-provided memory map, but always detected and
    added by a driver.
    
    Similar to MEMBLOCK_HOTPLUG, most infrastructure has to treat such
    memory regions like ordinary MEMBLOCK_NONE memory regions -- for
    example, when selecting memory regions to add to the vmcore for dumping
    in the crashkernel via for_each_mem_range().
    
    However, especially kexec_file is not supposed to select such memblocks
    via for_each_free_mem_range() / for_each_free_mem_range_reverse() to
    place kexec images, similar to how we handle
    IORESOURCE_SYSRAM_DRIVER_MANAGED without CONFIG_ARCH_KEEP_MEMBLOCK.
    
    We'll make sure that memory hotplug code sets the flag where applicable
    (IORESOURCE_SYSRAM_DRIVER_MANAGED) next.  This prepares architectures
    that need CONFIG_ARCH_KEEP_MEMBLOCK, such as arm64, for virtio-mem
    support.
    
    Note that kexec *must not* indicate this memory to the second kernel and
    *must not* place kexec-images on this memory.  Let's add a comment to
    kexec_walk_memblock(), documenting how we handle MEMBLOCK_DRIVER_MANAGED
    now just like using IORESOURCE_SYSRAM_DRIVER_MANAGED in
    locate_mem_hole_callback() for kexec_walk_resources().
    
    Also note that MEMBLOCK_HOTPLUG cannot be reused due to different
    semantics:
    	MEMBLOCK_HOTPLUG: memory is indicated as "System RAM" in the
    	firmware-provided memory map and added to the system early during
    	boot; kexec *has to* indicate this memory to the second kernel and
    	can place kexec-images on this memory. After memory hotunplug,
    	kexec has to be re-armed. We mostly ignore this flag when
    	"movable_node" is not set on the kernel command line, because
    	then we're told to not care about hotunpluggability of such
    	memory regions.
    
    	MEMBLOCK_DRIVER_MANAGED: memory is not indicated as "System RAM" in
    	the firmware-provided memory map; this memory is always detected
    	and added to the system by a driver; memory might not actually be
    	physically hotunpluggable. kexec *must not* indicate this memory to
    	the second kernel and *must not* place kexec-images on this memory.
    
    Link: https://lkml.kernel.org/r/20211004093605.5830-5-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Reviewed-by: default avatarMike Rapoport <rppt@linux.ibm.com>
    Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: Eric Biederman <ebiederm@xmission.com>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Huacai Chen <chenhuacai@kernel.org>
    Cc: Jianyong Wu <Jianyong.Wu@arm.com>
    Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: Shahab Vahedi <shahab@synopsys.com>
    Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Vineet Gupta <vgupta@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f7892d8e
kexec_file.c 33.6 KB