All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Baoquan He <bhe@redhat.com>,
	Eric Biederman <ebiederm@xmission.com>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yinghai Lu <yinghai@kernel.org>,
	kexec@lists.infradead.org
Subject: [PATCH v2 3/3] kexec_file: Load kernel at top of system RAM if required
Date: Sun,  8 Apr 2018 10:47:24 +0800	[thread overview]
Message-ID: <20180408024724.16812-4-bhe@redhat.com> (raw)
In-Reply-To: <20180408024724.16812-1-bhe@redhat.com>

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. 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@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: kexec@lists.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 57ec39995b23..76e6307f8971 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -445,6 +445,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

WARNING: multiple messages have this Message-ID (diff)
From: Baoquan He <bhe@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Baoquan He <bhe@redhat.com>, Dave Young <dyoung@redhat.com>,
	kexec@lists.infradead.org, Eric Biederman <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yinghai Lu <yinghai@kernel.org>, Vivek Goyal <vgoyal@redhat.com>
Subject: [PATCH v2 3/3] kexec_file: Load kernel at top of system RAM if required
Date: Sun,  8 Apr 2018 10:47:24 +0800	[thread overview]
Message-ID: <20180408024724.16812-4-bhe@redhat.com> (raw)
In-Reply-To: <20180408024724.16812-1-bhe@redhat.com>

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. 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@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: kexec@lists.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 57ec39995b23..76e6307f8971 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -445,6 +445,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


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2018-04-08  2:48 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-08  2:47 [PATCH v2 0/3] resource: Use list_head to link sibling resource Baoquan He
2018-04-08  2:47 ` [PATCH v2 1/3] " Baoquan He
2018-04-08  2:47   ` Baoquan He
2018-04-08  2:47   ` Baoquan He
2018-04-08  2:47   ` Baoquan He
2018-04-08  4:12   ` kbuild test robot
2018-04-08  4:12     ` kbuild test robot
2018-04-08  4:12     ` kbuild test robot
2018-04-08  4:12     ` kbuild test robot
2018-04-08  9:09     ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-08  5:55   ` kbuild test robot
2018-04-08  5:55     ` kbuild test robot
2018-04-08  5:55     ` kbuild test robot
2018-04-08  5:55     ` kbuild test robot
2018-04-08  9:09     ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-08  9:09       ` Baoquan He
2018-04-09  9:08   ` [PATCH v3 1/3] resource: Use list_head to link resource sibling Baoquan He
2018-04-09  9:08     ` Baoquan He
2018-04-09  9:08     ` Baoquan He
2018-04-09 14:49     ` Rob Herring
2018-04-09 14:49       ` Rob Herring
2018-04-09 14:49       ` Rob Herring
2018-04-09 16:05       ` Nicolas Pitre
2018-04-09 16:05         ` Nicolas Pitre
2018-04-09 16:05         ` Nicolas Pitre
2018-04-09 16:05         ` Nicolas Pitre
2018-04-10 13:44       ` Baoquan He
2018-04-10 13:44         ` Baoquan He
2018-04-10 13:44         ` Baoquan He
2018-04-10 13:44         ` Baoquan He
2018-04-11  3:22         ` Wei Yang
2018-04-11  3:22           ` Wei Yang
2018-04-11  3:22           ` Wei Yang
2018-04-09 15:38     ` Dan Williams
2018-04-09 15:38       ` Dan Williams
2018-04-09 15:38       ` Dan Williams
2018-04-10  2:10       ` Baoquan He
2018-04-10  2:10         ` Baoquan He
2018-04-10  2:10         ` Baoquan He
2018-04-10  2:10         ` Baoquan He
2018-04-10  2:34         ` Dan Williams
2018-04-10  2:34           ` Dan Williams
2018-04-10  2:34           ` Dan Williams
2018-04-10  2:34           ` Dan Williams
2018-04-10  2:49           ` Baoquan He
2018-04-10  2:49             ` Baoquan He
2018-04-10  2:49             ` Baoquan He
2018-04-10  2:49             ` Baoquan He
2018-04-08  2:47 ` [PATCH v2 2/3] resource: add walk_system_ram_res_rev() Baoquan He
2018-04-08  2:47 ` Baoquan He [this message]
2018-04-08  2:47   ` [PATCH v2 3/3] kexec_file: Load kernel at top of system RAM if required Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180408024724.16812-4-bhe@redhat.com \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgoyal@redhat.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.