milos-linux/arch/arm/kernel
Florian Fainelli 009b6c6486 ARM: 9476/1: mm: fix kexec and hibernation with CONFIG_CPU_TTBR0_PAN
Commit 7af5b901e8 ("ARM: 9358/2: Implement PAN for LPAE by TTBR0
page table walks disablement") implemented PAN for LPAE kernels by
setting TTBCR.EPD0 on every kernel entry, disabling TTBR0 page-table
walks while running in kernel mode. The commit correctly updated
cpu_suspend() in arch/arm/kernel/suspend.c, but missed two other code
paths that switch the CPU to the identity mapping before jumping to
low-PA (TTBR0-range) physical addresses:

1. setup_mm_for_reboot() in arch/arm/mm/idmap.c, used by the kexec
   reboot path. With TTBCR.EPD0 still set, the subsequent branch to
   the identity-mapped cpu_v7_reset causes a PrefetchAbort because the
   TTBR0 page-table walk needed to resolve the identity-mapped address
   is disabled. This manifests as a hard hang or "bad PC value" panic
   on LPAE kernels booted on CPUs that strictly enforce EPD0 for
   instruction fetch (e.g. Cortex-A53 in AArch32 mode) while the same
   image may accidentally work on Cortex-A15 due to microarchitectural
   differences in EPD0 enforcement.

2. arch_restore_image() in arch/arm/kernel/hibernate.c, which calls
   cpu_switch_mm(idmap_pgd, &init_mm) directly without going through
   setup_mm_for_reboot(), leaving TTBCR.EPD0 set while the identity
   mapping is active.

Fix both sites by calling uaccess_save_and_enable() before switching
to the identity mapping, mirroring what the original commit did for
cpu_suspend().

Assisted-by: Cursor:claude-sonnet-4.6

Fixes: 7af5b901e8 ("ARM: 9358/2: Implement PAN for LPAE by TTBR0 page table walks disablement")
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2026-06-11 14:52:03 +01:00
..
.gitignore
arch_timer.c
armksyms.c
asm-offsets.c arch: Add the macro COMPILE_OFFSETS to all the asm-offsets.c 2025-09-25 09:57:15 +02:00
atags.h
atags_compat.c
atags_parse.c
atags_proc.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bios32.c PCI: Align head space better 2026-03-27 10:19:08 -05:00
bugs.c
cacheinfo.c ARM: 9440/1: cacheinfo fix format field mask 2025-01-22 20:55:01 +00:00
cpuidle.c
crash_dump.c
debug.S
devtree.c of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-10-29 15:32:45 -05:00
dma.c
early_printk.c
efi.c
elf.c
entry-armv.S ARM: 9475/1: entry: use byte load for KASAN VMAP stack shadow 2026-06-11 14:52:01 +01:00
entry-common.S stackleak: Rename STACKLEAK to KSTACK_ERASE 2025-07-21 21:35:01 -07:00
entry-ftrace.S ARM: 9457/1: ftrace: Implement HAVE_FUNCTION_GRAPH_FREGS 2025-10-02 08:44:51 +01:00
entry-header.S
entry-v7m.S
fiq.c
fiqasm.S
ftrace.c asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
head-common.S
head-inflate-data.c
head-nommu.S
head.h
head.S ARM: 9420/1: smp: Fix SMP for xip kernels 2024-11-12 16:38:47 +00:00
hibernate.c ARM: 9476/1: mm: fix kexec and hibernation with CONFIG_CPU_TTBR0_PAN 2026-06-11 14:52:03 +01:00
hw_breakpoint.c kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI 2025-09-24 14:29:14 -07:00
hyp-stub.S
insn.c
io.c
irq.c ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() 2024-10-16 21:56:56 +02:00
isa.c treewide: const qualify ctl_tables where applicable 2025-01-28 13:48:37 +01:00
iwmmxt.h
iwmmxt.S
jump_label.c asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
kgdb.c asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
machine_kexec.c kexec: Consolidate machine_kexec_mask_interrupts() implementation 2024-12-11 20:32:34 +01:00
Makefile arm/paravirt: Use common code for paravirt_steal_clock() 2026-01-12 15:57:23 +01:00
module-plts.c ARM: 9471/1: module: fix unwind section relocation out of range error 2026-04-09 11:51:52 +01:00
module.c ARM: 9458/1: module: Ensure the override of module_arch_freeing_init() 2025-09-13 12:33:07 +01:00
opcodes.c
patch.c asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
perf_callchain.c perf/arm: Drop unused functions 2024-11-14 10:40:00 +01:00
perf_regs.c
phys2virt.S
process.c arch: copy_thread: pass clone_flags as u64 2025-09-01 15:31:34 +02:00
psci_smp.c ARM: 9420/1: smp: Fix SMP for xip kernels 2024-11-12 16:38:47 +00:00
ptrace.c ARM: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names 2025-07-14 22:27:47 -07:00
reboot.c
reboot.h
relocate_kernel.S
return_address.c
setup.c Add a new optional ",cma" suffix to the crashkernel= command line option 2025-07-19 19:08:22 -07:00
signal.c ARM: uapi: Drop PSR_ENDSTATE 2026-01-30 16:46:17 +01:00
signal.h
sigreturn_codes.S
sleep.S
smccc-call.S
smp.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
smp_scu.c
smp_tlb.c
smp_twd.c ARM: smp_twd: Remove clockevents shutdown call on offlining 2024-10-31 10:41:42 +01:00
spectre.c
stacktrace.c
suspend.c
swp_emulate.c
sys_arm.c
sys_oabi-compat.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
tcm.c
thumbee.c
time.c
topology.c
traps.c arm: Rely on generic printing of preemption model 2025-03-17 11:23:39 +01:00
unwind.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
v7m.c
vdso.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vmcore_info.c
vmlinux-xip.lds.S kbuild: Split .modinfo out from ELF_DETAILS 2026-02-26 11:50:19 -07:00
vmlinux.lds.S kbuild: Split .modinfo out from ELF_DETAILS 2026-02-26 11:50:19 -07:00
xscale-cp0.c