Skip to contentSkip to conversation

kexec/kdump support for ppc32

RFC PATCH In review Anton Vorontsov 5 participants 19 messages Aug 1, 2008 – Aug 20, 2008

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

cover kexec/kdump support for ppc32

Hi all,

I refreshed some Dale Farnsworth's kexec/kdump patches[1] against the latest kernel, and here they are.

There is a difference though. Dale's patches were using kmap_atomic_pfn() to map oldmem memory, while for this patches I took PPC64 approach to use ioremap(). This is done to be able to support kdump on !HIGHMEM kernels.

Also, please take a special look into 8/8 patch, there is a hunk marked with "XXX:", which I don't quite understand for PPC64 case (this hunk also persist in the original Dale's patch, and w/o it the capturing kernel doesn't boot on ppc32).

I'll try to refresh BookE support as soon as I'll find some BookE board.

The patchset includes:

- Kexec support

[PATCH 1/8] powerpc: set up OF properties for ppc32 kexec [PATCH 2/8] powerpc: make default kexec/crash_kernel ops implicit [PATCH 3/8] powerpc: remove default kexec/crash_kernel ops assignments

2/8 and 3/8 patches are used to avoid adding lots of default ops to the board files.

- Kdump support

[PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be loaded at 32M [PATCH 5/8] powerpc: allow to ioremap RAM addresses for kdump kernel on ppc32 [PATCH 6/8] powerpc: set up OF properties for ppc32 kdump
[PATCH 7/8] powerpc: implement crash_setup_regs for ppc32
[PATCH 8/8] powerpc: last bits to support kdump on ppc32

[1] http://ozlabs.org/pipermail/linuxppc-dev/2007-November/046739.html

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#1 lore raw

PATCH 1/8 powerpc: set up OF properties for ppc32 kexec

From: Dale Farnsworth <[email protected]>

Refactor the setting of kexec OF properties, moving the common code from machine_kexec_64.c to machine_kexec.c where it can be used on both ppc64 and ppc32. This is needed for kexec to work on ppc32 platforms.

---
 arch/powerpc/kernel/machine_kexec.c    |   27 +++++++++++++++++++++++++++
 arch/powerpc/kernel/machine_kexec_64.c |   20 +++++---------------
 2 files changed, 32 insertions(+), 15 deletions(-)
arch/powerpc/kernel/machine_kexec.c +27 -0
index aab7688..a625673 100644
@@ -13,8 +13,10 @@
 #include <linux/reboot.h>
 #include <linux/threads.h>
 #include <linux/lmb.h>
+#include <linux/of.h>
 #include <asm/machdep.h>
 #include <asm/prom.h>
+#include <asm/sections.h>
 
 void machine_crash_shutdown(struct pt_regs *regs)
 {
@@ -116,3 +118,28 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)
 {
 	return (start + size) > crashk_res.start && start <= crashk_res.end;
 }
+
+/* Values we need to export to the second kernel via the device tree. */
+static unsigned long kernel_end;
+
+static struct property kernel_end_prop = {
+	.name = "linux,kernel-end",
+	.length = sizeof(unsigned long),
+	.value = &kernel_end,
+};
+
+static int __init kexec_setup(void)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return -ENOENT;
+
+	kernel_end = __pa(_end);
+	prom_add_property(node, &kernel_end_prop);
+
+	of_node_put(node);
+	return 0;
+}
+__initcall(kexec_setup);
arch/powerpc/kernel/machine_kexec_64.c +5 -15
index a168514..c30678d 100644
@@ -289,7 +289,7 @@ void default_machine_kexec(struct kimage *image)
 }
 
 /* Values we need to export to the second kernel via the device tree. */
-static unsigned long htab_base, kernel_end;
+static unsigned long htab_base;
 
 static struct property htab_base_prop = {
 	.name = "linux,htab-base",
@@ -303,32 +303,22 @@ static struct property htab_size_prop = {
 	.value = &htab_size_bytes,
 };
 
-static struct property kernel_end_prop = {
-	.name = "linux,kernel-end",
-	.length = sizeof(unsigned long),
-	.value = &kernel_end,
-};
-
 static void __init export_htab_values(void)
 {
 	struct device_node *node;
 
+	/* On machines with no htab htab_address is NULL */
+	if (NULL == htab_address)
+		return;
+
 	node = of_find_node_by_path("/chosen");
 	if (!node)
 		return;
 
-	kernel_end = __pa(_end);
-	prom_add_property(node, &kernel_end_prop);
-
-	/* On machines with no htab htab_address is NULL */
-	if (NULL == htab_address)
-		goto out;
-
 	htab_base = __pa(htab_address);
 	prom_add_property(node, &htab_base_prop);
 	prom_add_property(node, &htab_size_prop);
 
- out:
 	of_node_put(node);
 }
 
Signature · 1 line
1.5.5.4
#2 lore raw

Re: [PATCH 1/8] powerpc: set up OF properties for ppc32 kexec

Quoted 6 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Refactor the setting of kexec OF properties, moving the common code from machine_kexec_64.c to machine_kexec.c where it can be used on both ppc64 and ppc32. This is needed for kexec to work on ppc32 platforms.

Hi Anton,

Quoted 4 lines
arch/powerpc/kernel/machine_kexec.c +0 -0
index aab7688..a625673 100644

...

Quoted 6 lines
arch/powerpc/kernel/machine_kexec.c +6 -0
+
+static int __init kexec_setup(void)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path("/chosen");

arch/powerpc/kernel/machine_kexec.c int overlaps_crashkernel(unsigned long start, unsigned long size) · line 145

Quoted 10 lines
arch/powerpc/kernel/machine_kexec.c +10 -0
+	if (!node)
+		return -ENOENT;
+
+	kernel_end = __pa(_end);
+	prom_add_property(node, &kernel_end_prop);
+
+	of_node_put(node);
+	return 0;
+}
+__initcall(kexec_setup);

__initcall() is supposedly deprecated, use device_initcall() instead.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#3 lore raw

PATCH 2/8 powerpc: make default kexec/crash_kernel ops implicit

In reply to Anton Vorontsov

This patch removes need for each platform to specify default kexec and crash kernel ops, thus effectively adds a working kexec support for most boards.

Platforms that can't cope with default ops will explode in some weird way, which means that the board's kexec support should be fixed or blacklisted via dummy _prepare callback returning -ENOSYS.

---
 arch/powerpc/kernel/machine_kexec.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)
arch/powerpc/kernel/machine_kexec.c +8 -12
index a625673..ac42cfb 100644
@@ -22,6 +22,8 @@ void machine_crash_shutdown(struct pt_regs *regs)
 {
 	if (ppc_md.machine_crash_shutdown)
 		ppc_md.machine_crash_shutdown(regs);
+	else
+		return default_machine_crash_shutdown(regs);
 }
 
 /*
@@ -33,11 +35,8 @@ int machine_kexec_prepare(struct kimage *image)
 {
 	if (ppc_md.machine_kexec_prepare)
 		return ppc_md.machine_kexec_prepare(image);
-	/*
-	 * Fail if platform doesn't provide its own machine_kexec_prepare
-	 * implementation.
-	 */
-	return -ENOSYS;
+	else
+		return default_machine_kexec_prepare(image);
 }
 
 void machine_kexec_cleanup(struct kimage *image)
@@ -54,13 +53,10 @@ void machine_kexec(struct kimage *image)
 {
 	if (ppc_md.machine_kexec)
 		ppc_md.machine_kexec(image);
-	else {
-		/*
-		 * Fall back to normal restart if platform doesn't provide
-		 * its own kexec function, and user insist to kexec...
-		 */
-		machine_restart(NULL);
-	}
+	else
+		default_machine_kexec(image);
+	/* Fall back to normal restart if we're still alive. */
+	machine_restart(NULL);
 	for(;;);
 }
 
Signature · 1 line
1.5.5.4
#4 lore raw

PATCH 3/8 powerpc: remove default kexec/crash_kernel ops assignments

In reply to Anton Vorontsov

Default ops are implicit now.

---
 arch/powerpc/platforms/cell/celleb_setup.c     |    9 ---------
 arch/powerpc/platforms/cell/setup.c            |    6 ------
 arch/powerpc/platforms/embedded6xx/c2k.c       |    6 ------
 arch/powerpc/platforms/embedded6xx/prpmc2800.c |    6 ------
 arch/powerpc/platforms/maple/setup.c           |    6 ------
 arch/powerpc/platforms/powermac/setup.c        |    6 ------
 arch/powerpc/platforms/ps3/setup.c             |    4 ----
 7 files changed, 0 insertions(+), 43 deletions(-)
arch/powerpc/platforms/cell/celleb_setup.c +0 -9
index b11cb30..07c234f 100644
@@ -45,7 +45,6 @@
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
-#include <asm/kexec.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/cputable.h>
@@ -226,9 +225,6 @@ define_machine(celleb_beat) {
 	.pci_setup_phb		= celleb_setup_phb,
 #ifdef CONFIG_KEXEC
 	.kexec_cpu_down		= beat_kexec_cpu_down,
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
 #endif
 };
 
@@ -248,9 +244,4 @@ define_machine(celleb_native) {
 	.pci_probe_mode 	= celleb_pci_probe_mode,
 	.pci_setup_phb		= celleb_setup_phb,
 	.init_IRQ		= celleb_init_IRQ_native,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 };
arch/powerpc/platforms/cell/setup.c +0 -6
index ab721b5..5930536 100644
@@ -35,7 +35,6 @@
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
-#include <asm/kexec.h>
 #include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
@@ -289,9 +288,4 @@ define_machine(cell) {
 	.progress		= cell_progress,
 	.init_IRQ       	= cell_init_irq,
 	.pci_setup_phb		= cell_setup_phb,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 };
arch/powerpc/platforms/embedded6xx/c2k.c +0 -6
index d0b25b8..19d3bc4 100644
@@ -20,7 +20,6 @@
 #include <linux/seq_file.h>
 #include <linux/time.h>
 #include <linux/of.h>
-#include <linux/kexec.h>
 
 #include <asm/machdep.h>
 #include <asm/prom.h>
@@ -150,9 +149,4 @@ define_machine(c2k) {
 	.get_irq		= mv64x60_get_irq,
 	.restart		= c2k_restart,
 	.calibrate_decr		= generic_calibrate_decr,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 };
arch/powerpc/platforms/embedded6xx/prpmc2800.c +0 -6
index 5a19b9a..e40b5a8 100644
@@ -19,7 +19,6 @@
 #include <asm/prom.h>
 #include <asm/system.h>
 #include <asm/time.h>
-#include <asm/kexec.h>
 
 #include <mm/mmu_decl.h>
 
@@ -158,9 +157,4 @@ define_machine(prpmc2800){
 	.get_irq		= mv64x60_get_irq,
 	.restart		= prpmc2800_restart,
 	.calibrate_decr		= generic_calibrate_decr,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 };
arch/powerpc/platforms/maple/setup.c +0 -6
index 3647147..1be9b7c 100644
@@ -51,7 +51,6 @@
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
-#include <asm/kexec.h>
 #include <asm/pci-bridge.h>
 #include <asm/iommu.h>
 #include <asm/machdep.h>
@@ -336,9 +335,4 @@ define_machine(maple) {
       	.calibrate_decr		= generic_calibrate_decr,
 	.progress		= maple_progress,
 	.power_save		= power4_idle,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 };
arch/powerpc/platforms/powermac/setup.c +0 -6
index 88ccf3a..5e0999b 100644
@@ -61,7 +61,6 @@
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
-#include <asm/kexec.h>
 #include <asm/pci-bridge.h>
 #include <asm/ohare.h>
 #include <asm/mediabay.h>
@@ -741,11 +740,6 @@ define_machine(powermac) {
 	.pci_probe_mode		= pmac_pci_probe_mode,
 	.power_save		= power4_idle,
 	.enable_pmcs		= power4_enable_pmcs,
-#ifdef CONFIG_KEXEC
-	.machine_kexec		= default_machine_kexec,
-	.machine_kexec_prepare	= default_machine_kexec_prepare,
-	.machine_crash_shutdown	= default_machine_crash_shutdown,
-#endif
 #endif /* CONFIG_PPC64 */
 #ifdef CONFIG_PPC32
 	.pcibios_enable_device_hook = pmac_pci_enable_device_hook,
arch/powerpc/platforms/ps3/setup.c +0 -4
index a413abb..a8b99a6 100644
@@ -23,7 +23,6 @@
 #include <linux/fs.h>
 #include <linux/root_dev.h>
 #include <linux/console.h>
-#include <linux/kexec.h>
 #include <linux/bootmem.h>
 
 #include <asm/machdep.h>
@@ -278,8 +277,5 @@ define_machine(ps3) {
 	.halt				= ps3_halt,
 #if defined(CONFIG_KEXEC)
 	.kexec_cpu_down			= ps3_kexec_cpu_down,
-	.machine_kexec			= default_machine_kexec,
-	.machine_kexec_prepare		= default_machine_kexec_prepare,
-	.machine_crash_shutdown		= default_machine_crash_shutdown,
 #endif
 };
Signature · 1 line
1.5.5.4
#5 lore raw

PATCH 4/8 powerpc: add the ability for a classic ppc kernel to be loaded at 32M

In reply to Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Add the ability for a classic ppc kernel to be loaded at an address of 32MB. This done by fixing a few places that assume we are loaded at address 0, and by changing several uses of KERNELBASE to use PAGE_OFFSET, instead.

---
 arch/powerpc/kernel/head_32.S |   11 ++++++-----
 arch/powerpc/mm/init_32.c     |    2 +-
 arch/powerpc/mm/pgtable_32.c  |    4 ++--
 arch/powerpc/mm/ppc_mmu_32.c  |    8 ++++----
 include/asm-powerpc/ppc_asm.h |    4 ++--
 5 files changed, 15 insertions(+), 14 deletions(-)
arch/powerpc/kernel/head_32.S +6 -5
index 99ee2f0..45e612b 100644
@@ -176,7 +176,8 @@ __after_mmu_off:
 	bl	reloc_offset
 	mr	r26,r3
 	addis	r4,r3,KERNELBASE@h	/* current address of _start */
-	cmpwi	0,r4,0			/* are we already running at 0? */
+	lis	r5,PHYSICAL_START@h
+	cmplw	0,r4,r5			/* already running at PHYSICAL_START? */
 	bne	relocate_kernel
 /*
  * we now have the 1st 16M of ram mapped with the bats.
@@ -804,13 +805,13 @@ giveup_altivec:
 
 /*
  * This code is jumped to from the startup code to copy
- * the kernel image to physical address 0.
+ * the kernel image to physical address PHYSICAL_START.
  */
 relocate_kernel:
 	addis	r9,r26,klimit@ha	/* fetch klimit */
 	lwz	r25,klimit@l(r9)
 	addis	r25,r25,-KERNELBASE@h
-	li	r3,0			/* Destination base address */
+	lis	r3,PHYSICAL_START@h	/* Destination base address */
 	li	r6,0			/* Destination offset */
 	li	r5,0x4000		/* # bytes of memory to copy */
 	bl	copy_and_flush		/* copy the first 0x4000 bytes */
@@ -1172,11 +1173,11 @@ mmu_off:
 
 /*
  * Use the first pair of BAT registers to map the 1st 16MB
- * of RAM to KERNELBASE.  From this point on we can't safely
+ * of RAM to PAGE_OFFSET.  From this point on we can't safely
  * call OF any more.
  */
 initial_bats:
-	lis	r11,KERNELBASE@h
+	lis	r11,PAGE_OFFSET@h
 	mfspr	r9,SPRN_PVR
 	rlwinm	r9,r9,16,16,31		/* r9 = 1 for 601, 4 for 604 */
 	cmpwi	0,r9,1
arch/powerpc/mm/init_32.c +1 -1
index 388ceda..4ac0e4e 100644
@@ -49,7 +49,7 @@
 
 #if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL)
 /* The ammount of lowmem must be within 0xF0000000 - KERNELBASE. */
-#if (CONFIG_LOWMEM_SIZE > (0xF0000000 - KERNELBASE))
+#if (CONFIG_LOWMEM_SIZE > (0xF0000000 - PAGE_OFFSET))
 #error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_START_KERNEL"
 #endif
 #endif
arch/powerpc/mm/pgtable_32.c +2 -2
index 2001abd..ea50968 100644
@@ -288,7 +288,7 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
 }
 
 /*
- * Map in all of physical memory starting at KERNELBASE.
+ * Map in all of physical memory starting at PAGE_OFFSET.
  */
 void __init mapin_ram(void)
 {
@@ -297,7 +297,7 @@ void __init mapin_ram(void)
 	int ktext;
 
 	s = mmu_mapin_ram();
-	v = KERNELBASE + s;
+	v = PAGE_OFFSET + s;
 	p = memstart_addr + s;
 	for (; s < total_lowmem; s += PAGE_SIZE) {
 		ktext = ((char *) v >= _stext && (char *) v < etext);
arch/powerpc/mm/ppc_mmu_32.c +4 -4
index c53145f..7c86103 100644
@@ -95,16 +95,16 @@ unsigned long __init mmu_mapin_ram(void)
 			break;
 	}
 
-	setbat(2, KERNELBASE, 0, bl, _PAGE_RAM);
-	done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1;
+	setbat(2, PAGE_OFFSET, 0, bl, _PAGE_RAM);
+	done = (unsigned long)bat_addrs[2].limit - PAGE_OFFSET + 1;
 	if ((done < tot) && !bat_addrs[3].limit) {
 		/* use BAT3 to cover a bit more */
 		tot -= done;
 		for (bl = 128<<10; bl < max_size; bl <<= 1)
 			if (bl * 2 > tot)
 				break;
-		setbat(3, KERNELBASE+done, done, bl, _PAGE_RAM);
-		done = (unsigned long)bat_addrs[3].limit - KERNELBASE + 1;
+		setbat(3, PAGE_OFFSET+done, done, bl, _PAGE_RAM);
+		done = (unsigned long)bat_addrs[3].limit - PAGE_OFFSET + 1;
 	}
 
 	return done;
include/asm-powerpc/ppc_asm.h +2 -2
index 0966899..d0c7f33 100644
@@ -425,14 +425,14 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #define fromreal(rd)	tovirt(rd,rd)
 
 #define tophys(rd,rs)				\
-0:	addis	rd,rs,-KERNELBASE@h;		\
+0:	addis	rd,rs,-PAGE_OFFSET@h;		\
 	.section ".vtop_fixup","aw";		\
 	.align  1;				\
 	.long   0b;				\
 	.previous
 
 #define tovirt(rd,rs)				\
-0:	addis	rd,rs,KERNELBASE@h;		\
+0:	addis	rd,rs,PAGE_OFFSET@h;		\
 	.section ".ptov_fixup","aw";		\
 	.align  1;				\
 	.long   0b;				\
Signature · 1 line
1.5.5.4
#6 lore raw

Re: [PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be loaded at 32M

Quoted 6 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Add the ability for a classic ppc kernel to be loaded at an address of 32MB. This done by fixing a few places that assume we are loaded at address 0, and by changing several uses of KERNELBASE to use PAGE_OFFSET, instead.

What do you do about the exception vectors?

-Scott

#7 lore raw

Re: [PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be loaded at 32M

Quoted 9 lines · Scott Wood
Quoted 6 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Add the ability for a classic ppc kernel to be loaded at an address of 32MB. This done by fixing a few places that assume we are loaded at address 0, and by changing several uses of KERNELBASE to use PAGE_OFFSET, instead.

What do you do about the exception vectors?

Making a trampoline code in place of exception vectors. See this patch:

[PATCH 8/8] powerpc: last bits to support kdump on ppc32

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#8 lore raw

Re: [PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be loaded at 32M

Quoted 5 lines · Anton Vorontsov
Quoted 1 line

What do you do about the exception vectors?

Making a trampoline code in place of exception vectors. See this patch:

[PATCH 8/8] powerpc: last bits to support kdump on ppc32

It would probably be worth looking at whether we could do a relocatable 32-bit kernel by linking it as a PIE and processing the dynamic relocations at boot time (like the patches I posted recently for 64-bit).

Paul.

#9 lore raw

PATCH 5/8 powerpc: allow to ioremap RAM addresses for kdump kernel on ppc32

In reply to Anton Vorontsov

While for debugging it is good to catch bogus users of ioremap, but for kdump support it is more convenient to use ioremap for copy_oldmem_page() (exactly as we do for PPC64 currently).

The other option is to use kmap_atomic_pfn()*, but it will not work for kernels compiled without HIGHMEM.

That is, on a board with 256MB RAM and crashkernel=64M@32M case, the !HIGHMEM capturing kernel maps 0-96M range, which does not include all the memory needed to capture the dump. And obviously accessing anything upper than 96M will cause faults.

* http://ozlabs.org/pipermail/linuxppc-dev/2007-November/046747.html

---
 arch/powerpc/mm/pgtable_32.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/powerpc/mm/pgtable_32.c +2 -0
index ea50968..3e69b0d 100644
@@ -194,6 +194,7 @@ __ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
 	if (p < 16*1024*1024)
 		p += _ISA_MEM_BASE;
 
+#ifndef CONFIG_CRASH_DUMP
 	/*
 	 * Don't allow anybody to remap normal RAM that we're using.
 	 * mem_init() sets high_memory so only do the check after that.
@@ -203,6 +204,7 @@ __ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
 		       (unsigned long long)p, __builtin_return_address(0));
 		return NULL;
 	}
+#endif
 
 	if (size == 0)
 		return NULL;
Signature · 1 line
1.5.5.4
#10 lore raw

PATCH 6/8 powerpc: set up OF properties for ppc32 kdump

In reply to Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Refactor the setting of kexec OF properties, moving the common code from machine_kexec_64.c to machine_kexec.c where it can be used on both ppc64 and ppc32. This will be needed for kdump to work on ppc32 platforms.

---
 arch/powerpc/kernel/machine_kexec.c    |   38 ++++++++++++++++++++++++++++
 arch/powerpc/kernel/machine_kexec_64.c |   43 --------------------------------
 2 files changed, 38 insertions(+), 43 deletions(-)
arch/powerpc/kernel/machine_kexec.c +38 -0
index ac42cfb..bfef717 100644
@@ -117,6 +117,7 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)
 
 /* Values we need to export to the second kernel via the device tree. */
 static unsigned long kernel_end;
+static unsigned long crashk_size;
 
 static struct property kernel_end_prop = {
 	.name = "linux,kernel-end",
@@ -124,6 +125,41 @@ static struct property kernel_end_prop = {
 	.value = &kernel_end,
 };
 
+static struct property crashk_base_prop = {
+	.name = "linux,crashkernel-base",
+	.length = sizeof(unsigned long),
+	.value = &crashk_res.start,
+};
+
+static struct property crashk_size_prop = {
+	.name = "linux,crashkernel-size",
+	.length = sizeof(unsigned long),
+	.value = &crashk_size,
+};
+
+static void __init export_crashk_values(struct device_node *node)
+{
+	struct property *prop;
+
+	/* There might be existing crash kernel properties, but we can't
+	 * be sure what's in them, so remove them. */
+	prop = of_find_property(node, "linux,crashkernel-base", NULL);
+	if (prop)
+		prom_remove_property(node, prop);
+
+	prop = of_find_property(node, "linux,crashkernel-size", NULL);
+	if (prop)
+		prom_remove_property(node, prop);
+
+	if (crashk_res.start != 0) {
+		prom_add_property(node, &crashk_base_prop);
+		crashk_size = crashk_res.end - crashk_res.start + 1;
+		prom_add_property(node, &crashk_size_prop);
+	}
+
+	of_node_put(node);
+}
+
 static int __init kexec_setup(void)
 {
 	struct device_node *node;
@@ -135,6 +171,8 @@ static int __init kexec_setup(void)
 	kernel_end = __pa(_end);
 	prom_add_property(node, &kernel_end_prop);
 
+	export_crashk_values(node);
+
 	of_node_put(node);
 	return 0;
 }
arch/powerpc/kernel/machine_kexec_64.c +0 -43

52 lines not on this page · raw message

Signature · 1 line
1.5.5.4
#11 lore raw

Re: [PATCH 6/8] powerpc: set up OF properties for ppc32 kdump

Quoted 6 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Refactor the setting of kexec OF properties, moving the common code from machine_kexec_64.c to machine_kexec.c where it can be used on both ppc64 and ppc32. This will be needed for kdump to work on ppc32 platforms.

Hi Anton,

Quoted 23 lines
arch/powerpc/kernel/machine_kexec.c +2 -0
index ac42cfb..bfef717 100644
@@ -117,6 +117,7 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)
 
 
 static int __init kexec_setup(void)
 {
 	struct device_node *node;
@@ -135,6 +171,8 @@ static int __init kexec_setup(void)
 	kernel_end = __pa(_end);
 	prom_add_property(node, &kernel_end_prop);
 
+	export_crashk_values(node);
+
 	of_node_put(node);
 	return 0;
 }
arch/powerpc/kernel/machine_kexec_64.c +0 -0
index c30678d..2aab296 100644

...

arch/powerpc/kernel/machine_kexec_64.c static void __init export_htab_values(void) · line 330

Quoted 8 lines
arch/powerpc/kernel/machine_kexec_64.c +0 -2
-
 static int __init kexec_setup(void)
 {
 	export_htab_values();
-	export_crashk_values();
 	return 0;
 }
 __initcall(kexec_setup);

This leaves us with two routines called kexec_setup(), do you mind getting rid of this one and making export_htab_values() an initcall directly.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#12 lore raw

Re: [PATCH 6/8] powerpc: set up OF properties for ppc32 kdump

Quoted 9 lines · Michael Ellerman
Quoted 6 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Refactor the setting of kexec OF properties, moving the common code from machine_kexec_64.c to machine_kexec.c where it can be used on both ppc64 and ppc32. This will be needed for kdump to work on ppc32 platforms.

Hi Anton,

Hi,

Quoted 25 lines
Quoted 23 lines
arch/powerpc/kernel/machine_kexec.c +2 -0
index ac42cfb..bfef717 100644
@@ -117,6 +117,7 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)
 
 
 static int __init kexec_setup(void)
 {
 	struct device_node *node;
@@ -135,6 +171,8 @@ static int __init kexec_setup(void)
 	kernel_end = __pa(_end);
 	prom_add_property(node, &kernel_end_prop);
 
+	export_crashk_values(node);
+
 	of_node_put(node);
 	return 0;
 }
arch/powerpc/kernel/machine_kexec_64.c +0 -0
index c30678d..2aab296 100644

...

Quoted 12 lines

arch/powerpc/kernel/machine_kexec_64.c static void __init export_htab_values(void) · line 330

Quoted 8 lines
arch/powerpc/kernel/machine_kexec_64.c +0 -2
-
 static int __init kexec_setup(void)
 {
 	export_htab_values();
-	export_crashk_values();
 	return 0;
 }
 __initcall(kexec_setup);

This leaves us with two routines called kexec_setup(), do you mind getting rid of this one and making export_htab_values() an initcall directly.

Yup, good idea. Will do this, and will address your other comments, too.

Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#13 lore raw

PATCH 7/8 powerpc: implement crash_setup_regs for ppc32

In reply to Anton Vorontsov

From: Dale Farnsworth <[email protected]>

---
 include/asm-powerpc/kexec.h |   60 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 9 deletions(-)
include/asm-powerpc/kexec.h +51 -9
index acdcdc6..9ecc307 100644
@@ -38,7 +38,6 @@ typedef void (*crash_shutdown_t)(void);
 
 #ifdef CONFIG_KEXEC
 
-#ifdef __powerpc64__
 /*
  * This function is responsible for capturing register states if coming
  * via panic or invoking dump using sysrq-trigger.
@@ -51,6 +50,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
 	else {
 		/* FIXME Merge this with xmon_save_regs ?? */
 		unsigned long tmp1, tmp2;
+#ifdef __powerpc64__
 		__asm__ __volatile__ (
 			"std    0,0(%2)\n"
 			"std    1,8(%2)\n"
@@ -99,16 +99,58 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
 			: "=&r" (tmp1), "=&r" (tmp2)
 			: "b" (newregs)
 			: "memory");
+#else /* __powerpc64__ */
+		__asm__ __volatile__ (
+			"stw    0,0(%2)\n"
+			"stw    1,4(%2)\n"
+			"stw    2,8(%2)\n"
+			"stw    3,12(%2)\n"
+			"stw    4,16(%2)\n"
+			"stw    5,20(%2)\n"
+			"stw    6,24(%2)\n"
+			"stw    7,28(%2)\n"
+			"stw    8,32(%2)\n"
+			"stw    9,36(%2)\n"
+			"stw    10,40(%2)\n"
+			"stw    11,44(%2)\n"
+			"stw    12,48(%2)\n"
+			"stw    13,52(%2)\n"
+			"stw    14,56(%2)\n"
+			"stw    15,60(%2)\n"
+			"stw    16,64(%2)\n"
+			"stw    17,68(%2)\n"
+			"stw    18,72(%2)\n"
+			"stw    19,76(%2)\n"
+			"stw    20,80(%2)\n"
+			"stw    21,84(%2)\n"
+			"stw    22,88(%2)\n"
+			"stw    23,92(%2)\n"
+			"stw    24,96(%2)\n"
+			"stw    25,100(%2)\n"
+			"stw    26,104(%2)\n"
+			"stw    27,108(%2)\n"
+			"stw    28,112(%2)\n"
+			"stw    29,116(%2)\n"
+			"stw    30,120(%2)\n"
+			"stw    31,124(%2)\n"
+			"mfmsr  %0\n"
+			"stw    %0,132(%2)\n"
+			"mfctr  %0\n"
+			"stw    %0,140(%2)\n"
+			"mflr   %0\n"
+			"stw    %0,144(%2)\n"
+			"bl     1f\n"
+		"1:     mflr   %1\n"
+			"stw    %1,128(%2)\n"
+			"mtlr   %0\n"
+			"mfxer  %0\n"
+			"stw    %0,148(%2)\n"
+			: "=&r" (tmp1), "=&r" (tmp2)
+			: "b" (newregs)
+			: "memory");
+#endif /* __powerpc64 __ */
 	}
 }
-#else
-/*
- * Provide a dummy definition to avoid build failures. Will remain
- * empty till crash dump support is enabled.
- */
-static inline void crash_setup_regs(struct pt_regs *newregs,
-					struct pt_regs *oldregs) { }
-#endif /* !__powerpc64 __ */
 
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
Signature · 1 line
1.5.5.4
#14 lore raw

Re: [PATCH 7/8] powerpc: implement crash_setup_regs for ppc32

Quoted 18 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

include/asm-powerpc/kexec.h +2 -0
@@ -51,6 +50,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
 	else {
 		/* FIXME Merge this with xmon_save_regs ?? */
 		unsigned long tmp1, tmp2;
+#ifdef __powerpc64__
 		__asm__ __volatile__ (
 			"std    0,0(%2)\n"
 			"std    1,8(%2)\n"
@@ -99,16 +99,58 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
 			: "=&r" (tmp1), "=&r" (tmp2)
 			: "b" (newregs)
 			: "memory");
+#else /* __powerpc64__ */

include/asm-powerpc/kexec.h static inline void crash_setup_regs(struct pt_regs *newregs, · line 112

Quoted 10 lines
include/asm-powerpc/kexec.h +10 -0
+		__asm__ __volatile__ (
+			"stw    0,0(%2)\n"
+			"stw    1,4(%2)\n"
+			"stw    2,8(%2)\n"
+			"stw    3,12(%2)\n"
+			"stw    4,16(%2)\n"
+			"stw    5,20(%2)\n"
+			"stw    6,24(%2)\n"
+			"stw    7,28(%2)\n"
+			"stw    8,32(%2)\n"

..

Hi Anton,

You should be able to avoid any use of #ifdefs in this routine. Look at SAVE_GPR() and friends in asm/ppc_asm.h.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#15 lore raw

PATCH 8/8 powerpc: last bits to support kdump on ppc32

In reply to Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Wire up the trampoline code for ppc32 to relay exceptions from the vectors at address 0 to vectors at address 32MB, and modify Kconfig to enable Kdump support for all powerpcs (except BookE, for now).

---
 arch/powerpc/Kconfig             |    2 +-
 arch/powerpc/kernel/crash_dump.c |    6 +++++-
 arch/powerpc/kernel/setup_32.c   |    2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +1 -1
index 587da5e..006a475 100644
@@ -321,7 +321,7 @@ config KEXEC
 
 config CRASH_DUMP
 	bool "Build a kdump crash kernel"
-	depends on PPC_MULTIPLATFORM && PPC64
+	depends on PPC_MULTIPLATFORM && !BOOKE
 	help
 	  Build a kernel suitable for use as a kdump capture kernel.
 	  The kernel will be linked at a different address than normal, and
arch/powerpc/kernel/crash_dump.c +5 -1
index e0debcc..96cd521 100644
@@ -34,7 +34,11 @@ void __init reserve_kdump_trampoline(void)
 
 static void __init create_trampoline(unsigned long addr)
 {
-	unsigned int *p = (unsigned int *)addr;
+	unsigned int *p;
+
+	/* XXX: why this code is working without += PAGE_OFFSET on PPC64? */
+	addr += PAGE_OFFSET;
+	p = (unsigned int *)addr;
 
 	/* The maximum range of a single instruction branch, is the current
 	 * instruction's address + (32 MB - 4) bytes. For the trampoline we
arch/powerpc/kernel/setup_32.c +2 -0
index 066e65c..1d76afc 100644
@@ -121,6 +121,8 @@ notrace void __init machine_init(unsigned long dt_ptr, unsigned long phys)
 
 	probe_machine();
 
+	setup_kdump_trampoline();
+
 #ifdef CONFIG_6xx
 	if (cpu_has_feature(CPU_FTR_CAN_DOZE) ||
 	    cpu_has_feature(CPU_FTR_CAN_NAP))
Signature · 1 line
1.5.5.4
#16 lore raw

Re: [PATCH 8/8] powerpc: last bits to support kdump on ppc32

Quoted 14 lines · Anton Vorontsov

From: Dale Farnsworth <[email protected]>

Wire up the trampoline code for ppc32 to relay exceptions from the vectors at address 0 to vectors at address 32MB, and modify Kconfig to enable Kdump support for all powerpcs (except BookE, for now).

arch/powerpc/kernel/crash_dump.c +0 -0
index e0debcc..96cd521 100644

arch/powerpc/kernel/crash_dump.c void __init reserve_kdump_trampoline(void) · line 41

Quoted 9 lines
arch/powerpc/kernel/crash_dump.c +5 -1
@@ -34,7 +34,11 @@ void __init reserve_kdump_trampoline(void)
 
 static void __init create_trampoline(unsigned long addr)
 {
-	unsigned int *p = (unsigned int *)addr;
+	unsigned int *p;
+
+	/* XXX: why this code is working without += PAGE_OFFSET on PPC64? */
+	addr += PAGE_OFFSET;
+	p = (unsigned int *)addr;

Because we're still in real mode when we call it.

It's kind of funny that it works on 32-bit as well. You're creating a branch from 0xc0000000 to 0xc2000000, and then expecting it to work when you're in real mode and you actually want to jump from 0x0 to 0x2000000
- luckily it's a relative branch :)

To clean this up you should just be able to change the definitions for KDUMP_TRAMPOLINE_START/END to include PAGE_OFFSET and that should work for 32 & 64-bit.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#17 lore raw
In reply to Anton Vorontsov
Quoted 40 lines · Anton Vorontsov

Hi all,

I refreshed some Dale Farnsworth's kexec/kdump patches[1] against the latest kernel, and here they are.

There is a difference though. Dale's patches were using kmap_atomic_pfn() to map oldmem memory, while for this patches I took PPC64 approach to use ioremap(). This is done to be able to support kdump on !HIGHMEM kernels.

Also, please take a special look into 8/8 patch, there is a hunk marked with "XXX:", which I don't quite understand for PPC64 case (this hunk also persist in the original Dale's patch, and w/o it the capturing kernel doesn't boot on ppc32).

I'll try to refresh BookE support as soon as I'll find some BookE board.

The patchset includes:

- Kexec support

[PATCH 1/8] powerpc: set up OF properties for ppc32 kexec [PATCH 2/8] powerpc: make default kexec/crash_kernel ops implicit [PATCH 3/8] powerpc: remove default kexec/crash_kernel ops
assignments

2/8 and 3/8 patches are used to avoid adding lots of default ops to the board files.

- Kdump support

[PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be
loaded at 32M
[PATCH 5/8] powerpc: allow to ioremap RAM addresses for kdump
kernel on ppc32
[PATCH 6/8] powerpc: set up OF properties for ppc32 kdump [PATCH 7/8] powerpc: implement crash_setup_regs for ppc32 [PATCH 8/8] powerpc: last bits to support kdump on ppc32

Quoted 1 line

[1] http://ozlabs.org/pipermail/linuxppc-dev/2007-November/046739.html

What's the state of the kexec tools for ppc32?

- k

#18 lore raw
Quoted 43 lines · Kumar Gala
Quoted 40 lines · Anton Vorontsov

Hi all,

I refreshed some Dale Farnsworth's kexec/kdump patches[1] against the latest kernel, and here they are.

There is a difference though. Dale's patches were using kmap_atomic_pfn() to map oldmem memory, while for this patches I took PPC64 approach to use ioremap(). This is done to be able to support kdump on !HIGHMEM kernels.

Also, please take a special look into 8/8 patch, there is a hunk marked with "XXX:", which I don't quite understand for PPC64 case (this hunk also persist in the original Dale's patch, and w/o it the capturing kernel doesn't boot on ppc32).

I'll try to refresh BookE support as soon as I'll find some BookE board.

The patchset includes:

- Kexec support

[PATCH 1/8] powerpc: set up OF properties for ppc32 kexec [PATCH 2/8] powerpc: make default kexec/crash_kernel ops implicit [PATCH 3/8] powerpc: remove default kexec/crash_kernel ops
assignments

2/8 and 3/8 patches are used to avoid adding lots of default ops to the board files.

- Kdump support

[PATCH 4/8] powerpc: add the ability for a classic ppc kernel to be
loaded at 32M
[PATCH 5/8] powerpc: allow to ioremap RAM addresses for kdump kernel
on ppc32
[PATCH 6/8] powerpc: set up OF properties for ppc32 kdump [PATCH 7/8] powerpc: implement crash_setup_regs for ppc32 [PATCH 8/8] powerpc: last bits to support kdump on ppc32

Quoted 3 lines
Quoted 1 line

[1] http://ozlabs.org/pipermail/linuxppc-dev/2007-November/046739.html

What's the state of the kexec tools for ppc32?

Current kexec-tools has split arch support, and ppc32 is officially broken.

I use some old (20070330), patched kexec-tools with ppc32/ and ppc64/ merged into powerpc (alike to Linux).

I hope one day I (or somebody else) will find time to cleanup or re-do the patches for the recent kexec-tools, and merge them after all.

Though, I didn't look into the patches themselves yet, so I can't tell how much work is pending.

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2