From: Matt Turner <mattst88@gmail.com>
To: linux-alpha@vger.kernel.org, richard.henderson@linaro.org
Cc: linmag7@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH 24/24] alpha: add TRACE_IRQFLAGS_SUPPORT
Date: Tue, 1 Sep 2026 11:50:37 -0400 [thread overview]
Message-ID: <b71c51ff7ca699ca6e667a55d9ebce58ef092c77.1788277742.git.mattst88@gmail.com> (raw)
In-Reply-To: <cover.1788277742.git.mattst88@gmail.com>
Instrument the entry/exit assembly to track hardirq state for lockdep.
TRACE_IRQS_OFF is called after SAVE_ALL at each exception/interrupt
entry point and at syscall entry. TRACE_IRQS_ON is called at
restore_all before returning to userspace, where PAL_rti will restore
the user IPL (re-enabling interrupts).
The function call clobbers caller-saved registers, so the
TRACE_IRQS_OFF macro reloads $0 and $16-$18 from the pt_regs frame.
$8 (current_thread_info) is preserved because it is declared as a
global register variable.
Together with the previously added STACKTRACE_SUPPORT and
LOCKDEP_SUPPORT, this enables LOCK_DEBUGGING_SUPPORT on Alpha.
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
arch/alpha/kernel/entry.S | 54 +++++++++++++++++++++++++++++++++------
1 file changed, 46 insertions(+), 8 deletions(-)
diff --git ./arch/alpha/kernel/entry.S ./arch/alpha/kernel/entry.S
index 9f2608de2544..ed5df48503d0 100644
--- ./arch/alpha/kernel/entry.S
+++ ./arch/alpha/kernel/entry.S
@@ -241,6 +241,36 @@
.cfi_adjust_cfa_offset -SWITCH_STACK_SIZE
.endm
+/*
+ * Trace hardirq state changes for lockdep. TRACE_IRQS_OFF is called
+ * after SAVE_ALL at each entry point where PALcode enters with IPL
+ * raised (interrupts disabled). TRACE_IRQS_ON is called before
+ * returning to userspace, where PAL_rti will restore the user IPL.
+ *
+ * The function call clobbers caller-saved registers; $8 is preserved
+ * because it is declared as a global register variable for
+ * current_thread_info. We reload $0 and $16-$18 from the pt_regs
+ * frame that SAVE_ALL created, since entry points pass those to their
+ * C handlers.
+ */
+.macro TRACE_IRQS_OFF
+#ifdef CONFIG_TRACE_IRQFLAGS
+ jsr $26, trace_hardirqs_off
+ ldgp $gp, 0($26)
+ ldq $0, 0($sp)
+ ldq $16, 160($sp)
+ ldq $17, 168($sp)
+ ldq $18, 176($sp)
+#endif
+.endm
+
+.macro TRACE_IRQS_ON
+#ifdef CONFIG_TRACE_IRQFLAGS
+ jsr $26, trace_hardirqs_on
+ ldgp $gp, 0($26)
+#endif
+.endm
+
/*
* Non-syscall kernel entry points.
*/
@@ -248,8 +278,9 @@
CFI_START_OSF_FRAME entInt
SAVE_ALL
lda $8, 0x3fff
- lda $26, ret_from_sys_call
bic $sp, $8, $8
+ TRACE_IRQS_OFF
+ lda $26, ret_from_sys_call
mov $sp, $19
jsr $31, do_entInt
CFI_END_OSF_FRAME entInt
@@ -257,14 +288,18 @@ CFI_END_OSF_FRAME entInt
CFI_START_OSF_FRAME entArith
SAVE_ALL
lda $8, 0x3fff
- lda $26, ret_from_sys_call
bic $sp, $8, $8
+ TRACE_IRQS_OFF
+ lda $26, ret_from_sys_call
mov $sp, $18
jsr $31, do_entArith
CFI_END_OSF_FRAME entArith
CFI_START_OSF_FRAME entMM
SAVE_ALL
+ lda $8, 0x3fff
+ bic $sp, $8, $8
+ TRACE_IRQS_OFF
/* save $9 - $15 so the inline exception code can manipulate them. */
subq $sp, 64, $sp
.cfi_adjust_cfa_offset 64
@@ -284,8 +319,6 @@ CFI_START_OSF_FRAME entMM
.cfi_rel_offset $15, 48
addq $sp, 64, $19
/* handle the fault */
- lda $8, 0x3fff
- bic $sp, $8, $8
jsr $26, do_page_fault
/* reload the registers after the exception code played. */
ldq $9, 0($sp)
@@ -311,8 +344,9 @@ CFI_END_OSF_FRAME entMM
CFI_START_OSF_FRAME entIF
SAVE_ALL
lda $8, 0x3fff
- lda $26, ret_from_sys_call
bic $sp, $8, $8
+ TRACE_IRQS_OFF
+ lda $26, ret_from_sys_call
mov $sp, $17
jsr $31, do_entIF
CFI_END_OSF_FRAME entIF
@@ -451,6 +485,9 @@ entUnaUser:
.cfi_restore $0
.cfi_adjust_cfa_offset -256
SAVE_ALL /* setup normal kernel stack */
+ lda $8, 0x3fff
+ bic $sp, $8, $8
+ TRACE_IRQS_OFF
lda $sp, -64($sp)
.cfi_adjust_cfa_offset 64
stq $9, 0($sp)
@@ -467,9 +504,7 @@ entUnaUser:
.cfi_rel_offset $13, 32
.cfi_rel_offset $14, 40
.cfi_rel_offset $15, 48
- lda $8, 0x3fff
addq $sp, 64, $19
- bic $sp, $8, $8
jsr $26, do_entUnaUser
ldq $9, 0($sp)
ldq $10, 8($sp)
@@ -493,8 +528,9 @@ CFI_END_OSF_FRAME entUna
CFI_START_OSF_FRAME entDbg
SAVE_ALL
lda $8, 0x3fff
- lda $26, ret_from_sys_call
bic $sp, $8, $8
+ TRACE_IRQS_OFF
+ lda $26, ret_from_sys_call
mov $sp, $16
jsr $31, do_entDbg
CFI_END_OSF_FRAME entDbg
@@ -543,6 +579,7 @@ entSys:
lda $8, 0x3fff
bic $sp, $8, $8
+ TRACE_IRQS_OFF
lda $4, NR_syscalls($31)
stq $16, SP_OFF+24($sp)
lda $5, sys_call_table
@@ -586,6 +623,7 @@ ret_to_user:
and $17, _TIF_WORK_MASK, $2
bne $2, work_pending
restore_all:
+ TRACE_IRQS_ON
ldl $2, TI_STATUS($8)
and $2, TS_SAVED_FP | TS_RESTORE_FP, $3
bne $3, restore_fpu
--
2.54.0
next prev parent reply other threads:[~2026-09-01 15:52 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 15:50 [PATCH 00/24] alpha: catch up on architecture Kconfig options Matt Turner
2026-09-01 15:50 ` [PATCH 01/24] alpha: fix arch_irqs_disabled_flags() to treat any raised IPL as disabled Matt Turner
2026-09-01 23:20 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 02/24] alpha: enter hardirq context before looking up the irq descriptor Matt Turner
2026-09-03 22:07 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 03/24] alpha: select ARCH_HAS_UBSAN Matt Turner
2026-09-01 22:34 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 04/24] alpha: select ARCH_HAS_GCOV_PROFILE_ALL Matt Turner
2026-09-03 22:35 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 05/24] alpha: select HAVE_DEBUG_KMEMLEAK Matt Turner
2026-09-02 6:01 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 06/24] alpha: select EDAC_SUPPORT Matt Turner
2026-09-01 23:17 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 07/24] alpha: select ARCH_SUPPORTS_ATOMIC_RMW Matt Turner
2026-09-02 6:17 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 08/24] alpha: select ARCH_HAS_FAST_MULTIPLIER Matt Turner
2026-09-02 7:49 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 09/24] alpha: select ARCH_SUPPORTS_INT128 Matt Turner
2026-09-02 8:50 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 10/24] alpha: select HAVE_ARCH_COMPILER_H Matt Turner
2026-09-02 9:11 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 11/24] alpha: select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE Matt Turner
2026-09-02 9:25 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 12/24] alpha: add HAVE_ARCH_THREAD_STRUCT_WHITELIST support Matt Turner
2026-09-02 9:35 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 13/24] alpha: add ARCH_HAS_PTE_SPECIAL support Matt Turner
2026-09-02 9:42 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 14/24] alpha: add ARCH_SUPPORTS_PAGE_TABLE_CHECK support Matt Turner
2026-09-01 22:45 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 15/24] alpha: select ARCH_HAS_DEBUG_VM_PGTABLE Matt Turner
2026-09-03 22:52 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 16/24] alpha: select HAVE_GUP_FAST Matt Turner
2026-09-02 21:09 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 17/24] alpha: select ARCH_USE_MEMTEST Matt Turner
2026-09-02 21:56 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 18/24] alpha: select SYSCTL_EXCEPTION_TRACE Matt Turner
2026-09-02 22:02 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 19/24] alpha: discard .eh_frame and the relocation sections Matt Turner
2026-09-03 5:18 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 20/24] alpha: select ARCH_WANT_LD_ORPHAN_WARN Matt Turner
2026-09-03 5:34 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 21/24] alpha: select ARCH_WANT_IRQS_OFF_ACTIVATE_MM Matt Turner
2026-09-03 5:42 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 22/24] alpha: add HAVE_PERF_REGS and HAVE_PERF_USER_STACK_DUMP support Matt Turner
2026-09-03 21:01 ` Magnus Lindholm
2026-09-01 15:50 ` [PATCH 23/24] alpha: select SPARSE_IRQ Matt Turner
2026-09-03 21:26 ` Magnus Lindholm
2026-09-01 15:50 ` Matt Turner [this message]
2026-09-03 22:58 ` [PATCH 24/24] alpha: add TRACE_IRQFLAGS_SUPPORT Magnus Lindholm
2026-09-02 18:53 ` [PATCH 00/24] alpha: catch up on architecture Kconfig options Magnus Lindholm
2026-09-02 18:57 ` Matt Turner
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=b71c51ff7ca699ca6e667a55d9ebce58ef092c77.1788277742.git.mattst88@gmail.com \
--to=mattst88@gmail.com \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.henderson@linaro.org \
/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