From: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
To: Ralf Baechle <ralf@linux-mips.org>, <linux-mips@linux-mips.org>
Subject: [PATCH 10/10] MIPS: generic/kexec: add support for a DTB passed in a separate buffer
Date: Wed, 23 Nov 2016 14:43:52 +0100 [thread overview]
Message-ID: <1479908632-30392-11-git-send-email-marcin.nowakowski@imgtec.com> (raw)
In-Reply-To: <1479908632-30392-1-git-send-email-marcin.nowakowski@imgtec.com>
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
arch/mips/generic/Makefile | 1 +
arch/mips/generic/kexec.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 arch/mips/generic/kexec.c
diff --git a/arch/mips/generic/Makefile b/arch/mips/generic/Makefile
index 7c66494..acb9b6d 100644
--- a/arch/mips/generic/Makefile
+++ b/arch/mips/generic/Makefile
@@ -13,3 +13,4 @@ obj-y += irq.o
obj-y += proc.o
obj-$(CONFIG_LEGACY_BOARD_SEAD3) += board-sead3.o
+obj-$(CONFIG_KEXEC) += kexec.o
diff --git a/arch/mips/generic/kexec.c b/arch/mips/generic/kexec.c
new file mode 100644
index 0000000..61f812b
--- /dev/null
+++ b/arch/mips/generic/kexec.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kexec.h>
+#include <linux/libfdt.h>
+#include <linux/uaccess.h>
+
+static int generic_kexec_prepare(struct kimage *image)
+{
+ int i;
+
+ for (i = 0; i < image->nr_segments; i++) {
+ struct fdt_header fdt;
+
+ if (image->segment[i].memsz <= sizeof(fdt))
+ continue;
+
+ if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
+ continue;
+
+ if (fdt_check_header(&fdt))
+ continue;
+
+ kexec_args[0] = -2;
+ kexec_args[1] = (unsigned long)
+ phys_to_virt((unsigned long)image->segment[i].mem);
+ break;
+ }
+ return 0;
+}
+
+static int __init register_generic_kexec(void)
+{
+ _machine_kexec_prepare = generic_kexec_prepare;
+ return 0;
+}
+arch_initcall(register_generic_kexec);
+
--
2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
To: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: [PATCH 10/10] MIPS: generic/kexec: add support for a DTB passed in a separate buffer
Date: Wed, 23 Nov 2016 14:43:52 +0100 [thread overview]
Message-ID: <1479908632-30392-11-git-send-email-marcin.nowakowski@imgtec.com> (raw)
Message-ID: <20161123134352.QncX6veapGSRpNBFakzpCOy4UHUmBYWIh3J2oJu2kzU@z> (raw)
In-Reply-To: <1479908632-30392-1-git-send-email-marcin.nowakowski@imgtec.com>
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
arch/mips/generic/Makefile | 1 +
arch/mips/generic/kexec.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 arch/mips/generic/kexec.c
diff --git a/arch/mips/generic/Makefile b/arch/mips/generic/Makefile
index 7c66494..acb9b6d 100644
--- a/arch/mips/generic/Makefile
+++ b/arch/mips/generic/Makefile
@@ -13,3 +13,4 @@ obj-y += irq.o
obj-y += proc.o
obj-$(CONFIG_LEGACY_BOARD_SEAD3) += board-sead3.o
+obj-$(CONFIG_KEXEC) += kexec.o
diff --git a/arch/mips/generic/kexec.c b/arch/mips/generic/kexec.c
new file mode 100644
index 0000000..61f812b
--- /dev/null
+++ b/arch/mips/generic/kexec.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kexec.h>
+#include <linux/libfdt.h>
+#include <linux/uaccess.h>
+
+static int generic_kexec_prepare(struct kimage *image)
+{
+ int i;
+
+ for (i = 0; i < image->nr_segments; i++) {
+ struct fdt_header fdt;
+
+ if (image->segment[i].memsz <= sizeof(fdt))
+ continue;
+
+ if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
+ continue;
+
+ if (fdt_check_header(&fdt))
+ continue;
+
+ kexec_args[0] = -2;
+ kexec_args[1] = (unsigned long)
+ phys_to_virt((unsigned long)image->segment[i].mem);
+ break;
+ }
+ return 0;
+}
+
+static int __init register_generic_kexec(void)
+{
+ _machine_kexec_prepare = generic_kexec_prepare;
+ return 0;
+}
+arch_initcall(register_generic_kexec);
+
--
2.7.4
next prev parent reply other threads:[~2016-11-23 13:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 13:43 [PATCH 00/10] various fixes for kexec crashkernel support Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 01/10] MIPS: do not request resources for crashkernel if one isn't defined Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 02/10] MIPS: init: ensure reserved memory regions are not added to bootmem Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 03/10] MIPS: init: ensure bootmem does not corrupt reserved memory Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 04/10] MIPS: use early_init_fdt_reserve_self to protect DTB location Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 05/10] MIPS: platform: allow for DTB to be moved during kernel relocation Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 06/10] MIPS: relocate: optionally relocate the DTB Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 07/10] MIPS: fix mem=X@Y commandline processing Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 08/10] MIPS: kexec: do not reserve invalid crashkernel memory on boot Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` [PATCH 09/10] MIPS: kexec: add debug info about the new kexec'ed image Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski
2016-11-23 13:43 ` Marcin Nowakowski [this message]
2016-11-23 13:43 ` [PATCH 10/10] MIPS: generic/kexec: add support for a DTB passed in a separate buffer Marcin Nowakowski
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=1479908632-30392-11-git-send-email-marcin.nowakowski@imgtec.com \
--to=marcin.nowakowski@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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