Skip to contentSkip to conversation

IA64 Kdump patch V3

PATCH Zou Nan hai 2 participants 2 messages Aug 18, 2006

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

The fix and change in this patch include

1. According to suggestion from Dave,
I put an extra switch stack frame on each CPU to help crash utility to run bt command.

2. Fix issue reported by Fujitsu that crash kernel can't startup with CONFIG_SPARSEMEM

3. More simplified crash path.

arch/ia64/hp/common/sba_iommu.c +22 -0
diff -Nraup linux-2.6.18-rc4/arch/ia64/hp/common/sba_iommu.c linux-2.6.18-rc4-kdump/arch/ia64/hp/common/sba_iommu.c
@@ -1623,6 +1623,28 @@ ioc_iova_init(struct ioc *ioc)
 	READ_REG(ioc->ioc_hpa + IOC_IBASE);
 }
 
+#ifdef CONFIG_KEXEC
+void
+ioc_iova_disable(void)
+{
+	struct ioc *ioc;
+
+	ioc = ioc_list;
+
+	while (ioc != NULL) {
+		/* Disable IOVA translation */
+		WRITE_REG(ioc->ibase & 0xfffffffffffffffe, ioc->ioc_hpa + IOC_IBASE);
+		READ_REG(ioc->ioc_hpa + IOC_IBASE);
+
+		/* Clear I/O TLB of any possible entries */
+		WRITE_REG(ioc->ibase | (get_iovp_order(ioc->iov_size) + iovp_shift), ioc->ioc_hpa + IOC_PCOM);
+		READ_REG(ioc->ioc_hpa + IOC_PCOM);
+
+		ioc = ioc->next;
+	}
+}
+#endif
+
 static void __init
 ioc_resource_init(struct ioc *ioc)
 {
arch/ia64/Kconfig +23 -0
diff -Nraup linux-2.6.18-rc4/arch/ia64/Kconfig linux-2.6.18-rc4-kdump/arch/ia64/Kconfig
@@ -427,6 +427,29 @@ config SGI_SN
 
 source "drivers/sn/Kconfig"
 
+config KEXEC
+	bool "kexec system call (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	help
+	  kexec is a system call that implements the ability to shutdown your
+	  current kernel, and to start another kernel.  It is like a reboot
+	  but it is indepedent of the system firmware.   And like a reboot
+	  you can start any kernel with it, not just Linux.
+
+	  The name comes from the similiarity to the exec system call.
+
+	  It is an ongoing process to be certain the hardware in a machine
+	  is properly shutdown, so do not be surprised if this code does not
+	  initially work for you.  It may help to enable device hotplugging
+	  support.  As of this writing the exact hardware interface is
+	  strongly in flux, so no good recommendation can be made.
+
+config CRASH_DUMP
+	  bool "kernel crash dumps (EXPERIMENTAL)"
+	  depends on EXPERIMENTAL
+	  help
+	    Generate crash dump after being started by kexec.
+
 source "drivers/firmware/Kconfig"
 
 source "fs/Kconfig.binfmt"
arch/ia64/kernel/crash.c +119 -0

119 lines not on this page · raw message

arch/ia64/kernel/efi.c +16 -3
diff -Nraup linux-2.6.18-rc4/arch/ia64/kernel/efi.c linux-2.6.18-rc4-kdump/arch/ia64/kernel/efi.c
@@ -26,6 +26,7 @@
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/efi.h>
+#include <linux/kexec.h>
 
 #include <asm/io.h>
 #include <asm/kregs.h>
@@ -41,7 +42,7 @@ extern efi_status_t efi_call_phys (void 
 struct efi efi;
 EXPORT_SYMBOL(efi);
 static efi_runtime_services_t *runtime;
-static unsigned long mem_limit = ~0UL, max_addr = ~0UL;
+static unsigned long mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL;
 
 #define efi_call_virt(f, args...)	(*(f))(args)
 
@@ -421,6 +422,8 @@ efi_init (void)
 			mem_limit = memparse(cp + 4, &cp);
 		} else if (memcmp(cp, "max_addr=", 9) = 0) {
 			max_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
+		} else if (memcmp(cp, "min_addr=", 9) = 0) {
+			min_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
 		} else {
 			while (*cp != ' ' && *cp)
 				++cp;
@@ -428,6 +431,8 @@ efi_init (void)
 				++cp;
 		}
 	}
+	if (min_addr != 0UL)
+		printk(KERN_INFO "Ignoring memory below %luMB\n", min_addr >> 20);
 	if (max_addr != ~0UL)
 		printk(KERN_INFO "Ignoring memory above %luMB\n", max_addr >> 20);
 
@@ -894,7 +899,8 @@ find_memmap_space (void)
 		as = max(contig_low, md->phys_addr);
 		ae = min(contig_high, efi_md_end(md));
 
-		/* keep within max_addr= command line arg */
+		/* keep within max_addr= and min_addr= command line arg */
+		as = max(as, min_addr);
 		ae = min(ae, max_addr);
 		if (ae <= as)
 			continue;
@@ -1004,7 +1010,8 @@ efi_memmap_init(unsigned long *s, unsign
 		} else
 			ae = efi_md_end(md);
 
-		/* keep within max_addr= command line arg */
+		/* keep within max_addr= and min_addr= command line arg */
+		as = max(as, min_addr);
 		ae = min(ae, max_addr);
 		if (ae <= as)
 			continue;
@@ -1116,6 +1123,12 @@ 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 +1 -1
diff -Nraup linux-2.6.18-rc4/arch/ia64/kernel/entry.S linux-2.6.18-rc4-kdump/arch/ia64/kernel/entry.S
@@ -1575,7 +1575,7 @@ sys_call_table:
 	data8 sys_mq_timedreceive		// 1265
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
-	data8 sys_ni_syscall			// reserved for kexec_load
+	data8 sys_kexec_load
 	data8 sys_ni_syscall			// reserved for vserver
 	data8 sys_waitid			// 1270
 	data8 sys_add_key
arch/ia64/kernel/iosapic.c +19 -0
diff -Nraup linux-2.6.18-rc4/arch/ia64/kernel/iosapic.c linux-2.6.18-rc4-kdump/arch/ia64/kernel/iosapic.c
@@ -288,6 +288,25 @@ nop (unsigned int irq)
 	/* do nothing... */
 }
 
+#ifdef CONFIG_CRASH_DUMP
+void
+kdump_disable_iosapic(void)
+{
+	u32 low32;
+	struct iosapic_intr_info *info;
+	struct iosapic_rte_info *rte;
+	for (info = iosapic_intr_info; info <
+			iosapic_intr_info + IA64_NUM_VECTORS; ++info) {
+		low32 = info->low32 |= IOSAPIC_MASK;
+		list_for_each_entry(rte, &info->rtes,
+				rte_list) {
+			iosapic_write(rte->addr,
+					IOSAPIC_RTE_LOW(rte->rte_index), low32);
+		}
+	}
+}
+#endif
+
 static void
 mask_irq (unsigned int irq)
 {
arch/ia64/kernel/machine_kexec.c +139 -0

139 lines not on this page · raw message

arch/ia64/kernel/Makefile +1 -0
diff -Nraup linux-2.6.18-rc4/arch/ia64/kernel/Makefile linux-2.6.18-rc4-kdump/arch/ia64/kernel/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)	+= mca_recovery.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o jprobes.o
+obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o crash.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)	+= uncached.o
 obj-$(CONFIG_AUDIT)		+= audit.o
 mca_recovery-y			+= mca_drv.o mca_drv_asm.o
arch/ia64/kernel/relocate_kernel.S +490 -0

490 lines not on this page · raw message

arch/ia64/kernel/setup.c +42 -0

60 lines not on this page · raw message

arch/ia64/kernel/smp.c +54 -1

91 lines not on this page · raw message

include/asm-ia64/kexec.h +40 -0
diff -Nraup linux-2.6.18-rc4/include/asm-ia64/kexec.h linux-2.6.18-rc4-kdump/include/asm-ia64/kexec.h
@@ -0,0 +1,40 @@
+#ifndef _ASM_IA64_KEXEC_H
+#define _ASM_IA64_KEXEC_H
+
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
+
+#define KEXEC_CONTROL_CODE_SIZE (8192 + 8192 + 4096)
+
+/* The native architecture */
+#define KEXEC_ARCH KEXEC_ARCH_IA_64
+
+#define MAX_NOTE_BYTES 1024
+
+#define pte_bits	3
+#define vmlpt_bits	(impl_va_bits - PAGE_SHIFT + pte_bits)
+#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,
+		struct ia64_boot_param *, unsigned long);
+extern void kexec_fake_sal_rendez(void *start, unsigned long wake_up,
+		unsigned long pal_base);
+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 kdump_disable_iosapic(void);
+extern void crash_save_this_cpu(void);
+
+#endif /* _ASM_IA64_KEXEC_H */
include/asm-ia64/machvec_hpzx1.h +2 -0
diff -Nraup linux-2.6.18-rc4/include/asm-ia64/machvec_hpzx1.h linux-2.6.18-rc4-kdump/include/asm-ia64/machvec_hpzx1.h
@@ -34,4 +34,6 @@ extern ia64_mv_dma_mapping_error	sba_dma
 #define platform_dma_supported			sba_dma_supported
 #define platform_dma_mapping_error		sba_dma_mapping_error
 
+extern void ioc_iova_disable(void);
+
 #endif /* _ASM_IA64_MACHVEC_HPZX1_h */
include/asm-ia64/meminit.h +2 -1
diff -Nraup linux-2.6.18-rc4/include/asm-ia64/meminit.h linux-2.6.18-rc4-kdump/include/asm-ia64/meminit.h
@@ -15,11 +15,12 @@
  * 	- initrd (optional)
  * 	- command line string
  * 	- kernel code & data
+ * 	- crash dumping code reserved region
  * 	- Kernel memory map built from EFI memory map
  *
  * More could be added if necessary
  */
-#define IA64_MAX_RSVD_REGIONS 6
+#define IA64_MAX_RSVD_REGIONS 7
 
 struct rsvd_region {
 	unsigned long start;	/* virtual address of beginning of element */
include/asm-ia64/smp.h +3 -0
diff -Nraup linux-2.6.18-rc4/include/asm-ia64/smp.h linux-2.6.18-rc4-kdump/include/asm-ia64/smp.h
@@ -128,6 +128,9 @@ extern void smp_send_reschedule (int cpu
 extern void lock_ipi_calllock(void);
 extern void unlock_ipi_calllock(void);
 extern void identify_siblings (struct cpuinfo_ia64 *);
+#ifdef CONFIG_KEXEC
+extern void kexec_stop_this_cpu(void *);
+#endif
 
 #else
 
kernel/irq/manage.c +0 -1
diff -Nraup linux-2.6.18-rc4/kernel/irq/manage.c linux-2.6.18-rc4-kdump/kernel/irq/manage.c
@@ -475,4 +475,3 @@ int request_irq(unsigned int irq,
 	return retval;
 }
 EXPORT_SYMBOL(request_irq);
-
#1 lore raw

Here is an incremental version of this patch, it should append as patch 6 to the 5 patch series that I posted yeterday.

http://permalink.gmane.org/gmane.comp.boot-loaders.fastboot.general/1407

I have also made the series of patches available at

http://www.vergenet.net/~horms/patches/ia64-kexec/kernel/

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

[IA64] Kdump patch V3
Quoted 10 lines

Archived-At: http://permalink.gmane.org/gmane.linux.ports.ia64/14717

IA64 Kdump patch V3

The fix and change in this patch include

1. According to suggestion from Dave,
I put an extra switch stack frame on each CPU to help crash utility to run bt command.

Quoted 7 lines

2. Fix issue reported by Fujitsu that crash kernel can't startup with CONFIG_SPARSEMEM

3. More simplified crash path.

Incremental version of the above patch

Index: linux-2.6-ia64/arch/ia64/kernel/crash.c
=================================--- linux-2.6-ia64.orig/arch/ia64/kernel/crash.c 2006-08-18 20:52:17.000000000 +0900
+++ linux-2.6-ia64/arch/ia64/kernel/crash.c 2006-08-18 20:52:35.000000000 +0900
@@ -30,8 +30,7 @@

         if (!csize)
                 return 0;
-        vaddr = page_address(pfn_to_page(pfn));
-
+        vaddr = __va(pfn<<PAGE_SHIFT);
         if (userbuf) {
                 if (copy_to_user(buf, (vaddr + offset), csize)) {
                         return -EFAULT;

@@ -43,13 +42,7 @@

static void device_shootdown(void)
{
- irq_desc_t *idesc;
- int irq;
- for (irq = 0; irq < NR_IRQS; irq++) {
- idesc = irq_desc + irq;
- if (idesc)
- kdump_disable_irq(irq);
- }
+ kdump_disable_iosapic();
#ifdef CONFIG_IA64_HP_ZX1
ioc_iova_disable();
#endif
@@ -122,4 +115,5 @@
#ifdef CONFIG_SMP
kdump_smp_send_stop();
#endif
+ udelay(1000000);
}
Index: linux-2.6-ia64/arch/ia64/kernel/iosapic.c
=================================--- linux-2.6-ia64.orig/arch/ia64/kernel/iosapic.c 2006-08-18 20:52:18.000000000 +0900
+++ linux-2.6-ia64/arch/ia64/kernel/iosapic.c 2006-08-18 20:52:35.000000000 +0900
@@ -290,18 +290,19 @@

#ifdef CONFIG_CRASH_DUMP
void
-kdump_disable_irq(unsigned int irq)
+kdump_disable_iosapic(void)
{
u32 low32;
- ia64_vector vec = irq_to_vector(irq);
+ struct iosapic_intr_info *info;
struct iosapic_rte_info *rte;
-
- low32 = iosapic_intr_info[vec].low32 |= IOSAPIC_MASK;
- list_for_each_entry(rte, &iosapic_intr_info[vec].rtes,
- rte_list) {
+ for (info = iosapic_intr_info; info <
+ iosapic_intr_info + IA64_NUM_VECTORS; ++info) {
+ low32 = info->low32 |= IOSAPIC_MASK;
+ list_for_each_entry(rte, &info->rtes,
+ rte_list) {
iosapic_write(rte->addr,
IOSAPIC_RTE_LOW(rte->rte_index), low32);
- iosapic_eoi(rte->addr, vec);
+ }
}
}
#endif
Index: linux-2.6-ia64/arch/ia64/kernel/machine_kexec.c
=================================--- linux-2.6-ia64.orig/arch/ia64/kernel/machine_kexec.c 2006-08-18 20:52:18.000000000 +0900
+++ linux-2.6-ia64/arch/ia64/kernel/machine_kexec.c 2006-08-18 20:52:35.000000000 +0900
@@ -102,7 +102,6 @@
}
#endif

-
#ifdef CONFIG_IA64_HP_ZX1
ioc_iova_disable();
#endif
@@ -113,13 +112,17 @@
* We are past the point of no return, committed to rebooting now.
*/
extern void *efi_get_pal_addr(void);
-void machine_kexec(struct kimage *image)
+static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
{
+ struct kimage *image = arg;
relocate_new_kernel_t rnk;
void *pal_addr = efi_get_pal_addr();
unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
- if (image->type = KEXEC_TYPE_CRASH)
+ if (image->type = KEXEC_TYPE_CRASH) {
crash_save_this_cpu();
+ current->thread.ksp = (__u64)info->sw - 16;
+ }
+
/* Interrupts aren't acceptable while we reboot */ ia64_set_itv(1<<16);
local_irq_disable();
@@ -127,5 +130,10 @@
(*rnk)(image->head, image->start, ia64_boot_param,
GRANULEROUNDDOWN((unsigned long) pal_addr));
BUG();
- for (;;);
+}
+
+void machine_kexec(struct kimage *image)
+{
+ unw_init_running(ia64_machine_kexec, image);
+ for(;;);
}
Index: linux-2.6-ia64/arch/ia64/kernel/setup.c
=================================--- linux-2.6-ia64.orig/arch/ia64/kernel/setup.c 2006-08-18 20:52:18.000000000 +0900
+++ linux-2.6-ia64/arch/ia64/kernel/setup.c 2006-08-18 20:52:35.000000000 +0900
@@ -278,9 +278,6 @@
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);

Index: linux-2.6-ia64/arch/ia64/kernel/smp.c
=================================--- linux-2.6-ia64.orig/arch/ia64/kernel/smp.c 2006-08-18 20:52:18.000000000 +0900
+++ linux-2.6-ia64/arch/ia64/kernel/smp.c 2006-08-18 20:52:35.000000000 +0900
@@ -126,6 +126,18 @@
cpu_halt();
}

+#ifdef CONFIG_CRASH_DUMP
+static void
+kdump_cpu_freeze(struct unw_frame_info *info, void *arg) +{
+ local_irq_disable();
+ crash_save_this_cpu();
+ current->thread.ksp = (__u64)info->sw - 16;
+ cpu_halt();
+}
+#endif
+
+
void
cpu_die(void)
{
@@ -187,11 +199,7 @@
break;
#ifdef CONFIG_CRASH_DUMP
case IPI_KDUMP_CPU_STOP:
- {
- local_irq_disable();
- crash_save_this_cpu();
- cpu_halt();
- }
+ unw_init_running(kdump_cpu_freeze, NULL);
break;
#endif
default:
@@ -251,6 +259,13 @@
send_IPI_single(smp_processor_id(), op);
}

+#ifdef CONFIG_CRASH_DUMP
+void
+kdump_smp_send_stop()
+{
+ send_IPI_allbutself(IPI_KDUMP_CPU_STOP);
+}
+#endif
/*
* Called with preeemption disabled.
*/
@@ -409,13 +424,6 @@
{
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)
Index: linux-2.6-ia64/include/asm-ia64/kexec.h
=================================--- linux-2.6-ia64.orig/include/asm-ia64/kexec.h 2006-08-18 20:52:18.000000000 +0900
+++ linux-2.6-ia64/include/asm-ia64/kexec.h 2006-08-18 20:52:35.000000000 +0900
@@ -34,7 +34,7 @@
extern struct resource efi_memmap_res;
extern struct resource boot_param_res;
extern void kdump_smp_send_stop(void);
-extern void kdump_disable_irq(unsigned int irq);
+extern void kdump_disable_iosapic(void);
extern void crash_save_this_cpu(void);

#endif /* _ASM_IA64_KEXEC_H */