From: sashiko-bot@kernel.org
To: "Jiangtian Feng" <jiangtianfeng@linux.alibaba.com>,
catalin.marinas@arm.com, will@kernel.org,
akpm@linux-foundation.org, rafael@kernel.org
Cc: mark.rutland@arm.com, james.morse@arm.com, robin.murphy@arm.com,
nikumbh.adi@gmail.com, tony.luck@intel.com, guohanjun@huawei.com,
mchehab@kernel.org, lenb@kernel.org, xueshuai@linux.alibaba.com,
tongtiangen@huawei.com, tianruidong@linux.alibaba.com,
tongweilin@linux.alibaba.com, baolin.wang@linux.alibaba.com,
ashok.raj@oss.qualcomm.com, jonathan.cameron@oss.qualcomm.com,
david@kernel.org, liam@infradead.org, vbabka@kernel.org,
rppt@kernel.org, mhocko@suse.com, ljs@kernel.org,
surenb@google.com, shivankg@amd.com, wangkefeng.wang@huawei.com,
xiangzao@linux.alibaba.com, ying.huang@linux.alibaba.com,
linmiaohe@huawei.com, nao.horiguchi@gmail.com, ziy@nvidia.com,
tujinjiang@huawei.com, mgorman@techsingularity.net,
kaitao.cheng@linux.dev, chengkaitao@kylinos.cn,
muchun.song@linux.dev, nico.pache@linux.dev,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org,
kees@kernel.org, andreyknvl@gmail.com, dvyukov@google.com,
gli@kvack.org, der@google.com, ryabinin.a.a@gmail.com,
vincenzo.frascino@arm.com, tglx@kernel.org, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com,
linux-mm@kvack.org, kasan-dev@googlegroups.com, x86@kernel.org
Subject: Re: [PATCH v16 4/9] arm64: enable recover from synchronous external abort in kernel context
Date: Sun, 06 Dec 2026 01:26:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-252031@kernel.org> (raw)
In-Reply-To: <20261205012435.1406255-5-jiangtianfeng@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 11 potential
issues to consider:
- [High] arm64: EX_TYPE_ACCESS_ERR_ZERO SEA fixup livelocks futex retry
loops
- [Medium] arm64: SEA fixup in __arch_copy_to_user() livelocks
read_kcore_iter()
- [Medium] arm64: unconditional apei_claim_sea() in EL1 deadlocks on
nested SEA
- [Medium] arm64: fixup_exception_me() recovers kernel/user writes via
ACCESS_ERR_ZERO
- [Medium] arm64: broad SEA extable fixup turns EL0 emulation SEAs into
SIGSEGV
- [Medium] arm64: do_apei_claim_sea() recovers SEAs even without page
isolation
- [Low] arm64: unconfirmed ESR_ELx.WnR validity on FSC_EXTABT SEAs in
extable
- [Low] arm64: commit message contradicts GHES_CTX_KERNEL SIGBUS and
extable scope
- [Low] arm64: confirm ESR_ELx.SET == 0b00 encoding in
do_apei_claim_sea()
- [Low] arm64: skipping 9997 fallback for MOPS faults may break usercopy
progress
- [Low] arm64: do_apei_claim_sea() skips ARM64_HAS_RAS_EXTN check for
RES0 SET
--
commit 50af6acf54c318c2deb67defca532465dfc1e14e
Author: Ruidong Tian <tianruidong@linux.alibaba.com>
arm64: enable recover from synchronous external abort in kernel context
This commit adds kernel-context recovery for EL1 synchronous external aborts
in do_sea() via a new EX_TYPE_KACCESS_SEA exception table type and
fixup_exception_me(), and annotates __arch_copy_to_user() kernel loads for
SEA recovery while bypassing the single-byte fallback on MOPS usercopy
faults.
> Take copy_from/to_user for example, If ld* triggers a memory error, even in
> kernel mode, only the associated process is affected. Killing the user
> process and isolating the corrupt page is a better choice.
[Severity: Low]
Does the commit message accurately reflect the SIGBUS and extable behavior?
With commit "ACPI: APEI: GHES: use exception context to gate SIGBUS on poison
consumption", GHES_CTX_KERNEL suppresses MF_ACTION_REQUIRED and
force_sig(SIGBUS), so the user process is not killed and instead receives an
error return such as -EFAULT. The commit message also describes kernel SEA
recovery as limited to EX_TYPE_KACCESS_SEA and EX_TYPE_UACCESS_CPY source
reads, omitting that fixup_exception_me() unconditionally recovers all
EX_TYPE_ACCESS_ERR_ZERO entries.
> diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
> index 400057d607ecd..04f152ff5b033 100644
> --- a/arch/arm64/lib/copy_from_user.S
> +++ b/arch/arm64/lib/copy_from_user.S
> @@ -54,7 +54,7 @@
>
> .macro cpy1 dst, src, count
> .arch_extension mops
> - USER_CPY(9997f, 0, cpyfprt [\dst]!, [\src]!, \count!)
> + USER_CPY(9998f, 0, cpyfprt [\dst]!, [\src]!, \count!)
> USER_CPY(9996f, 0, cpyfmrt [\dst]!, [\src]!, \count!)
> USER_CPY(9996f, 0, cpyfert [\dst]!, [\src]!, \count!)
> .endm
> @@ -69,9 +69,11 @@ SYM_FUNC_START(__arch_copy_from_user)
> ret
>
> // Exception fixups
> -9996: b.cs 9997f
> + // MOPS faults skip the zero-progress retry to avoid repeating an SEA.
> +9996: b.cs 9998f
> // Registers are in Option A format
> add dst, dst, count
> + b 9998f
[Severity: Low]
This question rests on an arm64 architecture detail that the review could not
confirm from the kernel source: can FEAT_MOPS unprivileged copy instructions
(cpyfprt/cpyfmrt/cpyfert and cpyfpwt/cpyfmwt/cpyfewt) take a synchronous data
abort with zero reported forward progress (leaving dst == dstin after Option
A/B register fixup) when a single-byte ldtrb/sttrb at byte 0 would succeed,
such as on an MTE tag mismatch in a later granule or unaligned Device memory?
If the answer is yes, bypassing label 9997 for all MOPS faults (here and in
arch/arm64/lib/copy_to_user.S) breaks the forward-progress contract that
295cf156231c ("arm64: Avoid premature usercopy failure") added 9997 to
uphold. In generic_perform_write() and iomap_write_iter(),
fault_in_readable() only probes byte 0 of each page, so it would succeed and
spin the write loop until a fatal signal arrives; copy_to_user() callers such
as filemap_read() would return -EFAULT instead of a short read. Bypassing
9997 only on SEA fixups would avoid repeating an SEA without changing
ordinary usercopy faults.
> diff --git a/arch/arm64/lib/copy_to_user.S b/arch/arm64/lib/copy_to_user.S
> index 819f2e3fc7a93..451bfeb0143b4 100644
> --- a/arch/arm64/lib/copy_to_user.S
> +++ b/arch/arm64/lib/copy_to_user.S
> @@ -20,7 +20,7 @@
> * x0 - bytes not copied
> */
> .macro ldrb1 reg, ptr, val
> - ldrb \reg, [\ptr], \val
> + KERNEL_SEA(9998f, ldrb \reg, [\ptr], \val)
> .endm
[Severity: Medium]
Does annotating regular __arch_copy_to_user() kernel loads with KERNEL_SEA
(and allowing kernel-source reads in ex_handler_uaccess_cpy()) livelock
callers that treat a short copy as an unmapped user page?
In read_kcore_iter() for KCORE_VMALLOC, a while (true) loop with no signal
check calls vread_iter() -> aligned_vread_iter() ->
copy_page_to_iter_nofault() -> __arch_copy_to_user(). When the kernel load
hits a poisoned vmalloc page, __arch_copy_to_user() returns a full residual
(0 bytes copied), fault_in_iov_iter_writeable() succeeds because the user
buffer is writable, and the loop spins forever re-triggering SEAs (commit
"ACPI: APEI: GHES: use exception context to gate SIGBUS on poison
consumption" skips duplicate-SEA -ECANCELED cancellation for
GHES_CTX_KERNEL).
This also causes filemap_read() to report a poisoned page-cache page as
-EFAULT instead of -EIO, and btrfs copy_to_sk() to retry on poisoned extent
buffers. Restricting kernel-source SEA recovery to an opt-in
copy_mc_to_user() path, as x86 and powerpc do, would avoid conflating kernel
memory errors with user page faults.
> diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c
> index 402c5db692ffe..5ea013a3247c3 100644
> --- a/arch/arm64/mm/extable.c
> +++ b/arch/arm64/mm/extable.c
[ ... ]
> @@ -55,10 +58,14 @@ static bool ex_handler_access_err_zero(const struct exception_table_entry *ex,
> }
>
> static bool ex_handler_uaccess_cpy(const struct exception_table_entry *ex,
> - struct pt_regs *regs, unsigned long esr)
> + struct pt_regs *regs, unsigned long esr,
> + bool allow_kernel_source)
> {
> - /* Do not fix up faults on kernel memory accesses */
> - if (!cpy_faulted_on_uaccess(ex, esr))
> + /* Only SEA may also accept copy_to_user's kernel source read. */
> + if (!cpy_faulted_on_uaccess(ex, esr) &&
> + !(allow_kernel_source &&
> + FIELD_GET(EX_DATA_UACCESS_WRITE, ex->data) &&
> + !(esr & ESR_ELx_WNR)))
> return false;
[Severity: Low]
This question rests on an arm64 architecture detail that the review could not
confirm from the kernel source: for an EL1 synchronous external abort with
DFSC == ESR_ELx_FSC_EXTABT (especially on a FEAT_MOPS CPY* instruction or
when ESR_ELx_FnV is set), can a write-triggered SEA report ESR_ELx.WnR == 0
or UNKNOWN?
If the answer is yes, cpy_faulted_on_uaccess() would treat a
kernel-destination write SEA in __arch_copy_from_user() (where
EX_DATA_UACCESS_WRITE is 0) as a user read and recover it, and the
ESR_ELx_WNR check on EX_TYPE_KACCESS_SEA in fixup_exception_me() would
likewise fail to reject a write SEA.
[ ... ]
> +bool fixup_exception_me(struct pt_regs *regs, unsigned long esr)
> +{
> + const struct exception_table_entry *ex;
> +
> + ex = search_exception_tables(instruction_pointer(regs));
> + if (!ex)
> + return false;
> +
> + switch (ex->type) {
> + case EX_TYPE_ACCESS_ERR_ZERO:
> + return ex_handler_access_err_zero(ex, regs);
[Severity: High]
Can unconditionally recovering EX_TYPE_ACCESS_ERR_ZERO entries here livelock
futex retry loops on a poisoned user page?
All arm64 futex atomics in arch/arm64/include/asm/futex.h emit
EX_TYPE_ACCESS_ERR_ZERO. When one hits an SEA in EL1, GHES_CTX_KERNEL queues
memory_failure_queue() asynchronously on the current CPU via
schedule_work_on(smp_processor_id(), &mf_cpu->work) and suppresses
force_sig(SIGBUS), while fixup_exception_me() returns -EFAULT.
In futex_lock_pi() and handle_futex_death(), -EFAULT calls
fault_in_user_writeable(), which sees the PTE still mapped and returns 0, and
immediately retries with no cond_resched() or fatal_signal_pending() check.
Under CONFIG_PREEMPT_NONE this starves the queued memory_failure work on the
same CPU; under any preemption model, if memory_failure is disabled or cannot
unmap the page, futex_lock_pi(), handle_futex_death(), futex_wake_op(), and
futex_requeue() loop indefinitely because GHES_CTX_KERNEL skips
duplicate-SEA -ECANCELED cancellation.
[Severity: Medium]
Does handling EX_TYPE_ACCESS_ERR_ZERO unconditionally also recover kernel
writes, user writes, and cache maintenance instructions?
After commit "arm64: extable: merge UACCESS_ERR_ZERO and KACCESS_ERR_ZERO
into ACCESS_ERR_ZERO", EX_TYPE_ACCESS_ERR_ZERO covers __put_kernel_nofault(),
user stores and atomics (such as put_user(), clear_user(), and sttr* in
copy_to_user()), and cache maintenance operations in
caches_clean_inval_user_pou(). Because fixup_exception_me() checks neither
ESR_ELx_WNR nor ESR_ELx_CM and cannot distinguish kernel from user entries,
it silently turns SEAs on kernel destination writes and cache maintenance
into -EFAULT.
[Severity: Medium]
Does this EX_TYPE_ACCESS_ERR_ZERO fixup also turn SEAs during trapped EL0
emulation into SIGSEGV instead of SIGBUS?
Both user_cache_maint_handler() and compat swp_handler() annotate their user
accesses with _ASM_EXTABLE_UACCESS_ERR and call arm64_notify_segfault() when
the access returns -EFAULT. Because do_apei_claim_sea() does not exclude
ESR_ELx_CM and GHES_CTX_KERNEL suppresses SIGBUS, an SEA on either path is
reported to userspace as SIGSEGV.
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index b22736853fcd8..d8ff65c86728d 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -874,21 +874,43 @@ static int do_bad(unsigned long far, unsigned long esr, struct pt_regs *regs)
> return 1; /* "fault" */
> }
>
> +/*
> + * APEI claimed this as a firmware-first notification.
> + * Some processing deferred to task_work before ret_to_user().
> + */
> +static int do_apei_claim_sea(struct pt_regs *regs, unsigned long esr)
> +{
> + int ret;
> +
> + ret = apei_claim_sea(regs);
> + if (ret)
> + return ret;
> +
> + if (user_mode(regs))
> + return 0;
[Severity: Medium]
Can calling apei_claim_sea() unconditionally on every EL1 SEA self-deadlock
on ghes_notify_lock_sea if a nested EL1 SEA occurs?
DAIF_ERRCTX cannot mask synchronous external aborts, and unlike
ghes_notify_nmi(), ghes_notify_sea() has no re-entrancy guard:
do_sea()
do_apei_claim_sea()
apei_claim_sea()
local_daif_restore(DAIF_ERRCTX)
nmi_enter()
ghes_notify_sea()
raw_spin_lock(&ghes_notify_lock_sea)
ghes_in_nmi_spool_from_list()
<nested EL1 SEA>
do_sea()
do_apei_claim_sea()
apei_claim_sea()
ghes_notify_sea()
raw_spin_lock(&ghes_notify_lock_sea) <-- spins forever
If a nested EL1 SEA hits before ghes_clear_estatus() clears block_status,
this CPU deadlocks on ghes_notify_lock_sea (blocking any other CPU that later
takes an SEA). If the read inside ghes_has_active_errors() itself triggers
an SEA, it recurses until stack overflow.
[Severity: Medium]
Can do_apei_claim_sea() recover a kernel SEA even when GHES did not isolate
the failing page or process a memory error?
ghes_in_nmi_queue_one_entry() returns 0 for any active non-panic SEA status
block regardless of whether ghes_do_proc() queues memory_failure() (for
example, a CPER record without CPER_MEM_VALID_PA, a non-memory section, or a
kernel with CONFIG_ACPI_APEI_MEMORY_FAILURE=n). Since commit "ACPI: APEI:
GHES: use exception context to gate SIGBUS on poison consumption" also
disabled the unqueued SIGBUS fallback for GHES_CTX_KERNEL, matching
fixup_exception_me() silently converts an unisolated hardware error into
-EFAULT without queuing memory_failure(), delivering SIGBUS, or setting
TAINT_MACHINE_CHECK.
> + /* A GHES claim alone does not make a kernel exception safe to skip. */
> + if (!is_el1_data_abort(esr) ||
> + (esr & ESR_ELx_FSC) != ESR_ELx_FSC_EXTABT ||
> + (esr & ESR_ELx_S1PTW) ||
> + (esr & ESR_ELx_SET_MASK))
> + return -ENOENT;
[Severity: Low]
This question rests on an arm64 architecture detail that the review could not
confirm from the kernel source: on FEAT_RAS systems (including RASv1p1 and
RASv2), can ESR_ELx.SET == 0b00 for an EL1 data abort with DFSC ==
ESR_ELx_FSC_EXTABT ever encode an uncontainable or non-UER error state rather
than UER?
arch/arm64/include/asm/esr.h only defines ESR_ELx_SET_SHIFT and
ESR_ELx_SET_MASK without named ESR_ELx_SET_* encodings. If 0b00 can encode a
non-UER error, checking (esr & ESR_ELx_SET_MASK) == 0 would skip a kernel
instruction on an uncontainable SEA instead of panicking (and reject valid
UER aborts if UER uses a non-zero encoding).
[Severity: Low]
This question rests on an arm64 architecture detail that the review could not
confirm from the kernel source: on a CPU without FEAT_RAS (where
ARM64_HAS_RAS_EXTN is absent and ESR_ELx.SET is RES0, as noted in
kvm_handle_guest_sea()), can hardware deliver an EL1 synchronous external
data abort with ESR_ELx_FSC_EXTABT and S1PTW == 0 for an uncontainable or
unrecoverable error?
If the answer is yes, because do_apei_claim_sea() does not check
ARM64_HAS_RAS_EXTN, (esr & ESR_ELx_SET_MASK) always evaluates to 0 on non-RAS
CPUs, and apei_claim_sea() returns 0 for any non-panic GHES record, so
fixup_exception_me() would skip the faulting kernel instruction and continue
running after an uncontained hardware error instead of calling
arm64_notify_die().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205012435.1406255-1-jiangtianfeng@linux.alibaba.com?part=4
next prev parent reply other threads:[~2026-12-06 1:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 1:24 [PATCH v16 0/9] arm64: add ARCH_HAS_COPY_MC support Jiangtian Feng
2026-12-05 1:24 ` [PATCH v16 1/9] uaccess: add generic fallback version of copy_mc_to_user() Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 2/9] ACPI: APEI: GHES: use exception context to gate SIGBUS on poison consumption Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 3/9] arm64: extable: merge UACCESS_ERR_ZERO and KACCESS_ERR_ZERO into ACCESS_ERR_ZERO Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 4/9] arm64: enable recover from synchronous external abort in kernel context Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot [this message]
2026-12-05 1:24 ` [PATCH v16 5/9] mm/hwpoison: return -EFAULT when copy fail in copy_mc_[user]_highpage() Jiangtian Feng
2026-12-05 1:24 ` [PATCH v16 6/9] arm64: support copy_mc_[user]_highpage() Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 7/9] arm64: introduce copy_mc_to_kernel() implementation Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 8/9] lib/test: memcpy_kunit: add copy_page() and copy_mc_page() tests Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
2026-12-05 1:24 ` [PATCH v16 9/9] lib/tests: memcpy_kunit: add memcpy_mc() and memcpy_mc_large() test Jiangtian Feng
2026-12-06 1:26 ` sashiko-bot
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=sashiko-outbox-252031@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=aneesh.kumar@kernel.org \
--cc=ashok.raj@oss.qualcomm.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chengkaitao@kylinos.cn \
--cc=chleroy@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=der@google.com \
--cc=dev.jain@arm.com \
--cc=dvyukov@google.com \
--cc=gli@kvack.org \
--cc=guohanjun@huawei.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=jiangtianfeng@linux.alibaba.com \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=kaitao.cheng@linux.dev \
--cc=kas@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=kees@kernel.org \
--cc=lance.yang@linux.dev \
--cc=lenb@kernel.org \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mark.rutland@arm.com \
--cc=mchehab@kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=naveen.n.rao@linux.ibm.com \
--cc=nico.pache@linux.dev \
--cc=nikumbh.adi@gmail.com \
--cc=npiggin@gmail.com \
--cc=rafael@kernel.org \
--cc=ritesh.list@gmail.com \
--cc=robin.murphy@arm.com \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shivankg@amd.com \
--cc=sshegde@linux.ibm.com \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=tianruidong@linux.alibaba.com \
--cc=tongtiangen@huawei.com \
--cc=tongweilin@linux.alibaba.com \
--cc=tony.luck@intel.com \
--cc=tujinjiang@huawei.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xiangzao@linux.alibaba.com \
--cc=xueshuai@linux.alibaba.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/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.