[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180507063224.24229-4-bhe@redhat.com>
Date: Mon, 7 May 2018 14:32:24 +0800
From: Baoquan He <bhe@...hat.com>
To: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
robh+dt@...nel.org, dan.j.williams@...el.com,
nicolas.pitre@...aro.org, josh@...htriplett.org,
fengguang.wu@...el.com, bp@...e.de
Cc: patrik.r.jakobsson@...il.com, airlied@...ux.ie, kys@...rosoft.com,
haiyangz@...rosoft.com, sthemmin@...rosoft.com,
dmitry.torokhov@...il.com, frowand.list@...il.com,
keith.busch@...el.com, jonathan.derrick@...el.com,
lorenzo.pieralisi@....com, bhelgaas@...gle.com, tglx@...utronix.de,
brijesh.singh@....com, jglisse@...hat.com, thomas.lendacky@....com,
gregkh@...uxfoundation.org, baiyaowei@...s.chinamobile.com,
richard.weiyang@...il.com, devel@...uxdriverproject.org,
linux-input@...r.kernel.org, linux-nvdimm@...ts.01.org,
devicetree@...r.kernel.org, linux-pci@...r.kernel.org,
ebiederm@...ssion.com, vgoyal@...hat.com, dyoung@...hat.com,
yinghai@...nel.org, kexec@...ts.infradead.org, monstr@...str.eu,
davem@...emloft.net, chris@...kel.net, jcmvbkbc@...il.com,
gustavo@...ovan.org, maarten.lankhorst@...ux.intel.com,
seanpaul@...omium.org, linux-parisc@...r.kernel.org,
Baoquan He <bhe@...hat.com>
Subject: [PATCH v4 3/3] kexec_file: 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 what we have been doing all along in the old kexec
loading interface and the kexec loading is still default setting in some
distributions. However, the current kexec_file loading interface doesn't
do likt this. The function arch_kexec_walk_mem() it calls ignores checking
kexec_buf.top_down, but calls walk_system_ram_res() directly to go through
all resources of System RAM from bottom to up, to try to find memory region
which can contain the specific kexec buffer, then call locate_mem_hole_callback()
to allocate memory in that found memory region from top to down. This brings
confusion especially when KASLR is widely supported , users have to make clear
why kexec/kdump kernel loading position is different between these two
interfaces in order to exclude unnecessary noises. Hence these two interfaces
need be unified on behaviour.
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.
Signed-off-by: Baoquan He <bhe@...hat.com>
Cc: Eric Biederman <ebiederm@...ssion.com>
Cc: Vivek Goyal <vgoyal@...hat.com>
Cc: Dave Young <dyoung@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Yinghai Lu <yinghai@...nel.org>
Cc: kexec@...ts.infradead.org
---
kernel/kexec_file.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 75d8e7cf040e..7a66d9d5a534 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -518,6 +518,8 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
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);
}
--
2.13.6
Powered by blists - more mailing lists