Skip to contentSkip to conversation

kexec/kdump update (2006-08-17.00)

PATCH In review [email protected] 1 participant 1 message Aug 17, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/5 kexec/kdump update (2006-08-17.00)

Quoted 54 lines

Archived-At: <http://permalink.gmane.org/gmane.linux.ports.ia64/14677>

This patch is the kexec-kdump patch re-based to 2.6.18-rc4 kernel.

Changes since last patch include:

1. re-base the patch to 2.6.18-rc4
2. per-cpu register dumping, so that user space tool can unwind kernel stack. This should really done by INIT event. But unfortunately it seems that the firmware on the machine I am using does not handle INIT event correctly... So current I dump per-cpu registers by simple IPI.

3. fix on_line_cpu issue,
previous patch stop APs by smp_send_stop. AP will clear his bit in cpu_online_map, then crash tools will see a cpu_online_map which only contains 1 cpu in vmcore file.

4. reserve efi memmap area and ia64 boot param area for the first kernel.

To test crash dump.

Compile a kernel with CONFIG_KEXEC CONFIG_CRASH_DUMP CONFIG_PROC_VMCORE enabled.

using this kernel for both host kernel and crash dumping kernel.

Boot this kernel with kernel parameter "crashkernel=XXX@YYY".
XXX should be a size big enough for crash kernel to run, YYY should be a physical address which contains more than XXX memory and aligned to 64M. you can check it in /proc/iomem.
Be careful of choosing the size and address to reserve.
The second kernel may hang silently if there is too few memory to use.

After the first kernel boots, the "Crash kernel" region will show in /proc/iomem. then load the same kernel with command.

kexec -p vmlinux.gz --initrd=initrd --append="root=... maxcpus=1"

trigger a crash with echo c > /proc/sysrq-trigger

after the crash kernel boots,
copy /proc/vmcore to disk

gdb vmlinux-of-first-kernel vmcore
then you can check the stack and variables of first kernel.

kexec -l + kexec -e may not work.
That is because of a recent change in mpt-fusion driver
shutdown code.
There was some delay in mptscsih_remove path.
the code was removed in 2.6.17, that cause MPT fusion driver unable to reinitialize. add a delay back to mptscsih_remove can solve this problem.

Quoted 2 lines

Signed-off-by:
Zou Nan hai <[email protected]>

Incremental version of the patch posted by Zou Nan hai

 arch/ia64/kernel/crash.c           |   77 ++++++------------
 arch/ia64/kernel/efi.c             |    2 
 arch/ia64/kernel/machine_kexec.c   |   66 ++++++++++------
 arch/ia64/kernel/relocate_kernel.S |  147 ++++++++++++++++++++++++++++++++++--
 arch/ia64/kernel/setup.c           |    9 ++
 arch/ia64/kernel/smp.c             |   18 ++++
 include/asm-ia64/kexec.h           |    6 +
 include/linux/irq.h                |    1 
 kernel/irq/manage.c                |   13 ---
 9 files changed, 243 insertions(+), 96 deletions(-)
arch/ia64/kernel/crash.c +27 -50
index a1a192c..5b7514c 100644
@@ -43,25 +43,23 @@ size_t copy_oldmem_page(unsigned long pf
 
 static void device_shootdown(void)
 {
-       struct pci_dev *dev;
-       irq_desc_t *desc;
-       u16 pci_command;
+	irq_desc_t *idesc;
+	int irq;
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		idesc = irq_desc + irq;
+		if (!idesc || !idesc->action)
+			continue;
+		disable_irq_nosync(irq);
+		idesc->chip->end(irq);
+		idesc->chip->shutdown(irq);
+	}
 
-       list_for_each_entry(dev, &pci_devices, global_list) {
-	       desc = irq_desc + dev->irq;
-               if (!desc->action)
-                       continue;
-               pci_read_config_word(dev, PCI_COMMAND, &pci_command);
-               if (pci_command & PCI_COMMAND_MASTER) {
-                       pci_command &= ~PCI_COMMAND_MASTER;
-                       pci_write_config_word(dev, PCI_COMMAND, pci_command);
-               }
-               disable_irq_nosync(dev->irq);
-               desc->chip->end(dev->irq);
-       }
+#ifdef CONFIG_IA64_HP_ZX1
+	ioc_iova_disable();
+#endif
 }
 
-static Elf64_Word
+static inline Elf64_Word
 *append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
 		size_t data_len)
 {
@@ -83,41 +81,25 @@ final_note(void *buf)
 	memset(buf, 0, sizeof(struct elf_note));
 }
 
-static void
-crash_save_this_cpu(void)
+extern void ia64_dump_cpu_regs(void *);
+
+void
+crash_save_this_cpu()
 {
 	void *buf;
 	struct elf_prstatus prstatus;
 	int cpu = smp_processor_id();
+	unsigned long cfm, sof, sol;
 	elf_greg_t *dst = (elf_greg_t *)&prstatus.pr_reg;
-
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 
-    	dst[1] = ia64_getreg(_IA64_REG_GP);
-    	dst[12] = ia64_getreg(_IA64_REG_SP);
-    	dst[13] = ia64_getreg(_IA64_REG_TP);
-
-    	dst[42] = ia64_getreg(_IA64_REG_IP);
-    	dst[45] = ia64_getreg(_IA64_REG_AR_RSC);
-
-	ia64_setreg(_IA64_REG_AR_RSC, 0);
-	ia64_srlz_i();
-
-    	dst[46] = ia64_getreg(_IA64_REG_AR_BSP);
-    	dst[47] = ia64_getreg(_IA64_REG_AR_BSPSTORE);
-
-    	dst[48] = ia64_getreg(_IA64_REG_AR_RNAT);
-    	dst[49] = ia64_getreg(_IA64_REG_AR_CCV);
-    	dst[50] = ia64_getreg(_IA64_REG_AR_UNAT);
-
-    	dst[51] = ia64_getreg(_IA64_REG_AR_FPSR);
-    	dst[52] = ia64_getreg(_IA64_REG_AR_PFS);
-    	dst[53] = ia64_getreg(_IA64_REG_AR_LC);
-
-    	dst[54] = ia64_getreg(_IA64_REG_AR_LC);
-    	dst[55] = ia64_getreg(_IA64_REG_AR_CSD);
-    	dst[56] = ia64_getreg(_IA64_REG_AR_SSD);
+	ia64_dump_cpu_regs(dst);
+        cfm = dst[43];
+        sol = (cfm >> 7) & 0x7f;
+        sof = cfm & 0x7f;
+        dst[46] = (unsigned long)ia64_rse_skip_regs((unsigned long *)dst[46],
+                        sof - sol);
 
         buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
@@ -138,15 +120,10 @@ machine_crash_shutdown(struct pt_regs *p
 	 * In practice this means shooting down the other cpus in
 	 * an SMP system.
 	 */
-	if (in_interrupt()) {
+	if (in_interrupt())
 		ia64_eoi();
-	}
-	crash_save_this_cpu();
 	device_shootdown();
 #ifdef CONFIG_SMP
-	smp_send_stop();
-#endif
-#ifdef CONFIG_IA64_HP_ZX1
-	ioc_iova_disable();
+	kdump_smp_send_stop();
 #endif
 }
arch/ia64/kernel/efi.c +2 -0
index 52729a9..6935452 100644
@@ -1124,6 +1124,8 @@ efi_initialize_iomem_resources(struct re
 			insert_resource(res, code_resource);
 			insert_resource(res, data_resource);
 #ifdef CONFIG_KEXEC
+                        insert_resource(res, &efi_memmap_res);
+                        insert_resource(res, &boot_param_res);
 			if (crashk_res.end > crashk_res.start)
 				insert_resource(res, &crashk_res);
 #endif
arch/ia64/kernel/entry.S +0 -0
arch/ia64/kernel/machine_kexec.c +41 -25

108 lines not on this page · raw message

arch/ia64/kernel/relocate_kernel.S +142 -5

178 lines not on this page · raw message

arch/ia64/kernel/setup.c +9 -0
index 74821be..14ee171 100644
@@ -275,6 +275,15 @@ #ifdef CONFIG_KEXEC
 				n++;
 			}
 		}
+		efi_memmap_res.start = ia64_boot_param->efi_memmap;
+                efi_memmap_res.end = efi_memmap_res.start +
+                        ia64_boot_param->efi_memmap_size;
+                printk("efi_memmap start %lx %lx\n",
+                        efi_memmap_res.start,
+                        efi_memmap_res.end);
+                boot_param_res.start = __pa(ia64_boot_param);
+                boot_param_res.end = boot_param_res.start +
+                        sizeof(*ia64_boot_param);
 	}
 #endif
 
arch/ia64/kernel/smp.c +17 -1
index 6337278..dee9fd7 100644
@@ -67,6 +67,7 @@ static volatile struct call_data_struct 
 
 #define IPI_CALL_FUNC		0
 #define IPI_CPU_STOP		1
+#define IPI_KDUMP_CPU_STOP	3
 
 /* This needs to be cacheline aligned because it is written to by *other* CPUs.  */
 static DEFINE_PER_CPU(u64, ipi_operation) ____cacheline_aligned;
@@ -184,7 +185,15 @@ handle_IPI (int irq, void *dev_id, struc
 			      case IPI_CPU_STOP:
 				stop_this_cpu();
 				break;
-
+#ifdef CONFIG_CRASH_DUMP
+			      case IPI_KDUMP_CPU_STOP:
+				{
+					local_irq_disable();
+					crash_save_this_cpu();
+					cpu_halt();
+				}
+				break;
+#endif
 			      default:
 				printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", this_cpu, which);
 				break;
@@ -400,6 +409,13 @@ smp_send_stop (void)
 {
 	send_IPI_allbutself(IPI_CPU_STOP);
 }
+#ifdef CONFIG_CRASH_DUMP
+void
+kdump_smp_send_stop()
+{
+ 	send_IPI_allbutself(IPI_KDUMP_CPU_STOP);
+}
+#endif
 
 int __init
 setup_profiling_timer (unsigned int multiplier)
include/asm-ia64/kexec.h +5 -1
index d45c03f..a035136 100644
@@ -23,7 +23,7 @@ #define POW2(n)		(1ULL << (n))
 DECLARE_PER_CPU(u64, ia64_mca_pal_base);
 const extern unsigned int relocate_new_kernel_size;
 volatile extern long kexec_rendez;
-extern void relocate_new_kernel(unsigned long, unsigned long, 
+extern void relocate_new_kernel(unsigned long, unsigned long,
 		struct ia64_boot_param *, unsigned long);
 extern void kexec_fake_sal_rendez(void *start, unsigned long wake_up,
 		unsigned long pal_base);
@@ -31,4 +31,8 @@ static inline void
 crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs)
 {
 }
+extern struct resource efi_memmap_res;
+extern struct resource boot_param_res;
+extern void kdump_smp_send_stop(void);
+extern void crash_save_this_cpu(void);
 #endif /* _ASM_IA64_KEXEC_H */
include/asm-ia64/machvec_hpzx1.h +0 -0
include/asm-ia64/meminit.h +0 -0
include/asm-ia64/smp.h +0 -0
include/linux/irq.h +0 -1
index 9b5349f..fbf6d90 100644
@@ -182,7 +182,6 @@ typedef struct irq_desc		irq_desc_t;
 #include <asm/hw_irq.h>
 
 extern int setup_irq(unsigned int irq, struct irqaction *new);
-extern void terminate_irqs(void);
 
 #ifdef CONFIG_GENERIC_HARDIRQS
 
kernel/irq/manage.c +0 -13
index e058bad..a795d6f 100644
@@ -475,16 +475,3 @@ #endif
 	return retval;
 }
 EXPORT_SYMBOL(request_irq);
-
-/*
- * Terminate any outstanding interrupts
- */
-void terminate_irqs(void)
-{
-	irq_desc_t *desc = irq_desc;
-	int i;
-
-	for (i = 0; i < NR_IRQS; i++, desc++)
-		if (desc->action && desc->chip->end)
-			desc->chip->end(i);
-}

--

Signature · 3 lines
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/