Skip to content

Commit 2f5cd0c

Browse files
diandersctmarinas
authored andcommitted
arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI roundup
Up until now we've been using the generic (weak) implementation for kgdb_roundup_cpus() when using kgdb on arm64. Let's move to a custom one. The advantage here is that, when pseudo-NMI is enabled on a device, we'll be able to round up CPUs using pseudo-NMI. This allows us to debug CPUs that are stuck with interrupts disabled. If pseudo-NMIs are not enabled then we'll fallback to just using an IPI, which is still slightly better than the generic implementation since it avoids the potential situation described in the generic kgdb_call_nmi_hook(). Co-developed-by: Sumit Garg <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Acked-by: Mark Rutland <[email protected]> Tested-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20230906090246.v13.6.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid Signed-off-by: Catalin Marinas <[email protected]>
1 parent d740251 commit 2f5cd0c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

arch/arm64/kernel/smp.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/irq_work.h>
3333
#include <linux/kernel_stat.h>
3434
#include <linux/kexec.h>
35+
#include <linux/kgdb.h>
3536
#include <linux/kvm_host.h>
3637
#include <linux/nmi.h>
3738

@@ -79,6 +80,7 @@ enum ipi_msg_type {
7980
* with trace_ipi_*
8081
*/
8182
IPI_CPU_BACKTRACE = NR_IPI,
83+
IPI_KGDB_ROUNDUP,
8284
MAX_IPI
8385
};
8486

@@ -868,6 +870,22 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu)
868870
nmi_trigger_cpumask_backtrace(mask, exclude_cpu, arm64_backtrace_ipi);
869871
}
870872

873+
#ifdef CONFIG_KGDB
874+
void kgdb_roundup_cpus(void)
875+
{
876+
int this_cpu = raw_smp_processor_id();
877+
int cpu;
878+
879+
for_each_online_cpu(cpu) {
880+
/* No need to roundup ourselves */
881+
if (cpu == this_cpu)
882+
continue;
883+
884+
__ipi_send_single(ipi_desc[IPI_KGDB_ROUNDUP], cpu);
885+
}
886+
}
887+
#endif
888+
871889
/*
872890
* Main handler for inter-processor interrupts
873891
*/
@@ -919,6 +937,10 @@ static void do_handle_IPI(int ipinr)
919937
nmi_cpu_backtrace(get_irq_regs());
920938
break;
921939

940+
case IPI_KGDB_ROUNDUP:
941+
kgdb_nmicallback(cpu, get_irq_regs());
942+
break;
943+
922944
default:
923945
pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr);
924946
break;
@@ -949,6 +971,7 @@ static bool ipi_should_be_nmi(enum ipi_msg_type ipi)
949971
case IPI_CPU_STOP:
950972
case IPI_CPU_CRASH_STOP:
951973
case IPI_CPU_BACKTRACE:
974+
case IPI_KGDB_ROUNDUP:
952975
return true;
953976
default:
954977
return false;

0 commit comments

Comments
 (0)