From: geoff@infradead.org (Geoff Levand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/16] arm64/kexec: Add core kexec support
Date: Mon, 02 Nov 2015 16:30:16 -0800 [thread overview]
Message-ID: <1446510616.23374.3.camel@infradead.org> (raw)
In-Reply-To: <56339ACD.7010506@arm.com>
Hi James,
On Fri, 2015-10-30 at 16:29 +0000, James Morse wrote:
> On 20/10/15 00:38, Geoff Levand wrote:
> > +config KEXEC
> > +> > > > depends on (!SMP || PM_SLEEP_SMP)
>
> Commit 4b3dc9679cf7 got rid of '!SMP'.
Fixed for v11.
> > - * Copyright (C) 2015 Huawei Futurewei Technologies.
> > + * Copyright (C) Huawei Futurewei Technologies.
>
> Move this hunk into the patch that adds the file?
Was fixed in v10.2.
> > +++ b/arch/arm64/kernel/relocate_kernel.S
> If I've followed all this through properly:
>
> With KVM - mmu+caches are configured, but then disabled by 'kvm: allows kvm
> cpu hotplug'. This 'arm64_relocate_new_kernel' function then runs at EL2
> with M=0, C=0, I=0.
>
> Without KVM - when there is no user of EL2, the mmu+caches are left in
> whatever state the bootloader (or efi stub) left them in. From
> Documentation/arm64/booting.txt:
> > Instruction cache may be on or off.
> and
> > System caches which respect the architected cache maintenance by VA
> > operations must be configured and may be enabled.
>
> So 'arm64_relocate_new_kernel' function could run at EL2 with M=0, C=?, I=?.
>
> I think this means you can't guarantee anything you are copying below
> actually makes it through the caches - booting secondary processors may get
> stale values.
>
> The EFI stub disables the M and C bits when booted at EL2 with uefi - but
> it leaves the instruction cache enabled. You only clean the
> reboot_code_buffer from the data cache, so there may be stale values in the
> instruction cache.
>
> I think you need to disable the i-cache at EL1. If you jump to EL2, I think
> you need to disable the I/C bits there too - as you can't rely on the code
> in 'kvm: allows kvm cpu hotplug' to do this in a non-kvm case.
For consistency across all code paths, we could put in something like this:
+ /* Clear SCTLR_ELx_FLAGS. */
+ mrs x0, CurrentEL
+ cmp x0, #CurrentEL_EL2
+ b.ne 1f
+ mrs x0, sctlr_el2
+ ldr x1, =SCTLR_EL2_FLAGS
+ bic x0, x0, x1
+ msr sctlr_el2, x0
+ isb
+ b 2f
+1: mrs x0, sctlr_el1
+ ldr x1, =SCTLR_EL2_FLAGS
+ bic x0, x0, x1
+ msr sctlr_el1, x0
+ isb
> > +.Ldone:
> > +> > > > dsb> > > > sy
> > +> > > > isb
> > +> > > > ic> > > > ialluis
> > +> > > > dsb> > > > sy
>
> Why the second dsb?
I removed the first isb as Mark suggested.
>
> > +> > > > isb
> > +
> > +> > > > /* Start new image. */
> > +> > > > ldr> > > > x4, .Lkimage_start
> > +> > > > mov> > > > x0, xzr
> > +> > > > mov> > > > x1, xzr
> > +> > > > mov> > > > x2, xzr
> > +> > > > mov> > > > x3, xzr
>
> Once the kexec'd kernel is booting, I get:
> > WARNING: x1-x3 nonzero in violation of boot protocol:
> > x1: 0000000080008000
> > x2: 0000000000000020
> > x3: 0000000000000020
> > This indicates a broken bootloader or old kernel
>
> Presumably this 'kimage_start' isn't pointing to the new kernel, but the
> purgatory code, (which comes from user-space?). (If so what are these xzr-s
> for?)
The warning was from the arm64 purgatory in kexec-tools, now fixed.
We don't need to zero the registers anymore. At one time I had
an option where the kernel found the dtb section and jumped
directly to the new image as the 32 bit arm kernel does.
> +/* The machine_kexec routine sets these variables via offsets from
> > + * arm64_relocate_new_kernel.
> > + */
> > +
> > +/*
> > + * .Lkimage_start - Copy of image->start, the entry point of the new
> > + * image.
> > + */
> > +.Lkimage_start:
> > +> > > > .quad> > > > 0x0
> > +
> > +/*
> > + * .Lkimage_head - Copy of image->head, the list of kimage entries.
> > + */
> > +.Lkimage_head:
> > +> > > > .quad> > > > 0x0
> > +
>
> I assume these .quad-s are used because you can't pass the values in via
> registers - due to the complicated soft_restart(). Given you are the only
> user, couldn't you simplify it to do all the disabling in
> arm64_relocate_new_kernel?
I moved some things from cpu_reset to arm64_relocate_new_kernel, but
from what Takahiro has said, to support a modular kvm some of the CPU
shutdown code will be shared. Maybe we can look into simplifying things
once work on modular kvm is started.
>
> From 'kexec -e' to the first messages from the new kernel takes ~1 minute
> on Juno, Did you see a similar delay? Or should I go looking for what I've
> configured wrong!?
As Pratyush has mentioned this is most likely due to the dcaches
being disabled.
> (Copying code with the mmu+caches on, then cleaning to PoC was noticeably
> faster for hibernate)
>
>
> I've used this series for kexec-ing between 4K and 64K page_size kernels on
> Juno.
Thanks for testing.
-Geoff
next prev parent reply other threads:[~2015-11-03 0:30 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 23:38 [PATCH 00/16] arm64 kexec kernel patches v10 Geoff Levand
2015-10-19 23:38 ` [PATCH 08/16] arm64/kexec: Add core kexec support Geoff Levand
2015-10-20 8:56 ` Pratyush Anand
2015-10-20 17:19 ` Geoff Levand
2015-10-23 7:29 ` Pratyush Anand
2015-10-21 18:30 ` [PATCH v10.2 " Geoff Levand
2015-10-30 16:29 ` [PATCH " James Morse
2015-10-30 16:54 ` Mark Rutland
2015-11-02 9:26 ` Pratyush Anand
2015-11-03 0:30 ` Geoff Levand [this message]
2015-10-19 23:38 ` [PATCH 01/16] arm64: Fold proc-macros.S into assembler.h Geoff Levand
2015-10-19 23:38 ` [PATCH 02/16] arm64: Convert hcalls to use HVC immediate value Geoff Levand
2015-10-19 23:38 ` [PATCH 05/16] arm64: Add back cpu_reset routines Geoff Levand
2015-10-19 23:38 ` [PATCH 07/16] Revert "arm64: remove dead code" Geoff Levand
2015-10-19 23:38 ` [PATCH 03/16] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2015-10-19 23:38 ` [PATCH 04/16] arm64: kvm: allows kvm cpu hotplug Geoff Levand
2015-10-20 18:57 ` [PATCH v10.1 " Geoff Levand
2015-10-19 23:38 ` [PATCH 06/16] arm64: Add EL2 switch to cpu_reset Geoff Levand
2015-10-19 23:38 ` [PATCH 14/16] arm64: kdump: update a kernel doc Geoff Levand
2015-10-19 23:38 ` [PATCH 16/16] arm64: kdump: relax BUG_ON() if more than one cpus are still active Geoff Levand
2015-10-19 23:38 ` [PATCH 15/16] arm64: kdump: enable kdump in the arm64 defconfig Geoff Levand
2015-10-19 23:38 ` [PATCH 11/16] arm64: kdump: reserve memory for crash dump kernel Geoff Levand
2015-10-19 23:38 ` [PATCH 10/16] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2015-10-19 23:38 ` [PATCH 13/16] arm64: kdump: add kdump support Geoff Levand
2015-10-22 3:25 ` Dave Young
2015-10-22 4:29 ` AKASHI Takahiro
2015-10-22 5:15 ` Dave Young
2015-10-22 9:57 ` AKASHI Takahiro
2015-10-23 9:50 ` Dave Young
2015-10-29 5:55 ` AKASHI Takahiro
2015-10-29 6:40 ` Dave Young
2015-10-29 6:53 ` AKASHI Takahiro
2015-10-29 7:01 ` Dave Young
2015-10-19 23:38 ` [PATCH 09/16] arm64/kexec: Add pr_devel output Geoff Levand
2015-10-19 23:38 ` [PATCH 12/16] arm64: kdump: implement machine_crash_shutdown() Geoff Levand
2015-10-20 18:54 ` [PATCH v10.1 " 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=1446510616.23374.3.camel@infradead.org \
--to=geoff@infradead.org \
--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;
as well as URLs for NNTP newsgroup(s).