Archive-only list for patches
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Huacai Chen <chenhuacai@loongson.cn>,
	Tianyang Zhang <zhangtianyang@loongson.cn>,
	Sasha Levin <sashal@kernel.org>,
	chenhuacai@kernel.org, maqianga@uniontech.com,
	alexander.deucher@amd.com, tangyouling@kylinos.cn,
	alexandre.f.demers@gmail.com, yangtiezhu@loongson.cn
Subject: [PATCH AUTOSEL 6.17-6.1] LoongArch: Mask all interrupts during kexec/kdump
Date: Mon, 24 Nov 2025 03:06:33 -0500	[thread overview]
Message-ID: <20251124080644.3871678-19-sashal@kernel.org> (raw)
In-Reply-To: <20251124080644.3871678-1-sashal@kernel.org>

From: Huacai Chen <chenhuacai@loongson.cn>

[ Upstream commit 863a320dc6fd7c855f47da4bb82a8de2d9102ea2 ]

If the default state of the interrupt controllers in the first kernel
don't mask any interrupts, it may cause the second kernel to potentially
receive interrupts (which were previously allocated by the first kernel)
immediately after a CPU becomes online during its boot process. These
interrupts cannot be properly routed, leading to bad IRQ issues.

This patch calls machine_kexec_mask_interrupts() to mask all interrupts
during the kexec/kdump process.

Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Comprehensive Analysis

### 1. Commit Message and Problem Analysis
The commit addresses a significant reliability issue in the LoongArch
architecture's kexec (soft reboot) and kdump (crash dump) mechanisms.
- **Problem:** When transitioning from the current kernel to a new one
  (either via kexec or panic-induced kdump), the interrupt controllers
  are not being properly masked. This allows interrupts from the old
  kernel to fire immediately as the new kernel boots, before it is ready
  to handle them. This results in "bad IRQ" errors, spurious interrupts,
  and potentially failed crash dumps.
- **Solution:** The patch introduces calls to
  `machine_kexec_mask_interrupts()` in the shutdown paths. This function
  iterates through active interrupts and masks them at the controller
  level, ensuring a clean, quiescent state for the incoming kernel.
- **Context:** This aligns LoongArch with other architectures (ARM64,
  RISC-V, PowerPC) where this masking is already standard practice.

### 2. Code Research and Validation
- **Mechanism:** The fix adds two function calls: one in
  `machine_kexec()` (standard path) and one in
  `machine_crash_shutdown()` (crash path).
- **Dependencies & Backporting Complexity:**
    - The function `machine_kexec_mask_interrupts()` is a standard
      helper. However, it was consolidated into the generic
      `kernel/irq/kexec.c` in kernel versions around v6.14 (approx. Dec
      2024).
    - **For recent stable kernels (e.g., 6.14+):** The patch should
      apply cleanly as the generic symbol is available.
    - **For older LTS kernels (e.g., 6.1.y, 6.6.y, 6.12.y):** The
      generic helper likely does not exist. Backporting to these trees
      will require a slight modification to include a local
      implementation of `machine_kexec_mask_interrupts()` within
      `arch/loongarch/kernel/machine_kexec.c`, similar to how ARM64 and
      RISC-V handled it prior to the consolidation. This is a standard
      procedure for architecture-specific fixes in stable.

### 3. Stable Kernel Rules Assessment
- **Fixes a Real Bug:** Yes. The lack of interrupt masking causes race
  conditions and potential boot failures in the second kernel.
- **Important Severity:** High. Kdump is a critical feature for
  enterprise debugging. If kdump fails due to spurious IRQs, diagnosing
  the original system crash becomes impossible.
- **Small and Contained:** The logic change is minimal (masking
  interrupts).
- **No New Features:** This is a fix for existing, broken functionality.
- **Regression Risk:** Low. The system is shutting down; masking
  interrupts is the correct defensive posture.

### 4. Conclusion
This commit is an essential fix for LoongArch system reliability. It
corrects a deviation from standard kernel behavior that jeopardizes
crash recovery. While backporting to older long-term stable trees will
require handling the missing generic helper function (by adding a local
version), the fix itself is obviously correct and required.

**YES**

 arch/loongarch/kernel/machine_kexec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/loongarch/kernel/machine_kexec.c b/arch/loongarch/kernel/machine_kexec.c
index f9381800e291c..8ef4e4595d61a 100644
--- a/arch/loongarch/kernel/machine_kexec.c
+++ b/arch/loongarch/kernel/machine_kexec.c
@@ -249,6 +249,7 @@ void machine_crash_shutdown(struct pt_regs *regs)
 #ifdef CONFIG_SMP
 	crash_smp_send_stop();
 #endif
+	machine_kexec_mask_interrupts();
 	cpumask_set_cpu(crashing_cpu, &cpus_in_crash);
 
 	pr_info("Starting crashdump kernel...\n");
@@ -286,6 +287,7 @@ void machine_kexec(struct kimage *image)
 
 	/* We do not want to be bothered. */
 	local_irq_disable();
+	machine_kexec_mask_interrupts();
 
 	pr_notice("EFI boot flag 0x%lx\n", efi_boot);
 	pr_notice("Command line at 0x%lx\n", cmdline_ptr);
-- 
2.51.0


  parent reply	other threads:[~2025-11-24  8:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24  8:06 [PATCH AUTOSEL 6.17-5.10] platform/x86: huawei-wmi: add keys for HONOR models Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] sched_ext: Fix possible deadlock in the deferred_irq_workfn() Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-5.15] HID: elecom: Add support for ELECOM M-XT3URBK (018F) Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86: intel-uncore-freq: Add additional client processors Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-6.6] platform/x86/amd/pmc: Add spurious_8042 to Xbox Ally Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-5.10] pinctrl: qcom: msm: Fix deadlock in pinmux configuration Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86: hp-wmi: Add Omen 16-wf1xxx fan support Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-5.10] samples: work around glibc redefining some of our defines wrong Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-6.6] HID: hid-input: Extend Elan ignore battery quirk to USB Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] HID: lenovo: fixup Lenovo Yoga Slim 7x Keyboard rdesc Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86/amd/pmc: Add support for Van Gogh SoC Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] sched_ext: Use IRQ_WORK_INIT_HARD() to initialize rq->scx.kick_cpus_irq_work Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86/intel/hid: Add Nova Lake support Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86: hp-wmi: mark Victus 16-r0 and 16-s0 for victus_s fan and thermal profile support Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-5.4] platform/x86: acer-wmi: Ignore backlight event Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17] platform/x86: hp-wmi: Add Omen MAX 16-ah0xx fan support and thermal profile Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-6.6] platform/x86/amd: pmc: Add Lenovo Legion Go 2 to pmc quirk list Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-6.6] nvme: fix admin request_queue lifetime Sasha Levin
2025-11-24  8:06 ` Sasha Levin [this message]
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-6.1] HID: apple: Add SONiX AK870 PRO to non_apple_keyboards quirk list Sasha Levin
2025-11-24  8:06 ` [PATCH AUTOSEL 6.17-5.4] bfs: Reconstruct file type when loading from disk Sasha Levin

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=20251124080644.3871678-19-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=alexandre.f.demers@gmail.com \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=maqianga@uniontech.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tangyouling@kylinos.cn \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhangtianyang@loongson.cn \
    /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