[PATCH] KDB: commandeer vector 0xfe for KDB_VECTOR]]

Jay Lan jlan at sgi.com
Wed Oct 29 17:37:12 PDT 2008


Jay Lan wrote:
> 
> I will let Keith to comment on the logic of your code, but this patch
> will cause IA64 compilation to fail because kdb_giveback_vector()
> is not defined for IA64.
> 
> Suggestions:
> 1) change kdb_takeover_vector and kdb_giveback_vector to arch-dependent
>    version of kdba_takeover_vector and kdba_giveback_vector.
> 2) extern of kdba_giveback_vector should be moved to arch-dependent
>    kdb.h (ie, arch/{ia64,x86}/include/asm/kdb.h.) and the ia64 version
>    to be a dummy define.
> 3) kdbmain.c should change accordingly.
Hi Cliff,

Attached below is a revised patch to change your patch with my
suggestions above.

Thanks,
jay




-- Attached file included as plaintext by Ecartis --
-- File: KDB_VECTOR.v2.1

Revised Cliff's KDB_VECTOR patch version 2 to make kdba_takeover_vector
and kdba_giveback_vector arch dependent.

---
 arch/ia64/include/asm/kdb.h   |    2 ++
 arch/x86/kdb/kdbasupport_32.c |   22 ++++++++++++++++++----
 arch/x86/kdb/kdbasupport_64.c |   23 +++++++++++++++++++----
 include/asm-x86/irq_vectors.h |   11 ++++++-----
 include/asm-x86/kdb.h         |    2 ++
 kdb/kdbmain.c                 |    2 ++
 6 files changed, 49 insertions(+), 13 deletions(-)

Index: linux/arch/x86/kdb/kdbasupport_32.c
===================================================================
--- linux.orig/arch/x86/kdb/kdbasupport_32.c	2008-10-29 17:19:18.000000000 -0700
+++ linux/arch/x86/kdb/kdbasupport_32.c	2008-10-29 17:21:15.944621636 -0700
@@ -883,9 +883,6 @@ kdba_cpu_up(void)
 static int __init
 kdba_arch_init(void)
 {
-#ifdef	CONFIG_SMP
-	set_intr_gate(KDB_VECTOR, kdb_interrupt);
-#endif
 	set_intr_gate(KDBENTER_VECTOR, kdb_call);
 	return 0;
 }
@@ -1027,14 +1024,31 @@ kdba_verify_rw(unsigned long addr, size_
 
 #include <mach_ipi.h>
 
+gate_desc save_idt[NR_VECTORS];
+
+void kdba_takeover_vector(int vector)
+{
+	memcpy(&save_idt[vector], &idt_table[vector], sizeof(gate_desc));
+	set_intr_gate(KDB_VECTOR, kdb_interrupt);
+	return;
+}
+
+void kdba_giveback_vector(int vector)
+{
+	native_write_idt_entry(idt_table, vector, &save_idt[vector]);
+	return;
+}
+
 /* When first entering KDB, try a normal IPI.  That reduces backtrace problems
  * on the other cpus.
  */
 void
 smp_kdb_stop(void)
 {
-	if (!KDB_FLAG(NOIPI))
+	if (!KDB_FLAG(NOIPI)) {
+		kdba_takeover_vector(KDB_VECTOR);
 		send_IPI_allbutself(KDB_VECTOR);
+	}
 }
 
 /* The normal KDB IPI handler */
Index: linux/arch/x86/kdb/kdbasupport_64.c
===================================================================
--- linux.orig/arch/x86/kdb/kdbasupport_64.c	2008-10-29 17:19:18.000000000 -0700
+++ linux/arch/x86/kdb/kdbasupport_64.c	2008-10-29 17:21:15.952621783 -0700
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/kdebug.h>
+#include <linux/cpumask.h>
 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/uaccess.h>
@@ -900,9 +901,6 @@ kdba_cpu_up(void)
 static int __init
 kdba_arch_init(void)
 {
-#ifdef	CONFIG_SMP
-	set_intr_gate(KDB_VECTOR, kdb_interrupt);
-#endif
 	set_intr_gate(KDBENTER_VECTOR, kdb_call);
 	return 0;
 }
@@ -976,14 +974,31 @@ kdba_set_current_task(const struct task_
 
 #include <mach_ipi.h>
 
+gate_desc save_idt[NR_VECTORS];
+
+void kdba_takeover_vector(int vector)
+{
+	memcpy(&save_idt[vector], &idt_table[vector], sizeof(gate_desc));
+	set_intr_gate(KDB_VECTOR, kdb_interrupt);
+	return;
+}
+
+void kdba_giveback_vector(int vector)
+{
+	native_write_idt_entry(idt_table, vector, &save_idt[vector]);
+	return;
+}
+
 /* When first entering KDB, try a normal IPI.  That reduces backtrace problems
  * on the other cpus.
  */
 void
 smp_kdb_stop(void)
 {
-	if (!KDB_FLAG(NOIPI))
+	if (!KDB_FLAG(NOIPI)) {
+		kdba_takeover_vector(KDB_VECTOR);
 		send_IPI_allbutself(KDB_VECTOR);
+	}
 }
 
 /* The normal KDB IPI handler */
Index: linux/include/asm-x86/irq_vectors.h
===================================================================
--- linux.orig/include/asm-x86/irq_vectors.h	2008-10-29 17:19:18.000000000 -0700
+++ linux/include/asm-x86/irq_vectors.h	2008-10-29 17:22:32.050027567 -0700
@@ -66,7 +66,6 @@
 # define RESCHEDULE_VECTOR		0xfc
 # define CALL_FUNCTION_VECTOR		0xfb
 # define CALL_FUNCTION_SINGLE_VECTOR	0xfa
-#define	KDB_VECTOR			0xf9
 # define THERMAL_APIC_VECTOR		0xf0
 
 #else
@@ -79,10 +78,6 @@
 #define THERMAL_APIC_VECTOR		0xfa
 #define THRESHOLD_APIC_VECTOR		0xf9
 #define UV_BAU_MESSAGE			0xf8
-/* Overload KDB_VECTOR with UV_BAU_MESSAGE. By the time the UV hardware is
- * ready, we should have moved to a dynamically allocated vector scheme.
- */
-#define KDB_VECTOR			0xf8
 #define INVALIDATE_TLB_VECTOR_END	0xf7
 #define INVALIDATE_TLB_VECTOR_START	0xf0	/* f0-f7 used for TLB flush */
 
@@ -91,6 +86,12 @@
 #endif
 
 /*
+ * KDB_VECTOR will take over vector 0xfe when it is needed, as in theory
+ * it should not be used anyway.
+ */
+#define KDB_VECTOR			0xfe
+
+/*
  * Local APIC timer IRQ vector is on a different priority level,
  * to work around the 'lost local interrupt if more than 2 IRQ
  * sources per level' errata.
Index: linux/kdb/kdbmain.c
===================================================================
--- linux.orig/kdb/kdbmain.c	2008-10-29 17:19:18.000000000 -0700
+++ linux/kdb/kdbmain.c	2008-10-29 17:21:15.988622448 -0700
@@ -1666,6 +1666,8 @@ kdb_wait_for_cpus(void)
 					wait == 1 ? " is" : "s are",
 					wait == 1 ? "its" : "their");
 	}
+	/* give back the vector we took over in smp_kdb_stop */
+	kdba_giveback_vector(KDB_VECTOR);
 #endif	/* CONFIG_SMP */
 }
 
Index: linux/arch/ia64/include/asm/kdb.h
===================================================================
--- linux.orig/arch/ia64/include/asm/kdb.h	2008-10-28 17:17:26.000000000 -0700
+++ linux/arch/ia64/include/asm/kdb.h	2008-10-29 17:21:16.008622818 -0700
@@ -43,4 +43,6 @@ kdba_funcptr_value(void *fp)
 	return *(unsigned long *)fp;
 }
 
+#define kdba_giveback_vector(vector) (0)
+
 #endif	/* !_ASM_KDB_H */
Index: linux/include/asm-x86/kdb.h
===================================================================
--- linux.orig/include/asm-x86/kdb.h	2008-10-28 17:17:27.000000000 -0700
+++ linux/include/asm-x86/kdb.h	2008-10-29 17:21:16.028623187 -0700
@@ -133,4 +133,6 @@ kdba_funcptr_value(void *fp)
 	return (unsigned long)fp;
 }
 
+extern void kdba_giveback_vector(int);
+
 #endif	/* !_ASM_KDB_H */


---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.


More information about the kdb mailing list