lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1603983387-8738-7-git-send-email-sumit.garg@linaro.org>
Date:   Thu, 29 Oct 2020 20:26:26 +0530
From:   Sumit Garg <sumit.garg@...aro.org>
To:     maz@...nel.org, catalin.marinas@....com, will@...nel.org
Cc:     linux-arm-kernel@...ts.infradead.org, tglx@...utronix.de,
        jason@...edaemon.net, linux@...linux.org.uk,
        tsbogend@...ha.franken.de, mpe@...erman.id.au, davem@...emloft.net,
        mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        mark.rutland@....com, julien.thierry.kdev@...il.com,
        dianders@...omium.org, daniel.thompson@...aro.org,
        jason.wessel@...driver.com, msys.mizuma@...il.com,
        ito-yuichi@...itsu.com, kgdb-bugreport@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, Sumit Garg <sumit.garg@...aro.org>
Subject: [PATCH v6 6/7] kgdb: roundup: Allow runtime arch specific override

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@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ