From: Keith Owens <kaos@sgi.com>
To: linux-arch@vger.kernel.org
Cc: Keith Owens <kaos@sgi.com>
Subject: [patch 2.6.19-rc5 4/12] crash_stop: i386 specific code
Date: Thu, 09 Nov 2006 15:04:41 +1100 [thread overview]
Message-ID: <20061109040441.17391.12845.sendpatchset@chook.melbourne.sgi.com> (raw)
In-Reply-To: <20061109040418.17391.16362.sendpatchset@chook.melbourne.sgi.com>
Add the i386 specific crash_stop code. This contains routines that are
called from the common crash_stop code and from the i386 notify_die
chain.
Note: Not tested on visw nor voyager, no hardware.
Signed-off-by: Keith Owens <kaos@sgi.com>
---
arch/i386/kernel/Makefile | 1
arch/i386/kernel/crash_stop.c | 127 ++++++++++++++++++++++++++++++++++++++++++
include/asm-i386/crash_stop.h | 14 ++++
3 files changed, 142 insertions(+)
Index: linux/arch/i386/kernel/Makefile
===================================================================
--- linux.orig/arch/i386/kernel/Makefile
+++ linux/arch/i386/kernel/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_VM86) += vm86.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_HPET_TIMER) += hpet.o
obj-$(CONFIG_K8_NB) += k8.o
+obj-$(CONFIG_CRASH_STOP_SUPPORTED) += crash_stop.o
EXTRA_AFLAGS := -traditional
Index: linux/arch/i386/kernel/crash_stop.c
===================================================================
--- /dev/null
+++ linux/arch/i386/kernel/crash_stop.c
@@ -0,0 +1,127 @@
+/*
+ * linux/arch/i386/crash_stop.c
+ *
+ * Copyright (C) 2006 Keith Owens <kaos@sgi.com>
+ *
+ * The i386 specific bits of the crash_stop code. There is a little bit of
+ * crash_stop code in arch/i386/kernel/{smp,smpboot}.c to handle
+ * CRASH_STOP_VECTOR, everything else is in this file.
+ */
+
+#include <linux/crash_stop.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/ptrace.h>
+#include <asm/kdebug.h>
+
+/* The starting point for a backtrace on a running process is set to
+ * cs_arch_cpu(). It would be nice to go up a couple of levels to start the
+ * backtrace where crash_stop() or cs_common_ipi() were invoked, but that is
+ * more work than I am willing to do in this function. Starting the backtrace
+ * at cs_arch_cpu() is simple and reliable, which is exactly what we want when
+ * the machine is already failing.
+ */
+void
+cs_arch_cpu(int monarch, struct crash_stop_running_process *r)
+{
+ r->arch.esp = current_stack_pointer;
+ r->arch.eip = (unsigned long)current_text_addr();
+ /* separate any stack changes from current_stack_pointer above */
+ barrier();
+ cs_common_cpu(monarch);
+}
+
+/* Called at the start of a notify_chain. */
+static int
+cs_arch_notify_start(struct notifier_block *self,
+ unsigned long val, void *data)
+{
+ struct die_args *args = data;
+ switch(val) {
+ case DIE_OOPS:
+ case DIE_NMIWATCHDOG:
+ cs_notify_chain_start(args->regs);
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+/* Called at the end of a notify_chain. */
+static int
+cs_arch_notify_end(struct notifier_block *self,
+ unsigned long val, void *data)
+{
+ switch(val) {
+ case DIE_OOPS:
+ case DIE_NMIWATCHDOG:
+ cs_notify_chain_end();
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+/* Pick up any NMI IPIs that were sent by crash_stop. */
+static int
+cs_arch_notify_nmi(struct notifier_block *self,
+ unsigned long val, void *data)
+{
+ switch(val) {
+ case DIE_NMI_IPI:
+ if (crash_stop_sent_nmi()) {
+ crash_stop_slave();
+ return NOTIFY_STOP;
+ }
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block cs_arch_nb_start = {
+ .notifier_call = cs_arch_notify_start,
+ .priority = ~0U >> 1,
+};
+
+static struct notifier_block cs_arch_nb_end = {
+ .notifier_call = cs_arch_notify_end,
+ .priority = 1,
+};
+
+static struct notifier_block cs_arch_nb_nmi = {
+ .notifier_call = cs_arch_notify_nmi,
+ .priority = 10,
+};
+
+static int __init
+cs_arch_init(void)
+{
+ int err;
+ const char *nb_name;
+ nb_name = "cs_arch_nb_start";
+ if ((err = register_die_notifier(&cs_arch_nb_start)))
+ goto error;
+ nb_name = "cs_arch_nb_end";
+ if ((err = register_die_notifier(&cs_arch_nb_end)))
+ goto error;
+ nb_name = "cs_arch_nb_nmi";
+ if ((err = register_die_notifier(&cs_arch_nb_nmi)))
+ goto error;
+ return 0;
+error:
+ printk(KERN_ERR "Failed to register %s\n", nb_name);
+ unregister_die_notifier(&cs_arch_nb_start);
+ unregister_die_notifier(&cs_arch_nb_end);
+ unregister_die_notifier(&cs_arch_nb_nmi);
+ return err;
+}
+
+static void __exit
+cs_arch_exit(void)
+{
+ unregister_die_notifier(&cs_arch_nb_nmi);
+ unregister_die_notifier(&cs_arch_nb_start);
+ unregister_die_notifier(&cs_arch_nb_end);
+ return;
+}
+
+module_init(cs_arch_init);
+module_exit(cs_arch_exit);
Index: linux/include/asm-i386/crash_stop.h
===================================================================
--- /dev/null
+++ linux/include/asm-i386/crash_stop.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_CRASH_STOP_H
+#define _ASM_CRASH_STOP_H
+
+/* CONFIG_4KSTACKS means that the registers (including eip) at the time of the
+ * interrupt can be on one stack while the crash_stop code is running on
+ * another stack. We have to save the current esp and eip.
+ */
+struct crash_stop_running_process_arch
+{
+ unsigned long esp;
+ unsigned long eip;
+};
+
+#endif /* _ASM_CRASH_STOP_H */
next prev parent reply other threads:[~2006-11-09 4:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-09 4:04 [patch 2.6.19-rc5 0/12] crash_stop: Summary Keith Owens
2006-11-09 4:04 ` [patch 2.6.19-rc5 1/12] crash_stop: common header Keith Owens
2006-11-09 4:04 ` [patch 2.6.19-rc5 2/12] crash_stop: common code Keith Owens
2006-11-09 4:04 ` [patch 2.6.19-rc5 3/12] crash_stop: i386 interrupt handlers Keith Owens
2006-11-09 4:04 ` Keith Owens [this message]
2006-11-09 4:04 ` [patch 2.6.19-rc5 5/12] crash_stop: add DIE_NMIWATCHDOG to x86_64 Keith Owens
2006-11-09 4:04 ` [patch 2.6.19-rc5 6/12] crash_stop: x86_64 interrupt handlers Keith Owens
2006-11-09 4:04 ` [patch 2.6.19-rc5 7/12] crash_stop: x86_64 specific code Keith Owens
2006-11-09 4:05 ` [patch 2.6.19-rc5 8/12] crash_stop: ia64 interrupt handlers Keith Owens
2006-11-09 4:05 ` [patch 2.6.19-rc5 9/12] crash_stop: ia64 specific code Keith Owens
2006-11-09 4:05 ` [patch 2.6.19-rc5 10/12] crash_stop: add to config system Keith Owens
2006-11-09 4:05 ` [patch 2.6.19-rc5 11/12] crash_stop: demonstration code Keith Owens
2006-11-09 4:05 ` [patch 2.6.19-rc5 12/12] crash_stop: test code Keith Owens
2006-11-11 1:45 ` [patch 2.6.19-rc5 0/12] crash_stop: Summary Vivek Goyal
2006-11-13 2:08 ` Keith Owens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061109040441.17391.12845.sendpatchset@chook.melbourne.sgi.com \
--to=kaos@sgi.com \
--cc=linux-arch@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.