From: Matthew McClintock <msm@freescale.com>
To: kexec@lists.infradead.org
Cc: Matthew McClintock <msm@freescale.com>, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 3/7] Update uImage to support crash kernel and misc fixes
Date: Tue, 20 Jul 2010 15:14:56 -0500 [thread overview]
Message-ID: <1279656900-27458-3-git-send-email-msm@freescale.com> (raw)
In-Reply-To: <1279656900-27458-2-git-send-email-msm@freescale.com>
Use current command line if none given, specifically useful for
when arguments are added causing the use of the current cmdline
to not occur.
We also try to load the dtb above the kernel, this is useful for
relocatable kernels where they device tree needs to reside just
above the kernel base address.
Only allocate 1 MiB extra for bss space after kernel as it appears
to be more than adequate.
Signed-off-by: Matthew McClintock <msm@freescale.com>
---
kexec/arch/ppc/kexec-uImage-ppc.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
index 4a8d28d..21a7c1b 100644
--- a/kexec/arch/ppc/kexec-uImage-ppc.c
+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
@@ -10,6 +10,7 @@
#include <getopt.h>
#include <arch/options.h>
#include "../../kexec.h"
+#include "../../kexec-syscall.h"
#include "kexec-ppc.h"
#include "fixup_dtb.h"
#include <kexec-uImage.h>
@@ -45,7 +46,7 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
off_t len, struct kexec_info *info, unsigned int load_addr,
unsigned int ep)
{
- char *command_line;
+ char *command_line, *cmdline_buf;
int command_line_len;
char *dtb;
unsigned int addr;
@@ -56,6 +57,7 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
int opt;
int ret;
+ cmdline_buf = NULL;
command_line = NULL;
dtb = NULL;
@@ -89,24 +91,34 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
}
command_line_len = 0;
- if (command_line)
+ if (command_line) {
+ command_line_len = strlen(command_line) + 1;
+ } else {
+ command_line = get_command_line();
command_line_len = strlen(command_line) + 1;
+ }
fixup_nodes[cur_fixup] = NULL;
/*
* len contains the length of the whole kernel image except the bss
- * section. The 3 MiB should cover it. The purgatory and the dtb are
+ * section. The 1 MiB should cover it. The purgatory and the dtb are
* allocated from memtop down towards zero so we should never get too
* close to the bss :)
*/
- ret = valid_memory_range(info, load_addr, len + 3 * 1024 * 1024);
+ ret = valid_memory_range(info, load_addr, load_addr + (len + (1 * 1024 * 1024)));
if (!ret) {
printf("Can't add kernel to addr 0x%08x len %ld\n",
- load_addr, len + 3 * 1024 * 1024);
+ load_addr, len + (1 * 1024 * 1024));
return -1;
}
- add_segment(info, buf, len, load_addr, len + 3 * 1024 * 1024);
+ add_segment(info, buf, len, load_addr, len + (1 * 1024 * 1024));
+
+ cmdline_buf = xmalloc(COMMAND_LINE_SIZE);
+ memset((void *)cmdline_buf, 0, COMMAND_LINE_SIZE);
+ if (command_line)
+ strncat(cmdline_buf, command_line, command_line_len);
+
if (dtb) {
char *blob_buf;
off_t blob_size = 0;
@@ -115,10 +127,9 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
blob_buf = slurp_file(dtb, &blob_size);
if (!blob_buf || !blob_size)
die("Device tree seems to be an empty file.\n");
- blob_buf = fixup_dtb_nodes(blob_buf, &blob_size, fixup_nodes, command_line);
-
- dtb_addr = add_buffer(info, blob_buf, blob_size, blob_size, 0, 0,
- KERNEL_ACCESS_TOP, -1);
+ blob_buf = fixup_dtb_nodes(blob_buf, &blob_size, fixup_nodes, cmdline_buf);
+ dtb_addr = add_buffer(info, blob_buf, blob_size, blob_size, 0, load_addr,
+ load_addr + KERNEL_ACCESS_TOP, -1);
} else {
dtb_addr = 0;
}
@@ -142,6 +153,7 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
addr = elf_rel_get_addr(&info->rhdr, "purgatory_start");
info->entry = (void *)addr;
+
return 0;
}
--
1.6.0.6
next prev parent reply other threads:[~2010-07-20 20:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-20 20:14 [PATCH v2 1/7] Restore kexec uImage-ppc to working state Matthew McClintock
2010-07-20 20:14 ` [PATCH v2 2/7] Fix case where phys_addr_t != unsigned long when reading proc entries Matthew McClintock
2010-07-20 20:14 ` Matthew McClintock [this message]
2010-07-20 20:14 ` [PATCH v2 4/7] Update Elf-ppc to support crash kernel and misc fixes Matthew McClintock
2010-07-20 20:14 ` [PATCH v2 5/7] Add support for ramdisk on ppc32 for uImage-ppc and Elf-ppc Matthew McClintock
2010-07-20 20:14 ` [PATCH v2 6/7] Add support for reworking flat device tree support Matthew McClintock
2010-07-20 20:15 ` [PATCH v2 7/7] Add documentation/howto for mpc85xx systems Matthew McClintock
2010-07-29 8:33 ` [PATCH v2 5/7] Add support for ramdisk on ppc32 for uImage-ppc and Elf-ppc Simon Horman
2010-07-29 16:03 ` Matthew McClintock
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=1279656900-27458-3-git-send-email-msm@freescale.com \
--to=msm@freescale.com \
--cc=kexec@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).