lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v6 6/7] kgdb: roundup: Allow runtime arch specific override
Date
Add a new API kgdb_arch_roundup_cpus() for a particular archichecture to
override default kgdb roundup and if it detects at runtime to not support
NMI roundup then it can fallback to default implementation using async
SMP cross-calls.

Currently such an architecture example is arm64 supporting pseudo NMIs
feature which is only available on platforms which have support for GICv3
or later version.

Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
arch/powerpc/kernel/kgdb.c | 3 ++-
arch/sparc/kernel/smp_64.c | 3 ++-
arch/x86/kernel/kgdb.c | 6 ++++--
include/linux/kgdb.h | 5 +++--
kernel/debug/debug_core.c | 10 +++++++++-
5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 4090802..126575d 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -125,9 +125,10 @@ static int kgdb_debugger_ipi(struct pt_regs *regs)
}

#ifdef CONFIG_SMP
-void kgdb_roundup_cpus(void)
+bool kgdb_arch_roundup_cpus(void)
{
smp_send_debugger_break();
+ return true;
}
#endif

diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index e38d8bf..c459c83 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1014,9 +1014,10 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
}

#ifdef CONFIG_KGDB
-void kgdb_roundup_cpus(void)
+bool kgdb_arch_roundup_cpus(void)
{
smp_cross_call(&xcall_kgdb_capture, 0, 0, 0);
+ return true;
}
#endif

diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index ff7878d..1b756d9 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -404,7 +404,8 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)

#ifdef CONFIG_SMP
/**
- * kgdb_roundup_cpus - Get other CPUs into a holding pattern
+ * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern
+ * in an architectural specific manner
*
* On SMP systems, we need to get the attention of the other CPUs
* and get them be in a known state. This should do what is needed
@@ -414,9 +415,10 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
*
* On non-SMP systems, this is not called.
*/
-void kgdb_roundup_cpus(void)
+bool kgdb_arch_roundup_cpus(void)
{
apic_send_IPI_allbutself(NMI_VECTOR);
+ return true;
}
#endif

diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 0d6cf64..f9db5b8 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -200,7 +200,8 @@ kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
extern void kgdb_call_nmi_hook(void *ignored);

/**
- * kgdb_roundup_cpus - Get other CPUs into a holding pattern
+ * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern
+ * in an architectural specific manner
*
* On SMP systems, we need to get the attention of the other CPUs
* and get them into a known state. This should do what is needed
@@ -210,7 +211,7 @@ extern void kgdb_call_nmi_hook(void *ignored);
*
* On non-SMP systems, this is not called.
*/
-extern void kgdb_roundup_cpus(void);
+extern bool kgdb_arch_roundup_cpus(void);

/**
* kgdb_arch_set_pc - Generic call back to the program counter
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 1e75a89..27e401c 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -241,13 +241,21 @@ void __weak kgdb_call_nmi_hook(void *ignored)
}
NOKPROBE_SYMBOL(kgdb_call_nmi_hook);

-void __weak kgdb_roundup_cpus(void)
+bool __weak kgdb_arch_roundup_cpus(void)
+{
+ return false;
+}
+
+static void kgdb_roundup_cpus(void)
{
call_single_data_t *csd;
int this_cpu = raw_smp_processor_id();
int cpu;
int ret;

+ if (kgdb_arch_roundup_cpus())
+ return;
+
for_each_online_cpu(cpu) {
/* No need to roundup ourselves */
if (cpu == this_cpu)
--
2.7.4
\
 
 \ /
  Last update: 2020-10-29 15:59    [W:0.099 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site