# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 6a28bfc1a940aa02dce3fa53aea11c0e06f67a91
# Parent 70155087efe89a741ca9eb5e3d7ebadaafabd3dc
[KEXEC] Clean up kexec code and fix panic-induced reboot when
kdump is not in use.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
xen/arch/x86/crash.c | 19 +++------
xen/arch/x86/traps.c | 2
xen/common/kexec.c | 94 ++++++++++++++++++---------------------------
xen/drivers/char/console.c | 2
xen/include/xen/kexec.h | 8 +--
5 files changed, 52 insertions(+), 73 deletions(-)
diff -r 70155087efe8 -r 6a28bfc1a940 xen/arch/x86/crash.c
--- a/xen/arch/x86/crash.c Thu Dec 14 14:13:18 2006 +0000
+++ b/xen/arch/x86/crash.c Thu Dec 14 15:06:22 2006 +0000
@@ -28,6 +28,7 @@
#include <asm/hvm/hvm.h>
static atomic_t waiting_for_crash_ipi;
+static unsigned int crashing_cpu;
static int crash_nmi_callback(struct cpu_user_regs *regs, int cpu)
{
@@ -39,7 +40,7 @@ static int crash_nmi_callback(struct cpu
return 1;
local_irq_disable();
- machine_crash_save_cpu();
+ kexec_crash_save_cpu();
disable_local_APIC();
atomic_dec(&waiting_for_crash_ipi);
hvm_disable();
@@ -67,6 +68,8 @@ static void nmi_shootdown_cpus(void)
{
unsigned long msecs;
+ crashing_cpu = smp_processor_id();
+
atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
/* Would it be better to replace the trap vector here? */
set_nmi_callback(crash_nmi_callback);
@@ -86,18 +89,10 @@ static void nmi_shootdown_cpus(void)
disable_local_APIC();
}
-static void crash_save_xen_notes(void)
+void machine_crash_shutdown(void)
{
crash_xen_info_t *info;
- info = machine_crash_save_info();
-
- info->dom0_pfn_to_mfn_frame_list_list = \
- dom0->shared_info->arch.pfn_to_mfn_frame_list_list;
-}
-
-void machine_crash_shutdown(void)
-{
local_irq_disable();
nmi_shootdown_cpus();
@@ -106,7 +101,9 @@ void machine_crash_shutdown(void)
hvm_disable();
- crash_save_xen_notes();
+ info = kexec_crash_save_info();
+ info->dom0_pfn_to_mfn_frame_list_list =
+ dom0->shared_info->arch.pfn_to_mfn_frame_list_list;
}
/*
diff -r 70155087efe8 -r 6a28bfc1a940 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c Thu Dec 14 14:13:18 2006 +0000
+++ b/xen/arch/x86/traps.c Thu Dec 14 15:06:22 2006 +0000
@@ -1665,7 +1665,7 @@ static void unknown_nmi_error(unsigned c
printk("Uhhuh. NMI received for unknown reason %02x.\n", reason);
printk("Dazed and confused, but trying to continue\n");
printk("Do you have a strange power saving mode enabled?\n");
- machine_crash_kexec();
+ kexec_crash();
}
}
diff -r 70155087efe8 -r 6a28bfc1a940 xen/common/kexec.c
--- a/xen/common/kexec.c Thu Dec 14 14:13:18 2006 +0000
+++ b/xen/common/kexec.c Thu Dec 14 15:06:22 2006 +0000
@@ -24,7 +24,6 @@
DEFINE_PER_CPU (crash_note_t, crash_notes);
cpumask_t crash_saved_cpus;
-int crashing_cpu;
xen_kexec_image_t kexec_image[KEXEC_IMAGE_NR];
@@ -58,38 +57,34 @@ custom_param("crashkernel", parse_crashk
static void one_cpu_only(void)
{
- /* Only allow the first cpu to continue - force other cpus to spin */
+ /* Only allow the first cpu to continue - force other cpus to spin */
if ( test_and_set_bit(KEXEC_FLAG_IN_PROGRESS, &kexec_flags) )
- {
- while (1);
- }
-}
-
-/* Save the registers in the per-cpu crash note buffer */
-
-void machine_crash_save_cpu(void)
+ for ( ; ; ) ;
+}
+
+/* Save the registers in the per-cpu crash note buffer. */
+void kexec_crash_save_cpu(void)
{
int cpu = smp_processor_id();
crash_note_t *cntp;
- if ( !cpu_test_and_set(cpu, crash_saved_cpus) )
- {
- cntp = &per_cpu(crash_notes, cpu);
- elf_core_save_regs(&cntp->core.desc.desc.pr_reg,
- &cntp->xen_regs.desc.desc);
-
- /* setup crash "CORE" note */
- setup_crash_note(cntp, core, CORE_STR, CORE_STR_LEN, NT_PRSTATUS);
-
- /* setup crash note "Xen", XEN_ELFNOTE_CRASH_REGS */
- setup_crash_note(cntp, xen_regs, XEN_STR, XEN_STR_LEN,
- XEN_ELFNOTE_CRASH_REGS);
- }
-}
-
-/* Setup the single Xen specific info crash note */
-
-crash_xen_info_t *machine_crash_save_info(void)
+ if ( cpu_test_and_set(cpu, crash_saved_cpus) )
+ return;
+
+ cntp = &per_cpu(crash_notes, cpu);
+ elf_core_save_regs(&cntp->core.desc.desc.pr_reg,
+ &cntp->xen_regs.desc.desc);
+
+ /* Set up crash "CORE" note. */
+ setup_crash_note(cntp, core, CORE_STR, CORE_STR_LEN, NT_PRSTATUS);
+
+ /* Set up crash note "Xen", XEN_ELFNOTE_CRASH_REGS. */
+ setup_crash_note(cntp, xen_regs, XEN_STR, XEN_STR_LEN,
+ XEN_ELFNOTE_CRASH_REGS);
+}
+
+/* Set up the single Xen-specific-info crash note. */
+crash_xen_info_t *kexec_crash_save_info(void)
{
int cpu = smp_processor_id();
crash_note_t *cntp;
@@ -99,7 +94,7 @@ crash_xen_info_t *machine_crash_save_inf
cntp = &per_cpu(crash_notes, cpu);
- /* setup crash note "Xen", XEN_ELFNOTE_CRASH_INFO */
+ /* Set up crash note "Xen", XEN_ELFNOTE_CRASH_INFO. */
setup_crash_note(cntp, xen_info, XEN_STR, XEN_STR_LEN,
XEN_ELFNOTE_CRASH_INFO);
@@ -117,45 +112,34 @@ crash_xen_info_t *machine_crash_save_inf
return info;
}
-void machine_crash_kexec(void)
+void kexec_crash(void)
{
int pos;
- xen_kexec_image_t *image;
+
+ pos = (test_bit(KEXEC_FLAG_CRASH_POS, &kexec_flags) != 0);
+ if ( !test_bit(KEXEC_IMAGE_CRASH_BASE + pos, &kexec_flags) )
+ return;
one_cpu_only();
-
- machine_crash_save_cpu();
- crashing_cpu = smp_processor_id();
-
+ kexec_crash_save_cpu();
machine_crash_shutdown();
- pos = (test_bit(KEXEC_FLAG_CRASH_POS, &kexec_flags) != 0);
-
- if ( test_bit(KEXEC_IMAGE_CRASH_BASE + pos, &kexec_flags) )
- {
- image = &kexec_image[KEXEC_IMAGE_CRASH_BASE + pos];
- machine_kexec(image); /* Does not return */
- }
+ machine_kexec(&kexec_image[KEXEC_IMAGE_CRASH_BASE + pos]);
+
+ BUG();
}
static void do_crashdump_trigger(unsigned char key)
{
- int pos = (test_bit(KEXEC_FLAG_CRASH_POS, &kexec_flags) != 0);
- if ( test_bit(KEXEC_IMAGE_CRASH_BASE + pos, &kexec_flags) )
- {
- printk("'%c' pressed -> triggering crashdump\n", key);
- machine_crash_kexec();
- }
- else
- {
- printk("'%c' pressed -> no crash kernel loaded -- not triggering
crashdump\n", key);
- }
+ printk("'%c' pressed -> triggering crashdump\n", key);
+ kexec_crash();
+ printk(" * no crash kernel loaded!\n");
}
static __init int register_crashdump_trigger(void)
{
- register_keyhandler('C', do_crashdump_trigger, "trigger a crashdump");
- return 0;
+ register_keyhandler('C', do_crashdump_trigger, "trigger a crashdump");
+ return 0;
}
__initcall(register_crashdump_trigger);
@@ -303,7 +287,7 @@ static int kexec_exec(XEN_GUEST_HANDLE(v
machine_reboot_kexec(image); /* Does not return */
break;
case KEXEC_TYPE_CRASH:
- machine_crash_kexec(); /* Does not return */
+ kexec_crash(); /* Does not return */
break;
}
diff -r 70155087efe8 -r 6a28bfc1a940 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c Thu Dec 14 14:13:18 2006 +0000
+++ b/xen/drivers/char/console.c Thu Dec 14 15:06:22 2006 +0000
@@ -866,7 +866,7 @@ void panic(const char *fmt, ...)
debugger_trap_immediate();
- machine_crash_kexec();
+ kexec_crash();
if ( opt_noreboot )
{
diff -r 70155087efe8 -r 6a28bfc1a940 xen/include/xen/kexec.h
--- a/xen/include/xen/kexec.h Thu Dec 14 14:13:18 2006 +0000
+++ b/xen/include/xen/kexec.h Thu Dec 14 15:06:22 2006 +0000
@@ -4,8 +4,6 @@
#include <public/kexec.h>
#include <asm/percpu.h>
#include <xen/elfcore.h>
-
-extern int crashing_cpu;
typedef struct xen_kexec_reserve {
unsigned long size;
@@ -27,9 +25,9 @@ void machine_kexec_unload(int type, int
void machine_kexec_unload(int type, int slot, xen_kexec_image_t *image);
void machine_kexec_reserved(xen_kexec_reserve_t *reservation);
void machine_reboot_kexec(xen_kexec_image_t *image);
-void machine_crash_kexec(void);
-void machine_crash_save_cpu(void);
-crash_xen_info_t *machine_crash_save_info(void);
+void kexec_crash(void);
+void kexec_crash_save_cpu(void);
+crash_xen_info_t *kexec_crash_save_info(void);
void machine_crash_shutdown(void);
#endif /* __XEN_KEXEC_H__ */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|