[PATCH] arm64: efi: don't restore TTBR0 if active_mm points at init_mm
Jon Medhurst (Tixy)
tixy at linaro.org
Mon Mar 23 10:22:57 PDT 2015
On Mon, 2015-03-23 at 15:44 +0000, Catalin Marinas wrote:
[...]
> I think for stable, we can do
> with the patch below. We could clean up the cpu_switch_mm() uses through
> the arch/arm64 and set the reserved ttbr0 but we only have two at the
> moment (__cpu_suspend and efi_set_pgd).
>
> -----------------8<-------------------------
>
> From 5d9e3540b6480558528612dd3672543fa8ab3528 Mon Sep 17 00:00:00 2001
> From: Catalin Marinas <catalin.marinas at arm.com>
> Date: Mon, 23 Mar 2015 15:06:50 +0000
> Subject: [PATCH] arm64: Use the reserved TTBR0 if context switching to the
> init_mm
>
> The idle_task_exit() function may call switch_mm() with next ==
> &init_mm. On arm64, init_mm.pgd cannot be used for user mappings, so
> this patch simply sets the reserved TTBR0.
>
> Cc: <stable at vger.kernel.org>
> Reported-by: Jon Medhurst (Tixy) <tixy at linaro.org>
> Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
That unsurprising fixes the BUG_ON I was seeing on Juno, so...
Tested-by: Jon Medhurst (Tixy) <tixy at linaro.org>
One question, is bypassing setting the mm_cpumask and context.id for
init_mm OK? I'm not familiar with the code but had a quick look, and it
looks like they are just used for ASID management, in which case I
assume everything is OK - ASIDs only being relevant for user mappings in
ttbr0?
> ---
> arch/arm64/include/asm/mmu_context.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
> index a9eee33dfa62..101a42bde728 100644
> --- a/arch/arm64/include/asm/mmu_context.h
> +++ b/arch/arm64/include/asm/mmu_context.h
> @@ -151,6 +151,15 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
> {
> unsigned int cpu = smp_processor_id();
>
> + /*
> + * init_mm.pgd does not contain any user mappings and it is always
> + * active for kernel addresses in TTBR1. Just set the reserved TTBR0.
> + */
> + if (next == &init_mm) {
> + cpu_set_reserved_ttbr0();
> + return;
> + }
> +
> if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next)
> check_and_switch_context(next, tsk);
> }
More information about the linux-arm-kernel
mailing list