From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BA1036492C for ; Mon, 6 Jul 2026 17:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783357241; cv=none; b=AOZRRATRSlCKiE4CxYbaYI8mDkt8+x50JV1rHkFoxp64v7aQDxI/2QzJGCM/Fus27fJYqFvObyri1SrgC1+P8aSFrQlTH78r/3mql6wa87qeqK7/gV5/bngNtQP7iYs5I2lPTA0JeXsGUGXwrYK2Hmow4pnaV1YkCkXFAujeyCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783357241; c=relaxed/simple; bh=MpoYLm89NwQfFVLcVWDxpeVcVoeEF0xclyotqVr5Rxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I3Hsu/yOOn5RS4dcs2RqWblUXq+6ZBAGd9PJH3MCTHNh6GjKufN31pAzZwh0a8IAwwd0CSAHwEfyGt4uAONo7UHZ1CL0TbkYAlT8uoiCjDiPuy46lPqfH8uhW+y6p8p8hcOVpyn1Kihr7wAxdVxcrKjU9uWZB6JQ8xOJ9ldnf+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VpgXK//P; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VpgXK//P" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5aeb8870485so3545758e87.2 for ; Mon, 06 Jul 2026 10:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783357237; x=1783962037; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PQQxn5OhfgSm5EhkEn0SlT3jwEgnlZIRODQEX4dc9n8=; b=VpgXK//PsfnP+VrhQtTOhui0aliGVPRnetPgoormf+Qv9o8g+R7KlWgSxCuXbw16qZ BW4bITXw+h37w3XpLIHrjxvNazX07EaoOBtdiT9+FCAtbDDePJ0AsUGvs2eCp2C5MOeQ US5NdAf4c9hU0Nsnr+uRnce+b+d6dWl4Gg3j+8gdbhQM7cffwtxue0vuDtSwMTBvlAxr t/UcoRK1bRNEDCSs48DzzSiBBG659wWOxCwzt5uy6A2J3jAydt7SObaqQZCIylDX4fPN FTFbGjqhH7M4eYul/+ZT9vumSVu6BYO/eUrq8HdNXnk6HtqP2AIIsqUZEhqoSdomXTVy iSQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783357237; x=1783962037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PQQxn5OhfgSm5EhkEn0SlT3jwEgnlZIRODQEX4dc9n8=; b=sjv6iBI0cNYPYoNiq29P3gN/zqyT0DKZSl7c8M0cdABfBWEbv/tu4Oy6lWSrOhb7DF wixt3GkZoL93CzVkRVBF4wT2cNUpUPo17acdP9cvsDhboGLAisZBa+mM8gJ33qfGyfax 7VRon5QicqTswLFmE958sINK9UfSTpzBeyMnVw6VFV7A68k1C38qPcjusmPPOawjs/83 hTMDvsiuTELXRqo12k8xl/tqJLbug9UFS9XUnZEL5tdUk5vXzzWmeMj7FIsngdl1XOug f6Ul5wdWJ+nFq7cD9c7LynAr3Jfbk6CVlBKEPcFBQKXM6McgmC5QeaSlogh3DUbTKLum R50w== X-Forwarded-Encrypted: i=1; AHgh+Rpw1Pd+mvh9Ig2uP477RjBbH+P1kAEmiZpw6vI3BmPfsFFnlmd5md8a6XoxBS4PfjYgIN+0UXNQSLRsFCs=@vger.kernel.org X-Gm-Message-State: AOJu0YxruIH1H14/1/bVvmCDXSfrPVh5eXxUeVvrumbZHpQ9aR4xKKMD HGLjeNJoUhvDZkXVt8Oxum2cMwvfR/K78GNH9BTwWERsZcXBFEIH0lpV X-Gm-Gg: AfdE7clNgMYiUKBufCuML8MR/60zOvGWk3zXyFIgXwDN5P3ahMSD+lC4sP2OUekoHE5 75QI7gmTMf7mkEEgjuwakEftyLwTZnIQp9/6hcwUP3+cBZ/W2Qk/ZRXDB+LOJY++vae/ZYTBo71 XBzu9OwxrqfoPpMwpz0d27mBTPlv/HymJEt+vgEVPlVEK2x1FOxiET6pvKmb0qRFPUCEoA+n1yD Qm3fvrVIITHmI/emffI90z89bBN5gCtsh4qjDWukEdqtvmRggglcfTHaU7YXG722mSX6pfxi7j4 xs/t7Vput1Z285jQFCQavUu1FM/S12MKeBW0jNu3sVaUQA8UYLkgrPBEtpAAcCZQjZAbT+LSD4I 9eoS3Y0+zr3KKQM0Wxrh5+VkS6yRVRcDlkaRgklnCDJE70LRD35xJSkxWcRcyoFvLMf4Pvo0ksn ghBnTEwQmqK4GAyLUyADxKcES6C3m/bJfZ0JaQU200PyF1ykK49ohu6KRQsra3Zh5s/8FHqJJjc AVm3OPbWuYBwtDfnpMFcOMTna0= X-Received: by 2002:a05:6512:65c6:b0:5ae:c561:3ace with SMTP id 2adb3069b0e04-5b007c4dfe1mr209135e87.57.1783357235837; Mon, 06 Jul 2026 10:00:35 -0700 (PDT) Received: from buildhost.darklands.se (h-158-174-102-211.A469.priv.bahnhof.se. [158.174.102.211]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aed13bfd1fsm2961021e87.55.2026.07.06.10.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 10:00:35 -0700 (PDT) From: Magnus Lindholm To: richard.henderson@linaro.org, mattst88@gmail.com, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org Cc: glaubitz@physik.fu-berlin.de, mcree@orcon.net.nz, ink@unseen.parts, macro@orcam.me.uk, Magnus Lindholm Subject: [PATCH v4 6/7] alpha: enable lockdep hardirq state tracking Date: Mon, 6 Jul 2026 18:56:47 +0200 Message-ID: <20260706170019.2941459-7-linmag7@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260706170019.2941459-1-linmag7@gmail.com> References: <20260706170019.2941459-1-linmag7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Alpha masks interrupts through the PAL IPL state, so lockdep cannot infer hardirq state transitions from generic code alone. Add explicit hardirq on/off annotations to the low-level entry and return paths so lockdep's IRQ state follows the hardware IPL state. Annotate the PAL IPL transitions and the shared return-to-user/kernel paths where interrupts become enabled or disabled. With the preceding irqflags, raw-lock, sysfs, and ftrace return-address preparations in place, select LOCKDEP_SUPPORT and TRACE_IRQFLAGS_SUPPORT for Alpha. This keeps CONFIG_PROVE_LOCKING usable on Alpha instead of disabling debug_locks due to IRQ-state mismatches. Reviewed-by: Matt Turner Tested-by: Matt Turner Signed-off-by: Magnus Lindholm --- .../features/locking/lockdep/arch-support.txt | 2 +- arch/alpha/Kconfig | 5 ++ arch/alpha/kernel/entry.S | 17 ++++- arch/alpha/kernel/irq_alpha.c | 74 ++++++++++++++----- arch/alpha/kernel/proto.h | 4 + arch/alpha/kernel/signal.c | 9 +++ 6 files changed, 91 insertions(+), 20 deletions(-) diff --git a/Documentation/features/locking/lockdep/arch-support.txt b/Documentation/features/locking/lockdep/arch-support.txt index b6b00469f7d0..87a534c89636 100644 --- a/Documentation/features/locking/lockdep/arch-support.txt +++ b/Documentation/features/locking/lockdep/arch-support.txt @@ -6,7 +6,7 @@ ----------------------- | arch |status| ----------------------- - | alpha: | TODO | + | alpha: | ok | | arc: | ok | | arm: | ok | | arm64: | ok | diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 7ac435c56845..e53ef2d88463 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -45,6 +45,8 @@ config ALPHA select MMU_GATHER_RCU_TABLE_FREE select SPARSEMEM_EXTREME if SPARSEMEM select ZONE_DMA + select TRACE_IRQFLAGS_SUPPORT + select ARCH_WANT_FRAME_POINTERS help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory, @@ -84,6 +86,9 @@ config AUDIT_ARCH config STACKTRACE_SUPPORT def_bool y +config LOCKDEP_SUPPORT + def_bool y + menu "System setup" choice diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index 449092a31eef..9f2608de2544 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -93,6 +93,19 @@ 4: .endm +.macro LOCKDEP_HARDIRQS_ON_RESTORE +#ifdef CONFIG_PROVE_LOCKING + /* a0 = saved PS */ + ldq $16, SP_OFF($sp) + + /* a1 = callsite IP for lockdep */ + lda $17, 1f + + jsr $26, lockdep_on_restore + ldgp $gp, 0($26) +1: +#endif +.endm /* * This defines the normal kernel pt-regs layout. @@ -427,6 +440,7 @@ CFI_START_OSF_FRAME entUna .cfi_restore $28 .cfi_restore $29 .cfi_adjust_cfa_offset -256 + LOCKDEP_HARDIRQS_ON_RESTORE call_pal PAL_rti .align 4 @@ -577,6 +591,7 @@ restore_all: bne $3, restore_fpu restore_other: .cfi_remember_state + LOCKDEP_HARDIRQS_ON_RESTORE RESTORE_ALL call_pal PAL_rti @@ -622,7 +637,7 @@ $work_resched: * or got through work_notifysig already. Either case means no syscall * restarts for us, so let $18 and $19 burn. */ - jsr $26, schedule + jsr $26, alpha_schedule_user_work mov 0, $18 br ret_to_user diff --git a/arch/alpha/kernel/irq_alpha.c b/arch/alpha/kernel/irq_alpha.c index d17e44c99df9..736294d3dd51 100644 --- a/arch/alpha/kernel/irq_alpha.c +++ b/arch/alpha/kernel/irq_alpha.c @@ -41,7 +41,7 @@ EXPORT_SYMBOL(perf_irq); * The main interrupt entry point. */ -asmlinkage void +asmlinkage void do_entInt(unsigned long type, unsigned long vector, unsigned long la_ptr, struct pt_regs *regs) { @@ -54,40 +54,78 @@ do_entInt(unsigned long type, unsigned long vector, * (namely LX164). */ local_irq_disable(); + old_regs = set_irq_regs(regs); + switch (type) { case 0: #ifdef CONFIG_SMP + irq_enter(); handle_ipi(regs); - return; + irq_exit(); + break; #else irq_err_count++; - printk(KERN_CRIT "Interprocessor interrupt? " - "You must be kidding!\n"); -#endif + pr_crit("Interprocessor interrupt? You must be kidding!\n"); break; +#endif case 1: - old_regs = set_irq_regs(regs); + /* handle_irq() already does irq_enter()/irq_exit() */ handle_irq(RTC_IRQ); - set_irq_regs(old_regs); - return; + break; case 2: - old_regs = set_irq_regs(regs); + irq_enter(); alpha_mv.machine_check(vector, la_ptr); - set_irq_regs(old_regs); - return; + irq_exit(); + break; case 3: - old_regs = set_irq_regs(regs); + irq_enter(); alpha_mv.device_interrupt(vector); - set_irq_regs(old_regs); - return; + irq_exit(); + break; case 4: + irq_enter(); perf_irq(la_ptr, regs); - return; + irq_exit(); + break; default: - printk(KERN_CRIT "Hardware intr %ld %lx? Huh?\n", - type, vector); + pr_crit("Hardware intr %lu %lx? Huh?\n", type, vector); + pr_crit("PC = %016lx PS=%04lx\n", regs->pc, regs->ps); + break; } - printk(KERN_CRIT "PC = %016lx PS=%04lx\n", regs->pc, regs->ps); + + set_irq_regs(old_regs); + + /* + * Intentionally no local_irq_enable(): Alpha historically avoids + * enabling at IPL0 here due to PAL/RTI issues (LX164/MILO note). + */ +} + +void notrace lockdep_on_restore(unsigned long ps, + unsigned long ip) +{ +#ifdef CONFIG_PROVE_LOCKING + /* Restoring IPL==7 means interrupts remain disabled. */ + if ((ps & 7) == 7) + return; + + /* + * If hardware IRQs are already enabled here, then emitting a + * hardirqs-on transition is redundant. + */ + if (!irqs_disabled()) + return; + + /* + * Only emit the transition if lockdep currently believes + * hardirqs are off. + */ + if (lockdep_hardirqs_enabled()) + return; + + lockdep_hardirqs_on_prepare(); + lockdep_hardirqs_on(ip); +#endif } void __init diff --git a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h index a8bc3ead776b..9b262ef09a3a 100644 --- a/arch/alpha/kernel/proto.h +++ b/arch/alpha/kernel/proto.h @@ -173,6 +173,7 @@ extern void do_sigreturn(struct sigcontext __user *); struct rt_sigframe; extern void do_rt_sigreturn(struct rt_sigframe __user *); extern void do_work_pending(struct pt_regs *, unsigned long, unsigned long, unsigned long); +extern void alpha_schedule_user_work(void); /* traps.c */ extern void dik_show_regs(struct pt_regs *regs, unsigned long *r9_15); @@ -185,6 +186,9 @@ struct allregs; extern void do_entUna(void *, unsigned long, unsigned long, struct allregs *); extern void do_entUnaUser(void __user *, unsigned long, unsigned long, struct pt_regs *); +/* irq_alpha.c */ +extern void notrace lockdep_on_restore(unsigned long ps, unsigned long ip); + /* sys_titan.c */ extern void titan_dispatch_irqs(u64); diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c index e62d1d461b1f..ce40a49b8496 100644 --- a/arch/alpha/kernel/signal.c +++ b/arch/alpha/kernel/signal.c @@ -41,6 +41,14 @@ asmlinkage void ret_from_sys_call(void); * The OSF/1 sigprocmask calling sequence is different from the * C sigprocmask() sequence.. */ + +asmlinkage void alpha_schedule_user_work(void) +{ + local_irq_enable(); + schedule(); + local_irq_disable(); +} + SYSCALL_DEFINE2(osf_sigprocmask, int, how, unsigned long, newmask) { sigset_t oldmask; @@ -525,6 +533,7 @@ do_work_pending(struct pt_regs *regs, unsigned long thread_flags, { do { if (thread_flags & _TIF_NEED_RESCHED) { + local_irq_enable(); schedule(); } else { local_irq_enable(); -- 2.53.0