From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 15/16] arm64: kernel: Add support for hibernate/suspend-to-disk
Date: Mon, 25 Apr 2016 10:19:11 +0100 [thread overview]
Message-ID: <571DE10F.10905@arm.com> (raw)
In-Reply-To: <20160422102954.GB2998@e104818-lin.cambridge.arm.com>
Hi Catalin,
Thanks for your comments,
On 22/04/16 11:29, Catalin Marinas wrote:
> On Fri, Apr 01, 2016 at 05:53:39PM +0100, James Morse wrote:
>> --- /dev/null
>> +++ b/arch/arm64/kernel/hibernate-asm.S
>> + copy_page x0, x1, x2, x3, x4, x5, x6, x7, x8, x9
>> +
>> + add x1, x10, #PAGE_SIZE
>> + /* Clean the copied page to PoU - based on flush_icache_range() */
>> + dcache_line_size x2, x3
>> + sub x3, x2, #1
>> + bic x4, x10, x3
>> +2: dc cvau, x4 /* clean D line / unified line */
>> + add x4, x4, x2
>> + cmp x4, x1
>> + b.lo 2b
>> +
>> + ldr x19, [x19, #HIBERN_PBE_NEXT]
>> + cbnz x19, 1b
>> +
>> +
>> + /* switch to the restored kernels page tables, to reconfigure el2 */
>> + msr ttbr1_el1, x21 /* physical address of swapper page tables */
>> + isb
>> + tlbi vmalle1is /* invalidate intermediate caching entries */
>> + ic ialluis
>> + dsb ish /* also waits for PoU cleaning to finish */
>> + isb
>
> The waiting for PoU cleaning needs to happen before the IC instruction.
Done, to check I understand why:
The 'ic ialluis' may finish before the PoU cleaning, sharing a barrier means in
this case we may speculatively load stale values back into the icache while we
wait for the cleaning to finish.
[ ... ]
>> +
>> + /* Load our new page tables */
>> + asm volatile("msr ttbr0_el1, %0;"
>> + "isb;"
>> + "tlbi vmalle1is;"
>> + "dsb ish" : : "r"(virt_to_phys(pgd)));
>
> Do we expect anything to have used ttbr0_el1 at this point?
EFI for the virt_efi_get_time() call when we setup the rtc. There may also be
device drivers out there that try to load firmware before the
late_initcall_sync() call that triggers resume.
[ ... ]
>> +int swsusp_arch_suspend(void)
>> +{
>> + int ret = 0;
>> + unsigned long flags;
>> + struct sleep_stack_data state;
>> +
>> + local_dbg_save(flags);
>> +
>> + if (__cpu_suspend_enter(&state)) {
>> + ret = swsusp_save();
>> + } else {
>> + void *lm_kernel_start;
>> +
>> + /* Clean kernel to PoC for secondary core startup */
>> + lm_kernel_start = LMADDR(KERNEL_START);
>> + __flush_dcache_area(lm_kernel_start, KERNEL_END - KERNEL_START);
>
> We don't need to use LMADDR here. The KERNEL_START is already mapped at
> the caches are PIPT (-like), so flushing any of the aliases would do.
With kaslr the range KERNEL_START -> KERNEL_END has holes in it. I think this is
where the __init text or alternatives used to be. Cleaning the corresponding
range in the linear map avoids the fault...
> But I'm not sure we even need to flush the whole kernel. The secondary
> cores would only execute certain areas before they enable the MMU, at
> which point they have visibility over the whole cache. Is this needed
> for secondary core startup on resume from hibernate?
I haven't hit this as an issue, but I think its needed for any mmu-off code.
The list is:
* secondary startup after resume
* hyp-stub and kvm's el2-init code,
* and cpu_resume() (if a core goes into idle soon after resume).
I agree cleaning the whole kernel is excessive. I guess the right thing to do is
to collect all these functions into a single section and clean that.
[ ... ]
Thanks for the detailed comments!
James
next prev parent reply other threads:[~2016-04-25 9:19 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 16:53 [PATCH v7 00/16] arm64: kernel: Add support for hibernate/suspend-to-disk James Morse
2016-04-01 16:53 ` [PATCH v7 01/16] arm64: KVM: Register CPU notifiers when the kernel runs at HYP James Morse
2016-04-18 16:10 ` Catalin Marinas
2016-04-19 8:58 ` James Morse
2016-04-19 14:39 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 02/16] arm64: Fold proc-macros.S into assembler.h James Morse
2016-04-18 16:11 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 03/16] arm64: Cleanup SCTLR flags James Morse
2016-04-19 14:44 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 04/16] arm64: kvm: Move the do_el2_call macro to a header file James Morse
2016-04-19 15:02 ` Marc Zyngier
2016-04-19 15:05 ` James Morse
2016-04-19 15:10 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 05/16] arm64: kvm: Move lr save/restore from do_el2_call into EL1 James Morse
2016-04-19 15:11 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 06/16] arm64: hyp/kvm: Extend hyp-stub API to allow function calls at EL2 James Morse
2016-04-19 15:22 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 07/16] arm64: kvm: allows kvm cpu hotplug James Morse
2016-04-19 16:03 ` Marc Zyngier
2016-04-19 17:37 ` James Morse
2016-04-20 10:29 ` AKASHI Takahiro
2016-04-20 11:19 ` James Morse
2016-04-20 10:37 ` Marc Zyngier
2016-04-20 11:19 ` James Morse
2016-04-20 11:46 ` Marc Zyngier
2016-04-25 8:41 ` AKASHI Takahiro
2016-04-25 9:16 ` James Morse
2016-04-25 9:28 ` Marc Zyngier
2016-04-01 16:53 ` [PATCH v7 08/16] arm64: kernel: Rework finisher callback out of __cpu_suspend_enter() James Morse
2016-04-18 17:20 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 09/16] arm64: Change cpu_resume() to enable mmu early then access sleep_sp by va James Morse
2016-04-20 16:24 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 10/16] arm64: kernel: Include _AC definition in page.h James Morse
2016-04-20 16:25 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 11/16] arm64: Promote KERNEL_START/KERNEL_END definitions to a header file James Morse
2016-04-20 16:26 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 12/16] arm64: Add new asm macro copy_page James Morse
2016-04-20 16:38 ` Catalin Marinas
2016-04-20 16:56 ` James Morse
2016-04-01 16:53 ` [PATCH v7 13/16] arm64: head.S: el2_setup() to accept sctlr_el1 as an argument James Morse
2016-04-20 17:12 ` Catalin Marinas
2016-04-20 17:35 ` James Morse
2016-04-22 10:36 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 14/16] PM / Hibernate: Call flush_icache_range() on pages restored in-place James Morse
2016-04-20 17:16 ` Catalin Marinas
2016-04-01 16:53 ` [PATCH v7 15/16] arm64: kernel: Add support for hibernate/suspend-to-disk James Morse
2016-04-22 10:29 ` Catalin Marinas
2016-04-25 9:19 ` James Morse [this message]
2016-04-01 16:53 ` [PATCH v7 16/16] arm64: hibernate: Prevent resume from a different kernel version James Morse
2016-04-10 12:16 ` Ard Biesheuvel
2016-04-13 16:35 ` James Morse
2016-04-13 16:31 ` [PATCH v7 17/16] arm64: hibernate: Refuse to hibernate if the boot cpu is offline James Morse
2016-04-21 11:33 ` Lorenzo Pieralisi
2016-04-21 11:44 ` Mark Rutland
2016-04-21 12:33 ` Mark Rutland
2016-04-21 16:28 ` Lorenzo Pieralisi
2016-04-22 10:41 ` Mark Rutland
2016-04-22 15:32 ` James Morse
2016-04-22 10:41 ` Catalin Marinas
2016-04-22 15:32 ` James Morse
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=571DE10F.10905@arm.com \
--to=james.morse@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.