From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Linus Walleij <linusw@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
bcm-kernel-feedback-list@broadcom.com,
Catalin Marinas <catalin.marinas@arm.com>,
Linus Walleij <linus.walleij@linaro.org>,
Russell King <linux@armlinux.org.uk>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Kees Cook <kees@kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ARM: mm: fix kexec and hibernation with CONFIG_CPU_TTBR0_PAN
Date: Mon, 25 May 2026 11:15:20 -0700 [thread overview]
Message-ID: <724e103e-ebc2-403c-887e-d91e403754d9@broadcom.com> (raw)
In-Reply-To: <CAD++jL=QxG=e62aOBXCzuud-nMEKtiUd-6_iUAudB0DJRWJwzw@mail.gmail.com>
On 5/25/2026 6:35 AM, Linus Walleij wrote:
> Hi Florian,
>
> thanks for digging in and finding this!
>
> On Sat, May 23, 2026 at 2:08 AM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
>
>> Commit 7af5b901e847 ("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().
>>
>> Fixes: 7af5b901e847 ("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>
>> Assisted-by: Cursor:claude-sonnet-4.6
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
>
> Please put this patch into Russell's patch tracker.
Thank you, now done:
https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9476/1
--
Florian
prev parent reply other threads:[~2026-05-25 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 0:08 [PATCH] ARM: mm: fix kexec and hibernation with CONFIG_CPU_TTBR0_PAN Florian Fainelli
2026-05-25 13:35 ` Linus Walleij
2026-05-25 18:15 ` Florian Fainelli [this message]
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=724e103e-ebc2-403c-887e-d91e403754d9@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=catalin.marinas@arm.com \
--cc=kees@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rmk+kernel@armlinux.org.uk \
/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