kexec_file: don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED
authorDavid Hildenbrand <david@redhat.com>
Thu, 4 Jun 2020 23:48:44 +0000 (16:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Jun 2020 02:06:23 +0000 (19:06 -0700)
Memory flagged with IORESOURCE_MEM_DRIVER_MANAGED is special - it won't be
part of the initial memmap of the kexec kernel and not all memory might be
accessible.  Don't place any kexec images onto it.

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Link: http://lkml.kernel.org/r/20200508084217.9160-4-david@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/kexec_file.c

index faa74d5f69411b420c7ea47cc58f1476ca0eafe7..bb05fd52de850ad388cdcd228d62e145804d611e 100644 (file)
@@ -540,6 +540,11 @@ static int locate_mem_hole_callback(struct resource *res, void *arg)
        unsigned long sz = end - start + 1;
 
        /* Returning 0 will take to next memory range */
+
+       /* Don't use memory that will be detected and handled by a driver. */
+       if (res->flags & IORESOURCE_MEM_DRIVER_MANAGED)
+               return 0;
+
        if (sz < kbuf->memsz)
                return 0;