All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Niklas Schnelle <schnelle@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Harald Freudenberger <freude@linux.ibm.com>,
	Holger Dengler <dengler@linux.ibm.com>,
	Stefan Haberland <sth@linux.ibm.com>,
	Jan Hoeppner <hoeppner@linux.ibm.com>,
	Ilya Leoshkevich <iii@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 32/32] s390/extable: Remove EX_TABLE macros and fallback extable search
Date: Thu,  1 Oct 2026 12:32:47 +0200	[thread overview]
Message-ID: <20261001103247.1989111-33-hca@linux.ibm.com> (raw)
In-Reply-To: <20261001103247.1989111-1-hca@linux.ibm.com>

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.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 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 <asm/ptrace.h>
 #include <linux/compiler.h>
 
-/*
- * 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 ca6a1efa49ee..6bed074f1c5f 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) {
-- 
2.53.0


  parent reply	other threads:[~2026-10-01 10:33 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 10:32 [PATCH 00/32] s390: Improve exception table handling and disassembler Heiko Carstens
2026-10-01 10:32 ` [PATCH 01/32] s390/kprobes: Prevent kprobes on instructions with exception table entry Heiko Carstens
2026-10-01 10:44   ` sashiko-bot
2026-10-12 11:31   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 02/32] s390/early: Fix early warning handling Heiko Carstens
2026-10-01 10:42   ` sashiko-bot
2026-10-12 12:11   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 03/32] s390: Clear pt_regs flags field Heiko Carstens
2026-10-01 10:44   ` sashiko-bot
2026-10-12 12:15   ` Ilya Leoshkevich
2026-10-12 12:21     ` Heiko Carstens
2026-10-01 10:32 ` [PATCH 04/32] s390/bug: Indicate modified PSW in disassembly Heiko Carstens
2026-10-01 10:43   ` sashiko-bot
2026-10-12 15:07   ` Ilya Leoshkevich
2026-10-12 15:29     ` Heiko Carstens
2026-10-12 15:37       ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 05/32] s390/tools: Rename gen_facilities to gen_bitmaps Heiko Carstens
2026-10-01 10:37   ` sashiko-bot
2026-10-12 12:35   ` Ilya Leoshkevich
2026-10-12 13:26     ` Heiko Carstens
2026-10-01 10:32 ` [PATCH 06/32] s390/tools: Generate bitmap of nullified program checks Heiko Carstens
2026-10-01 10:37   ` sashiko-bot
2026-10-12 12:50   ` Ilya Leoshkevich
2026-10-12 13:32     ` Heiko Carstens
2026-10-01 10:32 ` [PATCH 07/32] s390/traps: Handle nullifying program checks in get_trap_ip() Heiko Carstens
2026-10-01 10:42   ` sashiko-bot
2026-10-12 13:01   ` Ilya Leoshkevich
2026-10-12 13:42     ` Heiko Carstens
2026-10-12 14:31       ` Ilya Leoshkevich
2026-10-12 15:30         ` Heiko Carstens
2026-10-01 10:32 ` [PATCH 08/32] s390/dis: Improve show_code() output Heiko Carstens
2026-10-01 10:48   ` sashiko-bot
2026-10-01 12:50     ` Heiko Carstens
2026-10-12 15:08   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 09/32] s390/extable: Rework exception handling logic Heiko Carstens
2026-10-01 10:41   ` sashiko-bot
2026-10-12 13:09   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 10/32] s390/diag: Convert amode31 exception tables to EX_TABLE_INSN Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 13:13   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 11/32] s390/uaccess: Convert inline assembly " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 13:16   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 12/32] s390/lib/uaccess: " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 13:24   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 13/32] s390/futex: " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 13:27   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 14/32] s390/diag: " Heiko Carstens
2026-10-01 10:43   ` sashiko-bot
2026-10-12 14:20   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 15/32] s390/mm/pfault: " Heiko Carstens
2026-10-01 10:39   ` sashiko-bot
2026-10-12 14:21   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 16/32] s390/cpu_mf: " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 14:22   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 17/32] s390/cert_store: " Heiko Carstens
2026-10-01 10:39   ` sashiko-bot
2026-10-12 14:23   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 18/32] s390/ipl: " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-12 14:23   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 19/32] s390/hypfs: " Heiko Carstens
2026-10-01 10:39   ` sashiko-bot
2026-10-12 14:24   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 20/32] s390/ap: " Heiko Carstens
2026-10-01 10:40   ` sashiko-bot
2026-10-02  7:54   ` Harald Freudenberger
2026-10-01 10:32 ` [PATCH 21/32] s390/fpu: " Heiko Carstens
2026-10-01 10:42   ` sashiko-bot
2026-10-12 14:25   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 22/32] s390/traps: " Heiko Carstens
2026-10-01 10:41   ` sashiko-bot
2026-10-12 14:25   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 23/32] s390/word-at-a-time: " Heiko Carstens
2026-10-01 10:42   ` sashiko-bot
2026-10-12 14:26   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 24/32] s390/kvm: " Heiko Carstens
2026-10-01 10:42   ` sashiko-bot
2026-10-02  8:24   ` Claudio Imbrenda
2026-10-01 10:32 ` [PATCH 25/32] s390/pci: " Heiko Carstens
2026-10-01 10:46   ` sashiko-bot
2026-10-02  9:12   ` Niklas Schnelle
2026-10-01 10:32 ` [PATCH 26/32] s390/boot: " Heiko Carstens
2026-10-01 10:44   ` sashiko-bot
2026-10-12 14:28   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 27/32] s390/cio: " Heiko Carstens
2026-10-01 10:46   ` sashiko-bot
2026-10-12 14:32   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 28/32] s390/dasd: " Heiko Carstens
2026-10-01 10:44   ` sashiko-bot
2026-10-12 14:33   ` Ilya Leoshkevich
2026-10-12 14:52   ` Stefan Haberland
2026-10-01 10:32 ` [PATCH 29/32] s390/diag_ftp: " Heiko Carstens
2026-10-01 10:43   ` sashiko-bot
2026-10-12 14:33   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 30/32] s390/sclp: " Heiko Carstens
2026-10-01 10:45   ` sashiko-bot
2026-10-12 14:34   ` Ilya Leoshkevich
2026-10-01 10:32 ` [PATCH 31/32] s390/bpf: Simplify exception table entry handling Heiko Carstens
2026-10-01 10:46   ` sashiko-bot
2026-10-12 14:38   ` Ilya Leoshkevich
2026-10-01 10:32 ` Heiko Carstens [this message]
2026-10-01 10:44   ` [PATCH 32/32] s390/extable: Remove EX_TABLE macros and fallback extable search sashiko-bot
2026-10-12 14:43   ` Ilya Leoshkevich

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=20261001103247.1989111-33-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=dengler@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hoeppner@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=schnelle@linux.ibm.com \
    --cc=sth@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=vneethv@linux.ibm.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.