From: James Morse <james.morse@arm.com>
To: Geoff Levand <geoff@infradead.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
marc.zyngier@arm.com, Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v14 12/20] arm64/kexec: Add core kexec support
Date: Fri, 11 Mar 2016 11:37:54 +0000 [thread overview]
Message-ID: <56E2AE12.4020604@arm.com> (raw)
In-Reply-To: <cdab8a2001a9f8beb605bfcd565201c37dad78e6.1457135058.git.geoff@infradead.org>
Hi Geoff,
On 04/03/16 23:51, 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>
> diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> new file mode 100644
> index 0000000..6fd0f0c
> --- /dev/null
> +++ b/arch/arm64/kernel/machine_kexec.c
[ ... snip ... ]
> +/**
> + * kexec_list_flush - Helper to flush the kimage list to PoC.
> + */
> +static void kexec_list_flush(struct kimage *kimage)
> +{
> + kimage_entry_t *entry;
> + unsigned int flag;
> +
> + for (entry = &kimage->head, flag = 0; flag != IND_DONE; entry++) {
> + void *addr = kmap(phys_to_page(*entry & PAGE_MASK));
Isn't kmap() only needed for highmem? All memory should be accessible via the
linear map, so this could just be a call to phys_to_virt(), without the
intermediate page step.
> +
> + flag = *entry & IND_FLAGS;
> +
> + switch (flag) {
> + case IND_INDIRECTION:
> + entry = (kimage_entry_t *)addr - 1;
> + __flush_dcache_area(addr, PAGE_SIZE);
> + break;
> + case IND_DESTINATION:
> + break;
> + case IND_SOURCE:
> + __flush_dcache_area(addr, PAGE_SIZE);
> + break;
> + case IND_DONE:
> + break;
> + default:
> + BUG();
> + }
> + kunmap(addr);
> + }
> +}
> +
> +/**
> + * kexec_segment_flush - Helper to flush the kimage segments to PoC.
> + */
> +static void kexec_segment_flush(const struct kimage *kimage)
> +{
> + unsigned long i;
> +
> + pr_devel("%s:\n", __func__);
> +
> + for (i = 0; i < kimage->nr_segments; i++) {
> + pr_devel(" segment[%lu]: %016lx - %016lx, %lx bytes, %lu pages\n",
> + i,
> + kimage->segment[i].mem,
> + kimage->segment[i].mem + kimage->segment[i].memsz,
> + kimage->segment[i].memsz,
> + kimage->segment[i].memsz / PAGE_SIZE);
> +
> + __flush_dcache_area(phys_to_virt(kimage->segment[i].mem),
> + kimage->segment[i].memsz);
> + }
> +}
> +
> +/**
> + * machine_kexec - Do the kexec reboot.
> + *
> + * Called from the core kexec code for a sys_reboot with LINUX_REBOOT_CMD_KEXEC.
> + */
> +void machine_kexec(struct kimage *kimage)
> +{
> + phys_addr_t reboot_code_buffer_phys;
> + void *reboot_code_buffer;
> +
> + BUG_ON(num_online_cpus() > 1);
> +
> + reboot_code_buffer_phys = page_to_phys(kimage->control_code_page);
> + reboot_code_buffer = kmap(kimage->control_code_page);
page_address()?
> +
> + /*
> + * Copy arm64_relocate_new_kernel to the reboot_code_buffer for use
> + * after the kernel is shut down.
> + */
> + memcpy(reboot_code_buffer, arm64_relocate_new_kernel,
> + arm64_relocate_new_kernel_size);
> +
> + /* Flush the reboot_code_buffer in preparation for its execution. */
> + __flush_dcache_area(reboot_code_buffer, arm64_relocate_new_kernel_size);
> + flush_icache_range((uintptr_t)reboot_code_buffer,
> + arm64_relocate_new_kernel_size);
> +
> + /* Flush the kimage list. */
> + kexec_list_flush(kimage);
> +
> + /* Flush the new image if already in place. */
> + if (kimage->head & IND_DONE)
> + kexec_segment_flush(kimage);
> +
> + pr_info("Bye!\n");
> +
> + /* Disable all DAIF exceptions. */
> + asm volatile ("msr daifset, #0xf" : : : "memory");
> +
> + cpu_install_idmap();
> +
> + /*
> + * cpu_soft_restart will shutdown the MMU, disable data caches, then
> + * transfer control to the reboot_code_buffer which contains a copy of
> + * the arm64_relocate_new_kernel routine. arm64_relocate_new_kernel
> + * uses physical addressing to relocate the new image to its final
> + * position and transfers control to the image entry point when the
> + * relocation is complete.
> + */
> +
> + cpu_soft_restart(is_hyp_mode_available(),
> + reboot_code_buffer_phys, kimage->head, kimage_start, 0);
> +
> + BUG(); /* Should never get here. */
> +}
> +
> +void machine_crash_shutdown(struct pt_regs *regs)
> +{
> + /* Empty routine needed to avoid build errors. */
> +}
Thanks!
James
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2016-03-11 11:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 23:51 [PATCH v14 00/20] arm64 kexec kernel patches v14 Geoff Levand
2016-03-04 23:51 ` [PATCH v14 02/20] arm64: Cleanup SCTLR flags Geoff Levand
2016-03-04 23:51 ` [PATCH v14 11/20] Revert "arm64: remove dead code" Geoff Levand
2016-03-04 23:51 ` [PATCH v14 06/20] arm64: kernel: Include _AC definition in page.h Geoff Levand
2016-03-04 23:51 ` [PATCH v14 10/20] Revert "arm64: mm: remove unused cpu_set_idmap_tcr_t0sz function" Geoff Levand
2016-03-04 23:51 ` [PATCH v14 01/20] arm64: Fold proc-macros.S into assembler.h Geoff Levand
2016-03-04 23:51 ` [PATCH v14 09/20] arm64: Add back cpu_reset routines Geoff Levand
2016-03-04 23:51 ` [PATCH v14 05/20] arm64: kvm: allows kvm cpu hotplug Geoff Levand
2016-03-04 23:51 ` [PATCH v14 04/20] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2016-03-04 23:51 ` [PATCH v14 07/20] arm64: Promote KERNEL_START/KERNEL_END definitions to a header file Geoff Levand
2016-03-04 23:51 ` [PATCH v14 03/20] arm64: Convert hcalls to use HVC immediate value Geoff Levand
2016-03-04 23:51 ` [PATCH v14 12/20] arm64/kexec: Add core kexec support Geoff Levand
2016-03-11 11:37 ` James Morse [this message]
2016-03-04 23:51 ` [PATCH v14 08/20] arm64: Add new asm macro copy_page Geoff Levand
2016-03-04 23:51 ` [PATCH v14 18/20] arm64: kdump: add kdump support Geoff Levand
2016-03-04 23:51 ` [PATCH v14 13/20] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2016-03-04 23:51 ` [PATCH v14 16/20] arm64: limit memory regions based on DT property, usable-memory Geoff Levand
2016-03-04 23:51 ` [PATCH v14 20/20] arm64: kdump: update a kernel doc Geoff Levand
2016-03-04 23:51 ` [PATCH v14 14/20] arm64/kexec: Add pr_debug output Geoff Levand
2016-03-11 11:39 ` James Morse
2016-03-04 23:51 ` [PATCH v14 15/20] arm64: kdump: reserve memory for crash dump kernel Geoff Levand
2016-03-04 23:51 ` [PATCH v14 17/20] arm64: kdump: implement machine_crash_shutdown() Geoff Levand
2016-03-04 23:51 ` [PATCH v14 19/20] arm64: kdump: enable kdump in the arm64 defconfig Geoff Levand
2016-03-07 22:25 ` [PATCH v14 00/20] arm64 kexec kernel patches v14 Azriel Samson
2016-03-07 23:35 ` Geoff Levand
2016-03-08 0:23 ` AKASHI Takahiro
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=56E2AE12.4020604@arm.com \
--to=james.morse@arm.com \
--cc=catalin.marinas@arm.com \
--cc=geoff@infradead.org \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=takahiro.akashi@linaro.org \
--cc=will.deacon@arm.com \
/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