[PATCH RFC 2/3] arm64: Allow synchronous abort fixups for guarded MMIO reads

Matt Thompson via B4 Relay devnull+matt.boondocker.io at kernel.org
Fri Nov 13 16:28:50 PST 2026


From: Matt Thompson <matt at boondocker.io>

An RK3399 PCI configuration read can raise a synchronous external data
abort if it does not get a usable response. Allow an explicitly annotated
MMIO load to return an error in this case.

Match only a current-EL synchronous external abort on a read instruction
with the new exception table type. Keep existing handling for other
faults, including asynchronous SError and translation table walk aborts.

Signed-off-by: Matt Thompson <matt at boondocker.io>
---
 arch/arm64/include/asm/asm-extable.h |  9 +++++++++
 arch/arm64/mm/extable.c              |  1 +
 arch/arm64/mm/fault.c                | 11 +++++++++++
 3 files changed, 21 insertions(+)

diff --git a/arch/arm64/include/asm/asm-extable.h b/arch/arm64/include/asm/asm-extable.h
index d67e2fd..ed80aec 100644
--- a/arch/arm64/include/asm/asm-extable.h
+++ b/arch/arm64/include/asm/asm-extable.h
@@ -11,6 +11,7 @@
 #define EX_TYPE_KACCESS_ERR_ZERO	3
 #define EX_TYPE_UACCESS_CPY		4
 #define EX_TYPE_LOAD_UNALIGNED_ZEROPAD	5
+#define EX_TYPE_MMIO_READ_ERR_ZERO	6
 
 /* Data fields for EX_TYPE_UACCESS_ERR_ZERO */
 #define EX_DATA_REG_ERR_SHIFT	0
@@ -123,6 +124,14 @@
 #define _ASM_EXTABLE_KACCESS(insn, fixup)				\
 	_ASM_EXTABLE_KACCESS_ERR_ZERO(insn, fixup, wzr, wzr)
 
+#define _ASM_EXTABLE_MMIO_READ_ERR_ZERO(insn, fixup, err, zero)		\
+	__ASM_EXTABLE_RAW(insn, fixup,					\
+			  __stringify(EX_TYPE_MMIO_READ_ERR_ZERO),	\
+			  "((.L__gpr_num_" err " << "			\
+			  __stringify(EX_DATA_REG_ERR_SHIFT) ") | "	\
+			  "(.L__gpr_num_" zero " << "			\
+			  __stringify(EX_DATA_REG_ZERO_SHIFT) "))")
+
 #define _ASM_EXTABLE_LOAD_UNALIGNED_ZEROPAD(insn, fixup, data, addr)		\
 	__DEFINE_ASM_GPR_NUMS							\
 	__ASM_EXTABLE_RAW(#insn, #fixup,					\
diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c
index 299a244..c9b5944 100644
--- a/arch/arm64/mm/extable.c
+++ b/arch/arm64/mm/extable.c
@@ -100,6 +100,7 @@ bool fixup_exception(struct pt_regs *regs, unsigned long esr)
 		return ex_handler_bpf(ex, regs);
 	case EX_TYPE_UACCESS_ERR_ZERO:
 	case EX_TYPE_KACCESS_ERR_ZERO:
+	case EX_TYPE_MMIO_READ_ERR_ZERO:
 		return ex_handler_uaccess_err_zero(ex, regs);
 	case EX_TYPE_UACCESS_CPY:
 		return ex_handler_uaccess_cpy(ex, regs, esr);
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index b227368..148f7c9 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -877,8 +877,19 @@ static int do_bad(unsigned long far, unsigned long esr, struct pt_regs *regs)
 static int do_sea(unsigned long far, unsigned long esr, struct pt_regs *regs)
 {
 	const struct fault_info *inf;
+	const struct exception_table_entry *ex;
 	unsigned long siaddr;
 
+	/* Only a synchronous data abort on an explicitly guarded MMIO read. */
+	if (ESR_ELx_EC(esr) == ESR_ELx_EC_DABT_CUR &&
+	    (esr & ESR_ELx_FSC) == ESR_ELx_FSC_EXTABT &&
+	    !(esr & ESR_ELx_WNR)) {
+		ex = search_exception_tables(instruction_pointer(regs));
+		if (ex && ex->type == EX_TYPE_MMIO_READ_ERR_ZERO &&
+		    fixup_exception(regs, esr))
+			return 0;
+	}
+
 	inf = esr_to_fault_info(esr);
 
 	if (user_mode(regs) && apei_claim_sea(regs) == 0) {

-- 
Git-155)





More information about the Linux-rockchip mailing list