Skip to content

Commit e53f21b

Browse files
committed
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@vger.kernel.org> Reported-by: Jon Medhurst (Tixy) <tixy@linaro.org> Tested-by: Jon Medhurst (Tixy) <tixy@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent bc465aa commit e53f21b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/arm64/include/asm/mmu_context.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
151151
{
152152
unsigned int cpu = smp_processor_id();
153153

154+
/*
155+
* init_mm.pgd does not contain any user mappings and it is always
156+
* active for kernel addresses in TTBR1. Just set the reserved TTBR0.
157+
*/
158+
if (next == &init_mm) {
159+
cpu_set_reserved_ttbr0();
160+
return;
161+
}
162+
154163
if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next)
155164
check_and_switch_context(next, tsk);
156165
}

0 commit comments

Comments
 (0)