[to-be-updated] kexec_file-load-kernel-at-top-of-system-ram-if-required.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: kernel/kexec_file.c: load kernel at top of system RAM if required
has been removed from the -mm tree.  Its filename was
     kexec_file-load-kernel-at-top-of-system-ram-if-required.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: Baoquan He <bhe@xxxxxxxxxx>
Subject: kernel/kexec_file.c: load kernel at top of system RAM if required

For kexec_file loading, if kexec_buf.top_down is 'true', the memory which
is used to load kernel/initrd/purgatory is supposed to be allocated from
top to down.  This is also consistent with the old kexec loading
interface.

However, the current arch_kexec_walk_mem() doesn't do like this.  It
ignores checking kexec_buf.top_down, but calls walk_system_ram_res()
directly to go through all resources of System RAM, to try to find a
memory region which can contain the specific kexec buffer, then calls
locate_mem_hole_callback() to allocate memory in that found memory region
from top to down.  This is not right.

Here add checking if kexec_buf.top_down is 'true' in
arch_kexec_walk_mem(), if yes, call the newly added
walk_system_ram_res_rev() to find memory region from top to down to load
kernel.


The problem is the current kexec file loading has different behaviour with
the old kexec loading.  In kexec loading, user space kexec_tools utility
does most of job, it searches in /proc/iomem to try to find a memory
region from top to down to load kernel.  Therefore with the kexec loading,
x86_64 bzImage kernel are all loaded at top of System RAM.  However, the
kexec file loading just searches for available memory region in iomem
resource from bottom to top, then try to allocate from top to down in that
region.  E.g on my testing system with 2G memory as below, the kexec
loading will put kernel near 0x000000013fffffff, while kexec file loading
will put kernel near 0x000000003ffddfff.  There's no bug reported yet,
just we need consider it when take care of the kexec collaboration with
other kernel components like kaslr/hotplug etc, and also the
consistentency between the different kexec interface.

[Mar23 15:13] Linux version 4.16.0-rc3+ (bhe@localhost.localdomain) (gcc version
[  +0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.16.0-rc3+ root=UUID=be8f8e3a-9
[  +0.000000] x86/fpu: x87 FPU will use FXSAVE
[  +0.000000] e820: BIOS-provided physical RAM map:
[  +0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[  +0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[  +0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003ffddfff] usable
[  +0.000000] BIOS-e820: [mem 0x000000003ffde000-0x000000003fffffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[  +0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000013fffffff] usable

I searched on internet and found the original patches posted for adding
bzImage 64 support into the old kexec loading, which is located in user
space kexec_tools utility made by Yinghai, and Vivek and hpa reviewed
patches.  Still I didn't found out why kernel has to be put at top of
system RAM.  I guess low memory are reserved for system usage mostly,
putting kexec kernel at top is safer and no need to exclude those
resereved regions by system or firmware which we may not find out all of
them, but not very sure about it.

Link: http://lkml.kernel.org/r/20180322033722.9279-3-bhe@xxxxxxxxxx
Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
Cc: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx>
Cc: Dave Young <dyoung@xxxxxxxxxx>
Cc: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Philipp Rudo <prudo@xxxxxxxxxxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 kernel/kexec_file.c |    2 ++
 1 file changed, 2 insertions(+)

diff -puN kernel/kexec_file.c~kexec_file-load-kernel-at-top-of-system-ram-if-required kernel/kexec_file.c
--- a/kernel/kexec_file.c~kexec_file-load-kernel-at-top-of-system-ram-if-required
+++ a/kernel/kexec_file.c
@@ -518,6 +518,8 @@ int __weak arch_kexec_walk_mem(struct ke
 					   IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY,
 					   crashk_res.start, crashk_res.end,
 					   kbuf, func);
+	else if (kbuf->top_down)
+		return walk_system_ram_res_rev(0, ULONG_MAX, kbuf, func);
 	else
 		return walk_system_ram_res(0, ULONG_MAX, kbuf, func);
 }
_

Patches currently in -mm which might be from bhe@xxxxxxxxxx are

mm-sparse-add-a-static-variable-nr_present_sections.patch
mm-sparsemem-defer-the-ms-section_mem_map-clearing.patch
mm-sparse-add-a-new-parameter-data_unit_size-for-alloc_usemap_and_memmap.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux