From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/8] arm64/kexec: Add core kexec support
Date: Mon, 26 Jan 2015 19:16:20 +0000 [thread overview]
Message-ID: <20150126191620.GP23313@leverpostej> (raw)
In-Reply-To: <a5c232448c1d8fa1da73a9005fa9f3927c635578.1421449714.git.geoff@infradead.org>
On Sat, Jan 17, 2015 at 12:23:34AM +0000, Geoff Levand wrote:
> Add three new files, kexec.h, machine_kexec.c and relocate_kernel.S to the
> arm64 architecture that add support for the kexec re-boot mechanism
> (CONFIG_KEXEC) on arm64 platforms.
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> arch/arm64/Kconfig | 9 ++
> arch/arm64/include/asm/kexec.h | 47 +++++++++++
> arch/arm64/kernel/Makefile | 1 +
> arch/arm64/kernel/machine_kexec.c | 155 ++++++++++++++++++++++++++++++++++
> arch/arm64/kernel/relocate_kernel.S | 160 ++++++++++++++++++++++++++++++++++++
> include/uapi/linux/kexec.h | 1 +
> 6 files changed, 373 insertions(+)
> create mode 100644 arch/arm64/include/asm/kexec.h
> create mode 100644 arch/arm64/kernel/machine_kexec.c
> create mode 100644 arch/arm64/kernel/relocate_kernel.S
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b1f9a20..d9eb9cd 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -474,6 +474,15 @@ config SECCOMP
> and the task is only allowed to execute a few safe syscalls
> defined by each seccomp mode.
>
> +config KEXEC
> + depends on (!SMP || PM_SLEEP_SMP)
> + bool "kexec system call"
> + ---help---
> + kexec is a system call that implements the ability to shutdown your
> + current kernel, and to start another kernel. It is like a reboot
> + but it is independent of the system firmware. And like a reboot
> + you can start any kernel with it, not just Linux.
> +
[...]
> +/**
> + * kexec_is_dtb - Helper routine to check the device tree header signature.
> + */
> +static bool kexec_is_dtb(const void *dtb)
> +{
> + __be32 magic;
> +
> + return get_user(magic, (__be32 *)dtb) ? false :
> + (be32_to_cpu(magic) == OF_DT_HEADER);
> +}
> +
> +/**
> + * kexec_find_dtb_seg - Helper routine to find the dtb segment.
> + */
> +static const struct kexec_segment *kexec_find_dtb_seg(
> + const struct kimage *image)
> +{
> + int i;
> +
> + for (i = 0; i < image->nr_segments; i++) {
> + if (kexec_is_dtb(image->segment[i].buf))
> + return &image->segment[i];
> + }
> +
> + return NULL;
> +}
As mentioned before, _please_ move the dtb handling to the
userspace-provided purgatory. It would be far better to get userspace to
handle setting up the dtb pointer explicitly. That avoids fragility
w.r.t. policy here as userspace will get exactly what it asked for,
nothing more, nothing less.
The fact that this is done on 32-bit arm does not mean that we must do
it here.
[...]
> + /* Start new image. */
> + ldr x4, arm64_kexec_kimage_start
> + ldr x0, arm64_kexec_dtb_addr
> + mov x1, xzr
> + mov x2, xzr
> + mov x3, xzr
> + br x4
Likewise, this should be part of the userspace-provided purgatory code.
If we're staying true to "like a reboot you can start any kernel with
it, not just Linux", we shouldn't embed the Linux boot protocol here.
Mark.
next prev parent reply other threads:[~2015-01-26 19:16 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1415926876.git.geoff@infradead.orgg>
2015-01-17 0:23 ` [PATCH 0/8] arm64 kexec kernel patches V7 Geoff Levand
2015-01-17 0:23 ` [PATCH 5/8] arm64/kexec: Add core kexec support Geoff Levand
2015-01-26 19:16 ` Mark Rutland [this message]
2015-01-17 0:23 ` [PATCH 7/8] arm64/kexec: Add checks for KVM Geoff Levand
2015-01-26 19:19 ` Mark Rutland
2015-01-26 20:39 ` Christoffer Dall
2015-01-26 20:58 ` Geoff Levand
2015-01-26 21:00 ` Geoff Levand
2015-01-29 9:36 ` AKASHI Takahiro
2015-01-29 9:57 ` AKASHI Takahiro
2015-01-29 10:59 ` Marc Zyngier
2015-01-29 18:47 ` Mark Rutland
2015-01-30 6:10 ` AKASHI Takahiro
2015-01-30 12:14 ` Mark Rutland
2015-01-30 19:48 ` Geoff Levand
2015-02-02 8:18 ` AKASHI Takahiro
2015-02-06 0:11 ` Geoff Levand
2015-02-06 4:18 ` AKASHI Takahiro
2015-02-06 7:06 ` Geoff Levand
2015-01-17 0:23 ` [PATCH 2/8] arm64: Convert hcalls to use ISS field Geoff Levand
2015-01-26 18:26 ` Catalin Marinas
2015-01-30 23:31 ` Geoff Levand
2015-02-02 16:04 ` Catalin Marinas
2015-01-30 23:33 ` [PATCH v2 " Geoff Levand
2015-02-19 20:57 ` Christoffer Dall
2015-02-25 22:09 ` Geoff Levand
2015-03-02 22:13 ` Christoffer Dall
2015-03-02 23:22 ` Geoff Levand
2015-03-03 21:47 ` Christopher Covington
2015-03-03 22:35 ` Geoff Levand
2015-01-17 0:23 ` [PATCH 8/8] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2015-01-17 0:23 ` [PATCH 6/8] arm64/kexec: Add pr_devel output Geoff Levand
2015-01-17 0:23 ` [PATCH 3/8] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2015-01-27 17:39 ` Catalin Marinas
2015-01-27 18:00 ` Mark Rutland
2015-01-30 21:52 ` Geoff Levand
2015-01-17 0:23 ` [PATCH 1/8] arm64: Move proc-macros.S to include/asm Geoff Levand
2015-01-26 17:45 ` Catalin Marinas
2015-01-27 19:33 ` [PATCH V2 1/8] arm64: Fold proc-macros.S into assembler.h Geoff Levand
2015-01-17 0:23 ` [PATCH 4/8] arm64: Add EL2 switch to soft_restart Geoff Levand
2015-01-26 19:02 ` Mark Rutland
2015-01-26 21:48 ` Geoff Levand
2015-01-27 16:46 ` Mark Rutland
2015-01-27 18:34 ` Geoff Levand
2015-01-27 17:57 ` Catalin Marinas
2015-01-30 21:47 ` Geoff Levand
2015-01-26 17:44 ` [PATCH 0/8] arm64 kexec kernel patches V7 Catalin Marinas
2015-01-26 18:37 ` Grant Likely
2015-01-26 18:55 ` Mark Rutland
2015-01-26 20:57 ` Geoff Levand
2014-11-14 1:22 [PATCH 0/8] arm64 kexec kernel patches V6 Geoff Levand
2014-11-14 1:22 ` [PATCH 5/8] arm64/kexec: Add core kexec support Geoff Levand
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=20150126191620.GP23313@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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