Skip to contentSkip to conversation

powerpc: Add kexec/kdump support for ppc32

PATCH Applied Dale Farnsworth 4 participants 27 messages Nov 22, 2007 – Apr 24, 2008 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

cover powerpc: Add kexec/kdump support for ppc32

This patch series adds kexec and kdump support for ppc32 in arch/powerpc. It has been successfully tested on the mpc8548_cds and prpmc2800 platforms. Mark Greer and I are preparing patches to the kexec-tools package as well.

These patches apply to current powerpc.git.

Dale Farnsworth

#2 lore raw

PATCH 1/10 powerpc: Set up OF properties for ppc32 kexec

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    |   63 ++++++++++++++++++++++++++++++
 arch/powerpc/kernel/machine_kexec_64.c |   67 +++----------------------------
 2 files changed, 70 insertions(+), 60 deletions(-)
arch/powerpc/kernel/machine_kexec.c +63 -0
index c0c8e8c..691dba7 100644
@@ -12,8 +12,11 @@
 #include <linux/kexec.h>
 #include <linux/reboot.h>
 #include <linux/threads.h>
+#include <linux/of.h>
 #include <asm/machdep.h>
 #include <asm/lmb.h>
+#include <asm/sections.h>	/* _end */
+#include <asm/prom.h>
 
 void machine_crash_shutdown(struct pt_regs *regs)
 {
@@ -115,3 +118,63 @@ 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 struct property crashk_base_prop = {
+	.name = "linux,crashkernel-base",
+	.length = sizeof(unsigned long),
+	.value = &crashk_res.start, };
+
+static unsigned long crashk_size;
+
+static struct property crashk_size_prop = {
+	.name = "linux,crashkernel-size",
+	.length = sizeof(unsigned long),
+	.value = &crashk_size,
+};
+
+static void __init export_crashk_values(void)
+{
+	struct device_node *node;
+	struct property *prop;
+
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return;
+
+	kernel_end = __pa(_end);
+	prom_add_property(node, &kernel_end_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)
+{
+	export_crashk_values();
+	return 0;
+}
+__initcall(kexec_setup);
arch/powerpc/kernel/machine_kexec_64.c +7 -60

95 lines not on this page · raw message

Signature · 1 line
1.5.3.4
#3 lore raw

Re: [PATCH 01/10] powerpc: Set up OF properties for ppc32 kexec

Hi Dale,

Just a nit ...

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

Quoted 5 lines · On Thu, 22 Nov 2007 08:45:17 -0700 Dale Farnsworth <[email protected]> wrote:
arch/powerpc/kernel/machine_kexec.c +4 -0
+static struct property crashk_base_prop = {
+	.name = "linux,crashkernel-base",
+	.length = sizeof(unsigned long),
+	.value = &crashk_res.start, };
                                    ^^

Should be on a new line.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#4 lore raw

Re: [PATCH 01/10] powerpc: Set up OF properties for ppc32 kexec

Quoted 9 lines · Stephen Rothwell

Hi Dale,

Just a nit ...

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

Quoted 4 lines · On Thu, 22 Nov 2007 08:45:17 -0700 Dale Farnsworth <[email protected]> wrote:
arch/powerpc/kernel/machine_kexec.c +4 -0
+static struct property crashk_base_prop = {
+	.name = "linux,crashkernel-base",
+	.length = sizeof(unsigned long),
+	.value = &crashk_res.start, };

Heh. How did that happen? :)

I'll fix it as well as the alignment issues you mentioned.

Thanks Stephen.

-Dale

#5 lore raw

PATCH 2/10 powerpc: Cleanup CONFIG_KEXEC dependency

In reply to Dale Farnsworth

KEXEC's dependency on PPC_PRPMC2800 is redundant, since PPC_MULTIPLATFORM is now set for the prpmc2800 platform. Remove the dependency.

---
 arch/powerpc/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/Kconfig +1 -1
index 18f397c..191cc2c 100644
@@ -236,7 +236,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
 
 config KEXEC
 	bool "kexec system call (EXPERIMENTAL)"
-	depends on (PPC_PRPMC2800 || PPC_MULTIPLATFORM) && EXPERIMENTAL
+	depends on PPC_MULTIPLATFORM && 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
Signature · 1 line
1.5.3.4
#6 lore raw

PATCH 3/10 powerpc: Add kexec support for PPC_85xx platforms

In reply to Dale Farnsworth

Book E processors need some extra setup in relocate_new_kernel, because the MMU can't be turned off. Add the code to create the required one-to-one memory map.

---
 arch/powerpc/Kconfig                      |    2 +-
 arch/powerpc/kernel/misc_32.S             |   69 +++++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ads.c |    6 +++
 arch/powerpc/platforms/85xx/mpc85xx_cds.c |    6 +++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c  |    6 +++
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |    6 +++
 6 files changed, 94 insertions(+), 1 deletions(-)
arch/powerpc/Kconfig +1 -1
index 191cc2c..9e9581a 100644
@@ -236,7 +236,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
 
 config KEXEC
 	bool "kexec system call (EXPERIMENTAL)"
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && 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
arch/powerpc/kernel/misc_32.S +69 -0

75 lines not on this page · raw message

arch/powerpc/platforms/85xx/mpc85xx_ads.c +6 -0
index bccdc25..1ade3dd 100644
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 #include <linux/of_platform.h>
+#include <linux/kexec.h>
 
 #include <asm/system.h>
 #include <asm/time.h>
@@ -259,6 +260,11 @@ define_machine(mpc85xx_ads) {
 	.show_cpuinfo		= mpc85xx_ads_show_cpuinfo,
 	.get_irq		= mpic_get_irq,
 	.restart		= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif
 	.calibrate_decr		= generic_calibrate_decr,
 	.progress		= udbg_progress,
 };
arch/powerpc/platforms/85xx/mpc85xx_cds.c +6 -0
index 4d063ee..b8a5ed2 100644
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
+#include <linux/kexec.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -352,6 +353,11 @@ define_machine(mpc85xx_cds) {
 #else
 	.restart	= fsl_rstcr_restart,
 #endif
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif
 	.calibrate_decr = generic_calibrate_decr,
 	.progress	= udbg_progress,
 };
arch/powerpc/platforms/85xx/mpc85xx_ds.c +6 -0
index 59c121a..4c106b6 100644
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
+#include <linux/kexec.h>
 
 #include <asm/system.h>
 #include <asm/time.h>
@@ -224,6 +225,11 @@ define_machine(mpc8572_ds) {
 #endif
 	.get_irq		= mpic_get_irq,
 	.restart		= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif
 	.calibrate_decr		= generic_calibrate_decr,
 	.progress		= udbg_progress,
 };
arch/powerpc/platforms/85xx/mpc85xx_mds.c +6 -0
index 61b3eed..49f55c1 100644
@@ -30,6 +30,7 @@
 #include <linux/initrd.h>
 #include <linux/module.h>
 #include <linux/fsl_devices.h>
+#include <linux/kexec.h>
 
 #include <asm/of_device.h>
 #include <asm/of_platform.h>
@@ -202,6 +203,11 @@ define_machine(mpc85xx_mds) {
 	.init_IRQ	= mpc85xx_mds_pic_init,
 	.get_irq	= mpic_get_irq,
 	.restart	= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif
 	.calibrate_decr	= generic_calibrate_decr,
 	.progress	= udbg_progress,
 #ifdef CONFIG_PCI
Signature · 1 line
1.5.3.4
#7 lore raw

Re: [PATCH 03/10] powerpc: Add kexec support for PPC_85xx platforms

More nits ...

arch/powerpc/platforms/85xx/mpc85xx_ads.c define_machine(mpc85xx_ads) { · line 267

Quoted 10 lines · On Thu, 22 Nov 2007 08:46:07 -0700 Dale Farnsworth <[email protected]> wrote:
arch/powerpc/platforms/85xx/mpc85xx_ads.c +5 -0
@@ -259,6 +260,11 @@ define_machine(mpc85xx_ads) {
 	.show_cpuinfo		= mpc85xx_ads_show_cpuinfo,
 	.get_irq		= mpic_get_irq,
 	.restart		= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif

Please line these up for consistency.

arch/powerpc/platforms/85xx/mpc85xx_cds.c define_machine(mpc85xx_cds) { · line 360

Quoted 9 lines
arch/powerpc/platforms/85xx/mpc85xx_cds.c +5 -0
@@ -352,6 +353,11 @@ define_machine(mpc85xx_cds) {
 #else
 	.restart	= fsl_rstcr_restart,
 #endif
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif

And here

arch/powerpc/platforms/85xx/mpc85xx_ds.c define_machine(mpc8572_ds) { · line 232

Quoted 9 lines
arch/powerpc/platforms/85xx/mpc85xx_ds.c +5 -0
@@ -224,6 +225,11 @@ define_machine(mpc8572_ds) {
 #endif
 	.get_irq		= mpic_get_irq,
 	.restart		= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif

And again ...

Quoted 9 lines
arch/powerpc/platforms/85xx/mpc85xx_mds.c +5 -0
@@ -202,6 +203,11 @@ define_machine(mpc85xx_mds) {
 	.init_IRQ	= mpc85xx_mds_pic_init,
 	.get_irq	= mpic_get_irq,
 	.restart	= fsl_rstcr_restart,
+#ifdef CONFIG_KEXEC
+	.machine_kexec_prepare = default_machine_kexec_prepare,
+	.machine_kexec = default_machine_kexec,
+	.machine_crash_shutdown	= default_machine_crash_shutdown,
+#endif
Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#8 lore raw

Re: [PATCH 03/10] powerpc: Add kexec support for PPC_85xx platforms

In reply to Dale Farnsworth
Quoted 13 lines

index 8b642ab..db0e749 100644

arch/powerpc/kernel/misc_32.S +5 -0
@@ -816,6 +816,75 @@ relocate_new_kernel:
 	/* r4 = reboot_code_buffer */
 	/* r5 = start_address      */
 
+#ifdef CONFIG_E500
+	/*
+	 * Since we can't turn off the MMU, we must create an identity
+	 * map for kernel low memory.  We start by invalidating the
+	 * TLB entries we don't need.

arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 833

Quoted 10 lines
arch/powerpc/kernel/misc_32.S +10 -0
+	 *
+	 * First, invalidate the TLB0 entries
+	 */
+	li	r6, 0x04
+	tlbivax	0, r6
+#ifdef CONFIG_SMP
+	tlbsync
+#endif
+	msync
+

This is really E500 specific or should it be CONFIG_FSL_BOOKE ?

Ben.

#9 lore raw

Re: [PATCH 03/10] powerpc: Add kexec support for PPC_85xx platforms

Quoted 25 lines · Benjamin Herrenschmidt
Quoted 12 lines

index 8b642ab..db0e749 100644

arch/powerpc/kernel/misc_32.S +5 -0
@@ -816,6 +816,75 @@ relocate_new_kernel:
 	/* r4 = reboot_code_buffer */
 	/* r5 = start_address      */
 
+#ifdef CONFIG_E500
+	/*
+	 * Since we can't turn off the MMU, we must create an identity
+	 * map for kernel low memory.  We start by invalidating the
+	 * TLB entries we don't need.

arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 833

Quoted 10 lines
arch/powerpc/kernel/misc_32.S +10 -0
+	 *
+	 * First, invalidate the TLB0 entries
+	 */
+	li	r6, 0x04
+	tlbivax	0, r6
+#ifdef CONFIG_SMP
+	tlbsync
+#endif
+	msync
+

This is really E500 specific or should it be CONFIG_FSL_BOOKE ?

Quoted 1 line

Ben.

I agree that CONFIG_FSL_BOOKE is more appropriate. I'll reflect that in the next respin.

Thanks,
-Dale

#10 lore raw

PATCH 4/10 powerpc: Add crash kernel support for classic ppc

In reply to Dale Farnsworth

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. We also wire up the trampoline code for ppc32 to relay exceptions from the vectors at address 0 to vectors at address 32MB.

---
 arch/powerpc/Kconfig              |    2 +-
 arch/powerpc/kernel/crash_dump.c  |    1 +
 arch/powerpc/kernel/head_32.S     |   11 ++++++-----
 arch/powerpc/kernel/setup_32.c    |    2 ++
 arch/powerpc/kernel/vmlinux.lds.S |    4 +---
 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 ++--
 9 files changed, 20 insertions(+), 18 deletions(-)
arch/powerpc/Kconfig +1 -1
index 9e9581a..805b4d1 100644
@@ -253,7 +253,7 @@ config KEXEC
 
 config CRASH_DUMP
 	bool "Build a kdump crash kernel (EXPERIMENTAL)"
-	depends on PPC_MULTIPLATFORM && PPC64 && EXPERIMENTAL
+	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
 	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 +1 -0
index 29ff77c..77c0376 100644
@@ -40,6 +40,7 @@ static void __init create_trampoline(unsigned long addr)
 	 * branch to "addr" we jump to ("addr" + 32 MB). Although it requires
 	 * two instructions it doesn't require any registers.
 	 */
+	addr += PAGE_OFFSET;
 	create_instruction(addr, 0x60000000); /* nop */
 	create_branch(addr + 4, addr + PHYSICAL_START, 0);
 }
arch/powerpc/kernel/head_32.S +6 -5
index a5b13ae..a9b50ab 100644
@@ -175,7 +175,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.
@@ -818,13 +819,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 */
@@ -1186,11 +1187,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/kernel/setup_32.c +2 -0
index cd870a8..bbb4caf 100644
@@ -128,6 +128,8 @@ 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))
arch/powerpc/kernel/vmlinux.lds.S +1 -3
index f66fa5d..242f17d 100644
@@ -1,11 +1,9 @@
 #ifdef CONFIG_PPC64
-#include <asm/page.h>
 #define PROVIDE32(x)	PROVIDE(__unused__##x)
 #else
-#define PAGE_SIZE	4096
-#define KERNELBASE	CONFIG_KERNEL_START
 #define PROVIDE32(x)	PROVIDE(x)
 #endif
+#include <asm/page.h>
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/cache.h>
 
arch/powerpc/mm/init_32.c +1 -1
index 977cb1e..a25d3d7 100644
@@ -48,7 +48,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 6448872..e7505ea 100644
@@ -275,7 +275,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)
 {
@@ -283,7 +283,7 @@ void __init mapin_ram(void)
 	int ktext;
 
 	s = mmu_mapin_ram();
-	v = KERNELBASE + s;
+	v = PAGE_OFFSET + s;
 	p = PPC_MEMSTART + 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 5c45d47..6316895 100644
@@ -105,16 +105,16 @@ unsigned long __init mmu_mapin_ram(void)
 			break;
 	}
 
-	setbat(2, KERNELBASE, PPC_MEMSTART, bl, _PAGE_RAM);
-	done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1;
+	setbat(2, PAGE_OFFSET, PPC_MEMSTART, 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, PPC_MEMSTART+done, bl, _PAGE_RAM);
-		done = (unsigned long)bat_addrs[3].limit - KERNELBASE + 1;
+		setbat(3, PAGE_OFFSET+done, PPC_MEMSTART+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 2dbd4e7..f8943ec 100644
@@ -382,14 +382,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.3.4
#11 lore raw

PATCH 5/10 powerpc: Add crash kernel support for 85xx

In reply to Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---
 arch/powerpc/Kconfig                 |    2 +-
 arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
 arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
 3 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +1 -1
index 805b4d1..d405298 100644
@@ -253,7 +253,7 @@ config KEXEC
 
 config CRASH_DUMP
 	bool "Build a kdump crash kernel (EXPERIMENTAL)"
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && EXPERIMENTAL
 	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/head_fsl_booke.S +18 -5
index 4b98227..1c9685f 100644
@@ -41,6 +41,12 @@
 #include <asm/asm-offsets.h>
 #include "head_booke.h"
 
+#ifdef CONFIG_CRASH_DUMP
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_64M)
+#else
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_16M)
+#endif
+
 /* As with the other PowerPC ports, it is expected that when code
  * execution begins here, the following registers contain valid, yet
  * optional, information:
@@ -75,6 +81,7 @@ _ENTRY(_start);
  * boot loader and load a single entry in TLB1[0] to map the
  * first 16M of kernel memory.  Any boot info passed from the
  * bootloader needs to live in this first 16M.
+ * Note that for crash (kdump) kernels, the first 64M is mapped.
  *
  * Requirement on bootloader:
  *  - The page we're executing in needs to reside in TLB1 and
@@ -167,7 +174,7 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	mtspr	SPRN_MAS0,r7
 	tlbre
 
-	/* Just modify the entry ID and EPN for the temp mapping */
+	/* Just modify the entry ID, EPN and RPN for the temp mapping */
 	lis	r7,0x1000	/* Set MAS0(TLBSEL) = 1 */
 	rlwimi	r7,r5,16,4,15	/* Setup MAS0 = TLBSEL | ESEL(r5) */
 	mtspr	SPRN_MAS0,r7
@@ -177,9 +184,12 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	ori	r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
 	mtspr	SPRN_MAS1,r6
 	mfspr	r6,SPRN_MAS2
-	li	r7,0		/* temp EPN = 0 */
+	lis	r7,PHYSICAL_START@h
 	rlwimi	r7,r6,0,20,31
 	mtspr	SPRN_MAS2,r7
+	mfspr	r6,SPRN_MAS3
+	rlwimi	r7,r6,0,20,31
+	mtspr	SPRN_MAS3,r7
 	tlbwe
 
 	xori	r6,r4,1
@@ -222,11 +232,11 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	lis	r6,0x1000		/* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
 	mtspr	SPRN_MAS0,r6
 	lis	r6,(MAS1_VALID|MAS1_IPROT)@h
-	ori	r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_16M))@l
+	ori	r6,r6,(MAS1_TSIZE(INITIAL_BOOKE_PAGESZ))@l
 	mtspr	SPRN_MAS1,r6
 	li	r7,0
-	lis	r6,KERNELBASE@h
-	ori	r6,r6,KERNELBASE@l
+	lis	r6,PAGE_OFFSET@h
+	ori	r6,r6,PAGE_OFFSET@l
 	rlwimi	r6,r7,0,20,31
 	mtspr	SPRN_MAS2,r6
 	li	r7,(MAS3_SX|MAS3_SW|MAS3_SR)
@@ -234,6 +244,9 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	tlbwe
 
 /* 7. Jump to KERNELBASE mapping */
+	lis	r6,KERNELBASE@h
+	ori	r6,r6,KERNELBASE@l
+	rlwimi	r6,r7,0,20,31
 	lis	r7,MSR_KERNEL@h
 	ori	r7,r7,MSR_KERNEL@l
 	bl	1f			/* Find our address */
arch/powerpc/mm/fsl_booke_mmu.c +3 -3
index 17139da..c93a966 100644
@@ -165,15 +165,15 @@ void invalidate_tlbcam_entry(int index)
 void __init cam_mapin_ram(unsigned long cam0, unsigned long cam1,
 		unsigned long cam2)
 {
-	settlbcam(0, KERNELBASE, PPC_MEMSTART, cam0, _PAGE_KERNEL, 0);
+	settlbcam(0, PAGE_OFFSET, PPC_MEMSTART, cam0, _PAGE_KERNEL, 0);
 	tlbcam_index++;
 	if (cam1) {
 		tlbcam_index++;
-		settlbcam(1, KERNELBASE+cam0, PPC_MEMSTART+cam0, cam1, _PAGE_KERNEL, 0);
+		settlbcam(1, PAGE_OFFSET+cam0, PPC_MEMSTART+cam0, cam1, _PAGE_KERNEL, 0);
 	}
 	if (cam2) {
 		tlbcam_index++;
-		settlbcam(2, KERNELBASE+cam0+cam1, PPC_MEMSTART+cam0+cam1, cam2, _PAGE_KERNEL, 0);
+		settlbcam(2, PAGE_OFFSET+cam0+cam1, PPC_MEMSTART+cam0+cam1, cam2, _PAGE_KERNEL, 0);
 	}
 }
 
Signature · 1 line
1.5.3.4
#12 lore raw

Re: [PATCH 05/10] powerpc: Add crash kernel support for 85xx

Quoted 28 lines · Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---

arch/powerpc/Kconfig                 |    2 +-
arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +0 -0
index 805b4d1..d405298 100644
@@ -253,7 +253,7 @@ config KEXEC
 

config CRASH_DUMP
bool "Build a kdump crash kernel (EXPERIMENTAL)"

arch/powerpc/Kconfig +1 -1
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && EXPERIMENTAL

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/head_fsl_booke.S +0 -0
index 4b98227..1c9685f 100644

arch/powerpc/kernel/head_fsl_booke.S line 48

Quoted 8 lines
arch/powerpc/kernel/head_fsl_booke.S +5 -0
@@ -41,6 +41,12 @@
 #include <asm/asm-offsets.h>
 #include "head_booke.h"
 
+#ifdef CONFIG_CRASH_DUMP
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_64M)
+#else
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_16M)
+#endif

I'm ok with bumping the first page to 64M in all cases.

Quoted 84 lines
arch/powerpc/kernel/head_fsl_booke.S +13 -5
+
 /* As with the other PowerPC ports, it is expected that when code
 * execution begins here, the following registers contain valid, yet
 * optional, information:
@@ -75,6 +81,7 @@ _ENTRY(_start);
 * boot loader and load a single entry in TLB1[0] to map the
 * first 16M of kernel memory.  Any boot info passed from the
 * bootloader needs to live in this first 16M.
+ * Note that for crash (kdump) kernels, the first 64M is mapped.
 *
 * Requirement on bootloader:
 *  - The page we're executing in needs to reside in TLB1 and
@@ -167,7 +174,7 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	mtspr	SPRN_MAS0,r7
 	tlbre
 
-	/* Just modify the entry ID and EPN for the temp mapping */
+	/* Just modify the entry ID, EPN and RPN for the temp mapping */
 	lis	r7,0x1000	/* Set MAS0(TLBSEL) = 1 */
 	rlwimi	r7,r5,16,4,15	/* Setup MAS0 = TLBSEL | ESEL(r5) */
 	mtspr	SPRN_MAS0,r7
@@ -177,9 +184,12 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	ori	r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
 	mtspr	SPRN_MAS1,r6
 	mfspr	r6,SPRN_MAS2
-	li	r7,0		/* temp EPN = 0 */
+	lis	r7,PHYSICAL_START@h
 	rlwimi	r7,r6,0,20,31
 	mtspr	SPRN_MAS2,r7
+	mfspr	r6,SPRN_MAS3
+	rlwimi	r7,r6,0,20,31
+	mtspr	SPRN_MAS3,r7
 	tlbwe
 
 	xori	r6,r4,1
@@ -222,11 +232,11 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	lis	r6,0x1000		/* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
 	mtspr	SPRN_MAS0,r6
 	lis	r6,(MAS1_VALID|MAS1_IPROT)@h
-	ori	r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_16M))@l
+	ori	r6,r6,(MAS1_TSIZE(INITIAL_BOOKE_PAGESZ))@l
 	mtspr	SPRN_MAS1,r6
 	li	r7,0
-	lis	r6,KERNELBASE@h
-	ori	r6,r6,KERNELBASE@l
+	lis	r6,PAGE_OFFSET@h
+	ori	r6,r6,PAGE_OFFSET@l
 	rlwimi	r6,r7,0,20,31
 	mtspr	SPRN_MAS2,r6
 	li	r7,(MAS3_SX|MAS3_SW|MAS3_SR)
@@ -234,6 +244,9 @@ skpinv:	addi	r6,r6,1				/* Increment */
 	tlbwe
 
 /* 7. Jump to KERNELBASE mapping */
+	lis	r6,KERNELBASE@h
+	ori	r6,r6,KERNELBASE@l
+	rlwimi	r6,r7,0,20,31
 	lis	r7,MSR_KERNEL@h
 	ori	r7,r7,MSR_KERNEL@l
 	bl	1f			/* Find our address */
arch/powerpc/mm/fsl_booke_mmu.c +3 -3
index 17139da..c93a966 100644
@@ -165,15 +165,15 @@ void invalidate_tlbcam_entry(int index)
 void __init cam_mapin_ram(unsigned long cam0, unsigned long cam1,
 		unsigned long cam2)
 {
-	settlbcam(0, KERNELBASE, PPC_MEMSTART, cam0, _PAGE_KERNEL, 0);
+	settlbcam(0, PAGE_OFFSET, PPC_MEMSTART, cam0, _PAGE_KERNEL, 0);
 	tlbcam_index++;
 	if (cam1) {
 		tlbcam_index++;
-		settlbcam(1, KERNELBASE+cam0, PPC_MEMSTART+cam0, cam1,  
 _PAGE_KERNEL, 0);
+		settlbcam(1, PAGE_OFFSET+cam0, PPC_MEMSTART+cam0, cam1,  
 _PAGE_KERNEL, 0);
 	}
 	if (cam2) {
 		tlbcam_index++;
-		settlbcam(2, KERNELBASE+cam0+cam1, PPC_MEMSTART+cam0+cam1, cam2,  
 _PAGE_KERNEL, 0);
+		settlbcam(2, PAGE_OFFSET+cam0+cam1, PPC_MEMSTART+cam0+cam1, cam2,  
Quoted 3 lines
_PAGE_KERNEL, 0);
	}
}

The rest looks good. Does this mean we can boot a e500 kernel at a non-zero physical address? (can we run or is the non-zero phy just for a short period of init time).

- k

#13 lore raw

Re: [PATCH 05/10] powerpc: Add crash kernel support for 85xx

Quoted 34 lines · Kumar Gala
Quoted 32 lines · Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---

arch/powerpc/Kconfig                 |    2 +-
arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +0 -0
index 805b4d1..d405298 100644
@@ -253,7 +253,7 @@ config KEXEC
 

config CRASH_DUMP
bool "Build a kdump crash kernel (EXPERIMENTAL)"

arch/powerpc/Kconfig +1 -1
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && EXPERIMENTAL

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/ renamed from arch/powerpc/kernel/head_fsl_booke.S +0 -0

kernel/head_fsl_booke.S
index 4b98227..1c9685f 100644

arch/powerpc/kernel/head_fsl_booke.S +0 -0
@@ -41,6 +41,12 @@
 #include <asm/asm-offsets.h>
 #include "head_booke.h"
 
Quoted 7 lines

arch/powerpc/kernel/head_fsl_booke.S line 48

Quoted 5 lines
arch/powerpc/kernel/head_fsl_booke.S +5 -0
+#ifdef CONFIG_CRASH_DUMP
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_64M)
+#else
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_16M)
+#endif

I'm ok with bumping the first page to 64M in all cases.

OK, I'll make that change in the next rev. Thanks.

<snip>

Quoted 3 lines

The rest looks good. Does this mean we can boot a e500 kernel at a non-zero physical address? (can we run or is the non-zero phy just for a short period of init time).

Yes, with this series of patches, we can boot and run with a classic ppc or e500 kernel at 32MB physical (0xc2000000 virtual). Note that on classic, we still need memory at phys 0 for the exception vectors. On e500 IIRC, we don't use the vectors at phys 0, but we still write the trampoline vectors there. I just didn't bother making that conditional.

I'll post an updated series soon, with hopes of getting it into 2.6.25

-Dale

#14 lore raw

Re: [PATCH 05/10] powerpc: Add crash kernel support for 85xx

Quoted 43 lines · Dale Farnsworth
Quoted 34 lines · Kumar Gala
Quoted 32 lines · Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---

arch/powerpc/Kconfig                 |    2 +-
arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +0 -0
index 805b4d1..d405298 100644
@@ -253,7 +253,7 @@ config KEXEC
 

config CRASH_DUMP
bool "Build a kdump crash kernel (EXPERIMENTAL)"

arch/powerpc/Kconfig +1 -1
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && EXPERIMENTAL

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/ renamed from arch/powerpc/kernel/head_fsl_booke.S +0 -0

kernel/head_fsl_booke.S
index 4b98227..1c9685f 100644

arch/powerpc/kernel/head_fsl_booke.S +0 -0
@@ -41,6 +41,12 @@
 #include <asm/asm-offsets.h>
 #include "head_booke.h"
 
Quoted 7 lines

arch/powerpc/kernel/head_fsl_booke.S line 48

Quoted 5 lines
arch/powerpc/kernel/head_fsl_booke.S +5 -0
+#ifdef CONFIG_CRASH_DUMP
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_64M)
+#else
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_16M)
+#endif

I'm ok with bumping the first page to 64M in all cases.

Quoted 1 line

OK, I'll make that change in the next rev. Thanks.

I'm about to commit a version of this patch, why did you need to bump to 64M?

Quoted 8 lines

<snip>

Quoted 3 lines

The rest looks good. Does this mean we can boot a e500 kernel at a non-zero physical address? (can we run or is the non-zero phy just for a short period of init time).

Quoted 5 lines

Yes, with this series of patches, we can boot and run with a classic ppc or e500 kernel at 32MB physical (0xc2000000 virtual). Note that on classic, we still need memory at phys 0 for the exception vectors. On e500 IIRC, we don't use the vectors at phys 0, but we still write the trampoline vectors there. I just didn't bother making that conditional.

trampoline vectors?

Quoted 1 line

I'll post an updated series soon, with hopes of getting it into 2.6.25

- k

#15 lore raw

Re: [PATCH 05/10] powerpc: Add crash kernel support for 85xx

Quoted 44 lines · Kumar Gala
Quoted 43 lines · Dale Farnsworth
Quoted 41 lines · Kumar Gala
Quoted 29 lines · Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---

arch/powerpc/Kconfig                 |    2 +-
arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +0 -0
index 805b4d1..d405298 100644
@@ -253,7 +253,7 @@ config KEXEC
 

config CRASH_DUMP
bool "Build a kdump crash kernel (EXPERIMENTAL)"

arch/powerpc/Kconfig +1 -1
-	depends on PPC_MULTIPLATFORM && EXPERIMENTAL
+	depends on (PPC_MULTIPLATFORM || PPC_85xx) && EXPERIMENTAL

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/ renamed from arch/powerpc/kernel/head_fsl_booke.S +0 -0

kernel/head_fsl_booke.S
index 4b98227..1c9685f 100644

arch/powerpc/kernel/head_fsl_booke.S line 48

Quoted 8 lines
arch/powerpc/kernel/head_fsl_booke.S +5 -0
@@ -41,6 +41,12 @@
 #include <asm/asm-offsets.h>
 #include "head_booke.h"
 
+#ifdef CONFIG_CRASH_DUMP
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_64M)
+#else
+#define INITIAL_BOOKE_PAGESZ (BOOKE_PAGESZ_16M)
+#endif

I'm ok with bumping the first page to 64M in all cases.

Quoted 4 lines
Quoted 1 line

OK, I'll make that change in the next rev. Thanks.

I'm about to commit a version of this patch, why did you need to bump to 64M?

See below.

Quoted 6 lines
Quoted 6 lines

<snip>

Quoted 3 lines

The rest looks good. Does this mean we can boot a e500 kernel at a non-zero physical address? (can we run or is the non-zero phy just for a short period of init time).

Quoted 8 lines
Quoted 6 lines

Yes, with this series of patches, we can boot and run with a classic ppc or e500 kernel at 32MB physical (0xc2000000 virtual). Note that on classic, we still need memory at phys 0 for the exception vectors. On e500 IIRC, we don't use the vectors at phys 0, but we still write the trampoline vectors there. I just didn't bother making that conditional.

trampoline vectors?

Even though the kernel is loaded at 32M, the vectors still reside at 0 (at least on non-booke). There is code that saves the low 64K away, then create_trampoline() in crash_dump.c fills each vector with a "b . + 32M" sequence.

As to why 64M, since the kernel is loaded at 32M, and we still set up the trampoline vectors at 0, we need more than 16M. It's possible that we could skip writing the trampoline vectors on booke and then just just initially map 16M at 32M. I haven't tried it and can't prove that it won't work, but I don't know that it's worth doing.

Quoted 1 line
Quoted 1 line

I'll post an updated series soon, with hopes of getting it into 2.6.25

I think my time for doing it "soon" has passed. Still plan to do it.

Kumar, thanks for pursuing this.

-Dale

Applied
#16 lore raw

Re: [PATCH 05/10] powerpc: Add crash kernel support for 85xx

In reply to Dale Farnsworth
Quoted 10 lines · Dale Farnsworth

Add the ability to build a ppc_85xx kernel to run at a physical address of 32MB.

---
 arch/powerpc/Kconfig                 |    2 +-
 arch/powerpc/kernel/head_fsl_booke.S |   23 ++++++++++++++++++-----
 arch/powerpc/mm/fsl_booke_mmu.c      |    6 +++---
 3 files changed, 22 insertions(+), 9 deletions(-)

applied. (w/o Kconfig since this is useful for other purposes).

-k

#17 lore raw

PATCH 6/10 powerpc: Fix bogus crash kernel messages

In reply to Dale Farnsworth

Commit edd8ce67, Use extended crashkernel command line on ppc64, resulted in reserve_crashkernel() attempting to reserve a 1 byte crashkernel area when no no crashkernel reservation is requested. This results in the following bogus messages:
Crash kernel location must be 0x2000000
Reserving 0MB of memory at 32MB for crashkernel

The problem is that when crashk_res.start and crashk_res.end are both 0, the crash_size is computed to be 1 byte.

Revert back to using the value of crashk_res.start to determine if crashkernel memory is being reserved, rather than the computed crash_size.

---
 arch/powerpc/kernel/machine_kexec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/machine_kexec.c +1 -1
index 691dba7..38c1c1a 100644
@@ -84,7 +84,7 @@ void __init reserve_crashkernel(void)
 		crash_size = crashk_res.end - crashk_res.start + 1;
 	}
 
-	if (crash_size == 0)
+	if (crashk_res.start == 0)
 		return;
 
 	/* We might have got these values via the command line or the
Signature · 1 line
1.5.3.4
#18 lore raw

PATCH 7/10 powerpc: Implement kmap_atomic_pfn on powerpc

In reply to Dale Farnsworth

This is needed for the ppc32 /dev/oldmem driver of crash dump.

---
 include/asm-powerpc/highmem.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
include/asm-powerpc/highmem.h +18 -0
index f7b21ee..88d9e05 100644
@@ -117,6 +117,24 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
 	pagefault_enable();
 }
 
+/* This is the same as kmap_atomic() but can map memory that doesn't
+ * have a struct page associated with it.
+ */
+static inline void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+{
+	unsigned int idx;
+	unsigned long vaddr;
+
+	pagefault_disable();
+
+	idx = type + KM_TYPE_NR * smp_processor_id();
+	vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE;
+	set_pte_at(&init_mm, vaddr, kmap_pte+idx, pfn_pte(pfn, kmap_prot));
+	flush_tlb_page(NULL, vaddr);
+
+	return (void*) vaddr;
+}
+
 static inline struct page *kmap_atomic_to_page(void *ptr)
 {
 	unsigned long idx, vaddr = (unsigned long) ptr;
Signature · 1 line
1.5.3.4
#19 lore raw

Re: [PATCH 07/10] powerpc: Implement kmap_atomic_pfn on powerpc

Quoted 1 line · Dale Farnsworth

This is needed for the ppc32 /dev/oldmem driver of crash dump.

Kumar's working (well, last I heard he was) on a fixmap mechanism so we can do that sort of thing without CONFIG_HIGHMEM, you may want to sync with him here, that would allow to shrink the crash kernel by not having highmem selected.

Cheers,
Ben.

Quoted 34 lines
---
 include/asm-powerpc/highmem.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
include/asm-powerpc/highmem.h +18 -0
index f7b21ee..88d9e05 100644
@@ -117,6 +117,24 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
 	pagefault_enable();
 }
 
+/* This is the same as kmap_atomic() but can map memory that doesn't
+ * have a struct page associated with it.
+ */
+static inline void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+{
+	unsigned int idx;
+	unsigned long vaddr;
+
+	pagefault_disable();
+
+	idx = type + KM_TYPE_NR * smp_processor_id();
+	vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE;
+	set_pte_at(&init_mm, vaddr, kmap_pte+idx, pfn_pte(pfn, kmap_prot));
+	flush_tlb_page(NULL, vaddr);
+
+	return (void*) vaddr;
+}
+
 static inline struct page *kmap_atomic_to_page(void *ptr)
 {
 	unsigned long idx, vaddr = (unsigned long) ptr;
#20 lore raw

Re: [PATCH 07/10] powerpc: Implement kmap_atomic_pfn on powerpc

Quoted 11 lines · Benjamin Herrenschmidt
Quoted 1 line · Dale Farnsworth

This is needed for the ppc32 /dev/oldmem driver of crash dump.

Kumar's working (well, last I heard he was) on a fixmap mechanism so we can do that sort of thing without CONFIG_HIGHMEM, you may want to sync with him here, that would allow to shrink the crash kernel by not having highmem selected.

Cheers,
Ben.

Kumar, are you close to posting something that would make the patch below unnecessary (or change it significantly)? If so, I'll hold off.

-Dale

Quoted 34 lines
Quoted 34 lines
---
 include/asm-powerpc/highmem.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
include/asm-powerpc/highmem.h +18 -0
index f7b21ee..88d9e05 100644
@@ -117,6 +117,24 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
 	pagefault_enable();
 }
 
+/* This is the same as kmap_atomic() but can map memory that doesn't
+ * have a struct page associated with it.
+ */
+static inline void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+{
+	unsigned int idx;
+	unsigned long vaddr;
+
+	pagefault_disable();
+
+	idx = type + KM_TYPE_NR * smp_processor_id();
+	vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE;
+	set_pte_at(&init_mm, vaddr, kmap_pte+idx, pfn_pte(pfn, kmap_prot));
+	flush_tlb_page(NULL, vaddr);
+
+	return (void*) vaddr;
+}
+
 static inline struct page *kmap_atomic_to_page(void *ptr)
 {
 	unsigned long idx, vaddr = (unsigned long) ptr;
#21 lore raw

Re: [PATCH 07/10] powerpc: Implement kmap_atomic_pfn on powerpc

Quoted 10 lines · Dale Farnsworth
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 1 line · Dale Farnsworth

This is needed for the ppc32 /dev/oldmem driver of crash dump.

Kumar's working (well, last I heard he was) on a fixmap mechanism so we can do that sort of thing without CONFIG_HIGHMEM, you may want to sync with him here, that would allow to shrink the crash kernel by not having highmem selected.

Quoted 6 lines
Quoted 2 lines

Cheers,
Ben.

Kumar, are you close to posting something that would make the patch below unnecessary (or change it significantly)? If so, I'll hold off.

My plan is to get the fixmap stuff posted this week.

- k

#22 lore raw

PATCH 8/10 powerpc: Implement crash dump support on ppc32

In reply to Dale Farnsworth

Implement /dev/oldmem and /proc/vmcore support for ppc32. It is used to provide crash dumps of the previously running kernel.

---
 arch/powerpc/kernel/crash_dump.c |   67 ++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/kexec.h      |   62 +++++++++++++++++++++++++++++++++--
 2 files changed, 126 insertions(+), 3 deletions(-)
arch/powerpc/kernel/crash_dump.c +67 -0
index 77c0376..39a3d92 100644
@@ -13,6 +13,7 @@
 
 #include <linux/crash_dump.h>
 #include <linux/bootmem.h>
+#include <linux/highmem.h>
 #include <asm/kdump.h>
 #include <asm/lmb.h>
 #include <asm/firmware.h>
@@ -83,6 +84,7 @@ static int __init parse_savemaxmem(char *p)
 }
 __setup("savemaxmem=", parse_savemaxmem);
 
+#ifdef CONFIG_PPC64
 /**
  * copy_oldmem_page - copy one page from "oldmem"
  * @pfn: page frame number to be copied
@@ -117,3 +119,68 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
 	iounmap(vaddr);
 	return csize;
 }
+
+#else	/* CONFIG_PPC64 */
+
+static void *kdump_buf_page;
+
+/**
+ * copy_oldmem_page - copy one page from "oldmem"
+ * @pfn: page frame number to be copied
+ * @buf: target memory address for the copy; this can be in kernel address
+ *	space or user address space (see @userbuf)
+ * @csize: number of bytes to copy
+ * @offset: offset in bytes into the page (based on pfn) to begin the copy
+ * @userbuf: if set, @buf is in user address space, use copy_to_user(),
+ *	otherwise @buf is in kernel address space, use memcpy().
+ *
+ * Copy a page from "oldmem". For this page, there is no pte mapped
+ * in the current kernel.
+ *
+ * Calling copy_to_user() in atomic context is not desirable. Hence first
+ * copying the data to a pre-allocated kernel page and then copying to user
+ * space in non-atomic context.
+ */
+ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
+                               size_t csize, unsigned long offset, int userbuf)
+{
+	void  *vaddr;
+
+	if (!csize)
+		return 0;
+
+	vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
+
+	if (!userbuf) {
+		memcpy(buf, (vaddr + offset), csize);
+		kunmap_atomic(vaddr, KM_PTE0);
+	} else {
+		if (!kdump_buf_page) {
+			printk(KERN_WARNING "Kdump: Kdump buffer page not"
+				" allocated\n");
+			return -EFAULT;
+		}
+		copy_page(kdump_buf_page, vaddr);
+		kunmap_atomic(vaddr, KM_PTE0);
+		if (copy_to_user(buf, (kdump_buf_page + offset), csize))
+			return -EFAULT;
+	}
+
+	return csize;
+}
+
+static int __init kdump_buf_page_init(void)
+{
+	int ret = 0;
+
+	kdump_buf_page = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!kdump_buf_page) {
+		printk(KERN_WARNING "Kdump: Failed to allocate kdump buffer"
+			 " page\n");
+		ret = -ENOMEM;
+	}
+
+	return ret;
+}
+arch_initcall(kdump_buf_page_init);
+#endif	/* CONFIG_PPC64 */
include/asm-powerpc/kexec.h +59 -3

70 lines not on this page · raw message

Signature · 1 line
1.5.3.4
#23 lore raw

PATCH 9/10 powepc: Remove unnecessary of_get_flat_dt_prop casts

In reply to Dale Farnsworth

of_get_flat_dt_prop returns a void*. There is no need to cast its value when assigning to a pointer variable. This also avoids warnings on ppc32 where unsigned long is 32 bits.

---
 arch/powerpc/kernel/prom.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/prom.c +2 -2
index acc0d24..e2e7d9c 100644
@@ -790,11 +790,11 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
 #endif
 
 #ifdef CONFIG_KEXEC
-	lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
+	lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
 	if (lprop)
 		crashk_res.start = *lprop;
 
-	lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-size", NULL);
+	lprop = of_get_flat_dt_prop(node, "linux,crashkernel-size", NULL);
 	if (lprop)
 		crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
Signature · 1 line
1.5.3.4
#24 lore raw

PATCH 10/10 powerpc: Make crashkernels ignore crashkernel reservations

In reply to Dale Farnsworth

If a user requests a crash kernel to reserve crashkernel memory, the kernel fails to boot. While the user shouldn't do that, it is easy to check for and makes it possible to use the same command line for crash kernels as for the initial kernel.

---
 arch/powerpc/kernel/machine_kexec.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/powerpc/kernel/machine_kexec.c +8 -0
index 38c1c1a..733726a 100644
@@ -94,6 +94,14 @@ void __init reserve_crashkernel(void)
 		printk("Crash kernel location must be 0x%x\n",
 				KDUMP_KERNELBASE);
 
+	if (PHYSICAL_START == KDUMP_KERNELBASE) {
+		printk("Already running a crashkernel, "
+			"ignoring crashkernel reservation\n");
+		crashk_res.start = 0;
+		crashk_res.end = 0;
+		return;
+	}
+
 	crashk_res.start = KDUMP_KERNELBASE;
 	crash_size = PAGE_ALIGN(crash_size);
 	crashk_res.end = crashk_res.start + crash_size - 1;
Signature · 1 line
1.5.3.4
#25 lore raw
In reply to Dale Farnsworth
Quoted 4 lines · Dale Farnsworth

This patch series adds kexec and kdump support for ppc32 in arch/powerpc. It has been successfully tested on the mpc8548_cds and prpmc2800 platforms. Mark Greer and I are preparing patches to the kexec-tools package as well.

Dale, can you look at updating your patchset now that we've made some progress on other patches.

- k

#26 lore raw
Quoted 10 lines · Kumar Gala
Quoted 6 lines · Dale Farnsworth

This patch series adds kexec and kdump support for ppc32 in arch/ powerpc.
It has been successfully tested on the mpc8548_cds and prpmc2800 platforms.
Mark Greer and I are preparing patches to the kexec-tools package as well.

Dale, can you look at updating your patchset now that we've made some progress on other patches.

Yes. It'll take a couple of weeks for me to fit it in though.

-Dale

#27 lore raw
Quoted 9 lines · Dale Farnsworth
Quoted 8 lines · Kumar Gala
Quoted 6 lines · Dale Farnsworth

This patch series adds kexec and kdump support for ppc32 in arch/ powerpc.
It has been successfully tested on the mpc8548_cds and prpmc2800 platforms.
Mark Greer and I are preparing patches to the kexec-tools package as well.

Quoted 4 lines
Quoted 2 lines

Dale, can you look at updating your patchset now that we've made some progress on other patches.

Yes. It'll take a couple of weeks for me to fit it in though.

no problem. I figure we are aiming for 2.6.27 for this functionality.

- k