From: Guo Ren <[email protected]>
Current riscv kexec can't crash_save percpu states and disable
interrupts properly. The patch series fix them.
Guo Ren (2):
riscv: kexec: EOI active and mask all interrupts in kexec crash path
riscv: kexec: Implement crash_smp_send_stop with percpu crash_save_cpu
arch/riscv/include/asm/smp.h | 6 +++
arch/riscv/kernel/machine_kexec.c | 44 +++++++++++----
arch/riscv/kernel/smp.c | 89 ++++++++++++++++++++++++++++++-
3 files changed, 126 insertions(+), 13 deletions(-)
--
2.36.1
From: Guo Ren <[email protected]>
If a crash happens on cpu3 and all interrupts are binding on cpu0, the
bad irq routing will cause a crash kernel that can't receive any irq.
Because start-up of crash kernel won't clean up other hart plic to
enable the context. The patch is similar to 9141a003a491 ("ARM: 7316/1:
kexec: EOI active and mask all interrupts in kexec crash path") and
78fd584cdec0 ("arm64: kdump: implement machine_crash_shutdown()"), also
PowerPC has the same mechanism.
Signed-off-by: Guo Ren <[email protected]>
Signed-off-by: Guo Ren <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: AKASHI Takahiro <[email protected]>
---
arch/riscv/kernel/machine_kexec.c | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c
index ee79e6839b86..db41c676e5a2 100644
--- a/arch/riscv/kernel/machine_kexec.c
+++ b/arch/riscv/kernel/machine_kexec.c
@@ -15,6 +15,8 @@
#include <linux/compiler.h> /* For unreachable() */
#include <linux/cpu.h> /* For cpu_down() */
#include <linux/reboot.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
/*
* kexec_image_info - Print received image details
@@ -154,6 +156,37 @@ void crash_smp_send_stop(void)
cpus_stopped = 1;
}
+static void machine_kexec_mask_interrupts(void)
+{
+ unsigned int i;
+ struct irq_desc *desc;
+
+ for_each_irq_desc(i, desc) {
+ struct irq_chip *chip;
+ int ret;
+
+ chip = irq_desc_get_chip(desc);
+ if (!chip)
+ continue;
+
+ /*
+ * First try to remove the active state. If this
+ * fails, try to EOI the interrupt.
+ */
+ ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false);
+
+ if (ret && irqd_irq_inprogress(&desc->irq_data) &&
+ chip->irq_eoi)
+ chip->irq_eoi(&desc->irq_data);
+
+ if (chip->irq_mask)
+ chip->irq_mask(&desc->irq_data);
+
+ if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
+ chip->irq_disable(&desc->irq_data);
+ }
+}
+
/*
* machine_crash_shutdown - Prepare to kexec after a kernel crash
*
@@ -169,6 +202,8 @@ machine_crash_shutdown(struct pt_regs *regs)
crash_smp_send_stop();
crash_save_cpu(regs, smp_processor_id());
+ machine_kexec_mask_interrupts();
+
pr_info("Starting crashdump kernel...\n");
}
--
2.36.1
On 16/08/2022 02:26, [email protected] wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Guo Ren <[email protected]>
>
> Current riscv kexec can't crash_save percpu states and disable
> interrupts properly. The patch series fix them.
Hey,
If these are fixes, are there fixes tags you could add?
I don't see one for either patch.
Thanks,
Conor.
>
> Guo Ren (2):
> riscv: kexec: EOI active and mask all interrupts in kexec crash path
> riscv: kexec: Implement crash_smp_send_stop with percpu crash_save_cpu
>
> arch/riscv/include/asm/smp.h | 6 +++
> arch/riscv/kernel/machine_kexec.c | 44 +++++++++++----
> arch/riscv/kernel/smp.c | 89 ++++++++++++++++++++++++++++++-
> 3 files changed, 126 insertions(+), 13 deletions(-)
>
> --
> 2.36.1
>
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv