From 6d86f714aed7287e15178dee949d4b64bf5d7ed2 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Thu, 1 Oct 2026 12:32:47 +0200 Subject: [PATCH] s390/extable: Remove EX_TABLE macros and fallback extable search Now that all exception table entries point to the faulting instruction, rename all EX_TABLE* macros to EX_TABLE_INSN* and remove the EX_TABLE_INSN* aliases. Also remove the fallback extable search via instruction_pointer() which was only needed to handle the old EX_TABLE entries that pointed to the instruction after the faulting instruction. Add a comment above the EX_TABLE_INSN macros that documents the usage rule and describe the difference to the previous EX_TABLE macros. This might be helpful in case of backporting to old kernels. Reviewed-by: Ilya Leoshkevich Signed-off-by: Heiko Carstens --- arch/s390/boot/pgm_check.c | 23 +++++------------ arch/s390/include/asm/asm-extable.h | 38 ++++++++++++++--------------- arch/s390/include/asm/extable.h | 25 ++++++------------- arch/s390/mm/extable.c | 2 -- 4 files changed, 32 insertions(+), 56 deletions(-) diff --git a/arch/s390/boot/pgm_check.c b/arch/s390/boot/pgm_check.c index 56d0be7e2823..e5a454b21669 100644 --- a/arch/s390/boot/pgm_check.c +++ b/arch/s390/boot/pgm_check.c @@ -51,31 +51,20 @@ static unsigned long boot_get_trap_ip(struct pt_regs *regs) return __rewind_psw(regs->psw, regs->int_code >> 16); } -static const struct exception_table_entry *search_boot_extable(unsigned long ip) +static bool ex_handler(struct pt_regs *regs) { const struct exception_table_entry *ex; + unsigned long ip = boot_get_trap_ip(regs); for (ex = __start___ex_table; ex < __stop___ex_table; ex++) { if (extable_insn(ex) != ip) continue; if (ex->type != EX_TYPE_FIXUP) - return NULL; - return ex; + return false; + regs->psw.addr = extable_fixup(ex); + return true; } - return NULL; -} - -static bool ex_handler(struct pt_regs *regs) -{ - const struct exception_table_entry *ex; - - ex = search_boot_extable(boot_get_trap_ip(regs)); - if (!ex) - ex = search_boot_extable(instruction_pointer(regs)); - if (!ex) - return false; - regs->psw.addr = extable_fixup(ex); - return true; + return false; } void do_pgm_check(struct pt_regs *regs) diff --git a/arch/s390/include/asm/asm-extable.h b/arch/s390/include/asm/asm-extable.h index 488bd10452b3..fd43ecd3e491 100644 --- a/arch/s390/include/asm/asm-extable.h +++ b/arch/s390/include/asm/asm-extable.h @@ -65,41 +65,41 @@ stringify_in_c(.purgem extable_reg;) \ stringify_in_c(.previous) -#define EX_TABLE(_fault, _target) \ +/* + * EX_TABLE_INSN usage rules: + * + * _fault must point to the faulting instruction, never behind it. + * + * This differs from the former EX_TABLE convention, where usually two entries + * were needed. One that pointed to the faulting instruction (for nullifying + * exceptions), and a second one that pointed behind the instruction (for + * suppressing, completing, and terminating exceptions). + */ +#define EX_TABLE_INSN(_fault, _target) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FIXUP, __stringify(%%r0), __stringify(%%r0), 0) -#define EX_TABLE_AMODE31(_fault, _target) \ +#define EX_TABLE_INSN_AMODE31(_fault, _target) \ __EX_TABLE(.amode31.ex_table, _fault, _target, EX_TYPE_FIXUP, __stringify(%%r0), __stringify(%%r0), 0) -#define EX_TABLE_UA_FAULT(_fault, _target, _regerr) \ +#define EX_TABLE_INSN_UA_FAULT(_fault, _target, _regerr) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_FAULT, _regerr, _regerr, 0) -#define EX_TABLE_UA_LOAD_REG(_fault, _target, _regerr, _regzero) \ +#define EX_TABLE_INSN_UA_LOAD_REG(_fault, _target, _regerr, _regzero) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REG, _regerr, _regzero, 0) -#define EX_TABLE_UA_LOAD_REGPAIR(_fault, _target, _regerr, _regzero) \ +#define EX_TABLE_INSN_UA_LOAD_REGPAIR(_fault, _target, _regerr, _regzero) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REGPAIR, _regerr, _regzero, 0) -#define EX_TABLE_ZEROPAD(_fault, _target, _regdata, _regaddr) \ +#define EX_TABLE_INSN_ZEROPAD(_fault, _target, _regdata, _regaddr) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_ZEROPAD, _regdata, _regaddr, 0) -#define EX_TABLE_FPC(_fault, _target) \ +#define EX_TABLE_INSN_FPC(_fault, _target) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FPC, __stringify(%%r0), __stringify(%%r0), 0) -#define EX_TABLE_UA_MVCOS_TO(_fault, _target) \ +#define EX_TABLE_INSN_UA_MVCOS_TO(_fault, _target) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_MVCOS_TO, __stringify(%%r0), __stringify(%%r0), 0) -#define EX_TABLE_UA_MVCOS_FROM(_fault, _target) \ +#define EX_TABLE_INSN_UA_MVCOS_FROM(_fault, _target) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_MVCOS_FROM, __stringify(%%r0), __stringify(%%r0), 0) -#define EX_TABLE_INSN EX_TABLE -#define EX_TABLE_INSN_AMODE31 EX_TABLE_AMODE31 -#define EX_TABLE_INSN_UA_FAULT EX_TABLE_UA_FAULT -#define EX_TABLE_INSN_UA_LOAD_REG EX_TABLE_UA_LOAD_REG -#define EX_TABLE_INSN_UA_LOAD_REGPAIR EX_TABLE_UA_LOAD_REGPAIR -#define EX_TABLE_INSN_ZEROPAD EX_TABLE_ZEROPAD -#define EX_TABLE_INSN_FPC EX_TABLE_FPC -#define EX_TABLE_INSN_UA_MVCOS_TO EX_TABLE_UA_MVCOS_TO -#define EX_TABLE_INSN_UA_MVCOS_FROM EX_TABLE_UA_MVCOS_FROM - #endif /* __ASM_EXTABLE_H */ diff --git a/arch/s390/include/asm/extable.h b/arch/s390/include/asm/extable.h index af6ba52743e9..5032c648781b 100644 --- a/arch/s390/include/asm/extable.h +++ b/arch/s390/include/asm/extable.h @@ -5,25 +5,14 @@ #include #include -/* - * The exception table consists of three addresses: - * - * - Address of an instruction that is allowed to fault. - * - Address at which the program should continue. - * - Optional address of handler that takes pt_regs * argument and runs in - * interrupt context. - * - * No registers are modified, so it is entirely up to the continuation code - * to figure out what to do. - * - * All the routines below use bits of fixup code that are out of line - * with the main instruction path. This means when everything is well, - * we don't even have to jump over them. Further, they do not intrude - * on our cache or tlb entries. +/** + * struct exception_table_entry - entry in exception table + * @insn: Relative pointer to faulting instruction + * @fixup: Relative pointer to instruction where execution resumes + * @type: Exception type + * @data: handler-specific data */ - -struct exception_table_entry -{ +struct exception_table_entry { int insn, fixup; short type, data; }; diff --git a/arch/s390/mm/extable.c b/arch/s390/mm/extable.c index 3d2ad6e853d1..d0a1ded21520 100644 --- a/arch/s390/mm/extable.c +++ b/arch/s390/mm/extable.c @@ -121,8 +121,6 @@ bool fixup_exception(struct pt_regs *regs) const struct exception_table_entry *ex; ex = s390_search_extables(get_trap_ip(regs)); - if (!ex) - ex = s390_search_extables(instruction_pointer(regs)); if (!ex) return false; switch (ex->type) { -- knotmirror 0.0.1