Skip to contentSkip to conversation

kexec support for Linux/m68k (kernel part)

PATCH New Geert Uytterhoeven 3 participants 13 messages Oct 15, 2013

Subsystems (4)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

PATCH v2 1/1 kexec support for Linux/m68k (kernel part)

This is a set of patches to add kexec support for m68k to the Linux kernel.

- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)

- Tested on ARAnyM, with emulated 68040.
I tested the behavior for machines where memory doesn't start at zero (e.g. Amiga) by modifying the bootinfo to make ST-RAM memory start at 0x20000000, which also works (this does require a small patch to make atari_stram_init() succeed).

- Tested on Amiga 4000/040, where it hangs :-(
Probably this is due to lack of memory. It also crashes on ARAnyM with only 12 MiB of RAM. It seems something is corrupted when copying, although I couldn't detect any overlapping copies using the debug code in patch 1.

- Test results on real machines with more than 16 MiB of RAM and different CPUs would be welcome!

You can download a kexec binary from
http://users.telenet.be/geertu/Download/kexec-m68k-2013-10-15.tar.bz2

- To have automatic "kexec -e" on reboot, copy /etc/rc6.d/S85kexec from another system, and fix it up for kexec living in /usr/local/sbin instead of /sbin.

- Sample invocation:

        kexec -d -l vmlinux --reuse-cmdline
        reboot

Patches:
- [PATCH 1/3] kexec: Add debug printing of kimage table entries
- v2: new patch
- [PATCH 2/3] m68k: Add kexec support
- v2:
- KEXEC depends on M68KCLASSIC,
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Support for other CPUs than 68040.
- [PATCH 3/3] m68k: Add support to export bootinfo in procfs
- v2: no changes
- "m68k: Add System RAM to /proc/iomem" was dropped in v2.

Have fun!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#1 lore raw

PATCH 1/3 kexec: Add debug printing of kimage table entries

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

---
 kernel/kexec.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
kernel/kexec.c +76 -0
index 490afc03627e..e25022ac229e 100644
@@ -1073,6 +1073,80 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 }
 #endif
 
+#ifdef DEBUG
+struct kimage_block {
+	unsigned long dst, src, len;
+};
+
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}
+
+static void kimage_print(const struct kimage *image)
+{
+	void *control_code_page;
+	const kimage_entry_t *ptr;
+	kimage_entry_t entry;
+	struct kimage_block block;
+	unsigned long dnext = KIMAGE_NO_DEST, snext = KIMAGE_NO_DEST;
+	unsigned long total = 0;
+
+	control_code_page = page_address(image->control_code_page);
+	pr_info("Control code page 0x%p (phys 0x%lx)\n",
+		control_code_page, virt_to_phys(control_code_page));
+
+	ptr = &image->head;
+	block.dst = KIMAGE_NO_DEST;
+	block.src = KIMAGE_NO_DEST;
+	block.len = 0;
+	while ((entry = *ptr)) {
+		if (entry & IND_DONE)
+			break;
+
+		if (entry & IND_DESTINATION) {
+			if (block.len > 0) {
+				kimage_print_block(&block);
+				total += block.len;
+			}
+			dnext = block.dst = entry & PAGE_MASK;
+			block.src = KIMAGE_NO_DEST;
+			block.len = 0;
+		}
+
+		if (entry & IND_SOURCE) {
+			if (!block.len) {
+				snext = block.src = entry & PAGE_MASK;
+			} else if ((entry & PAGE_MASK) != snext) {
+				kimage_print_block(&block);
+				total += block.len;
+				block.dst = dnext;
+				snext = block.src = entry & PAGE_MASK;
+				block.len = 0;
+			}
+			dnext += PAGE_SIZE;
+			snext += PAGE_SIZE;
+			block.len += PAGE_SIZE;
+		}
+
+		if (entry & IND_INDIRECTION) {
+			pr_info("Indirection page 0x%lx\n", entry & PAGE_MASK);
+			ptr = phys_to_virt(entry & PAGE_MASK);
+		} else
+			ptr++;
+	}
+	if (block.len) {
+		kimage_print_block(&block);
+		total += block.len;
+	}
+	pr_info("Total: 0x%lx/%ld bytes\n", total, total);
+}
+#else
+static inline void kimage_print(const struct kimage *image) {}
+#endif
+
 void crash_kexec(struct pt_regs *regs)
 {
 	/* Take the kexec_mutex here to prevent sys_kexec_load
@@ -1090,6 +1164,7 @@ void crash_kexec(struct pt_regs *regs)
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
 			machine_crash_shutdown(&fixed_regs);
+			kimage_print(kexec_crash_image);
 			machine_kexec(kexec_crash_image);
 		}
 		mutex_unlock(&kexec_mutex);
@@ -1680,6 +1755,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kimage_print(kexec_image);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP
Signature · 1 line
1.7.9.5
author maintainer
#2 lore raw

PATCH 1/3 kexec: Add debug printing of kimage table entries

In reply to Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

---
 kernel/kexec.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
kernel/kexec.c +76 -0
index 490afc03627e..e25022ac229e 100644
@@ -1073,6 +1073,80 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 }
 #endif
 
+#ifdef DEBUG
+struct kimage_block {
+	unsigned long dst, src, len;
+};
+
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}
+
+static void kimage_print(const struct kimage *image)
+{
+	void *control_code_page;
+	const kimage_entry_t *ptr;
+	kimage_entry_t entry;
+	struct kimage_block block;
+	unsigned long dnext = KIMAGE_NO_DEST, snext = KIMAGE_NO_DEST;
+	unsigned long total = 0;
+
+	control_code_page = page_address(image->control_code_page);
+	pr_info("Control code page 0x%p (phys 0x%lx)\n",
+		control_code_page, virt_to_phys(control_code_page));
+
+	ptr = &image->head;
+	block.dst = KIMAGE_NO_DEST;
+	block.src = KIMAGE_NO_DEST;
+	block.len = 0;
+	while ((entry = *ptr)) {
+		if (entry & IND_DONE)
+			break;
+
+		if (entry & IND_DESTINATION) {
+			if (block.len > 0) {
+				kimage_print_block(&block);
+				total += block.len;
+			}
+			dnext = block.dst = entry & PAGE_MASK;
+			block.src = KIMAGE_NO_DEST;
+			block.len = 0;
+		}
+
+		if (entry & IND_SOURCE) {
+			if (!block.len) {
+				snext = block.src = entry & PAGE_MASK;
+			} else if ((entry & PAGE_MASK) != snext) {
+				kimage_print_block(&block);
+				total += block.len;
+				block.dst = dnext;
+				snext = block.src = entry & PAGE_MASK;
+				block.len = 0;
+			}
+			dnext += PAGE_SIZE;
+			snext += PAGE_SIZE;
+			block.len += PAGE_SIZE;
+		}
+
+		if (entry & IND_INDIRECTION) {
+			pr_info("Indirection page 0x%lx\n", entry & PAGE_MASK);
+			ptr = phys_to_virt(entry & PAGE_MASK);
+		} else
+			ptr++;
+	}
+	if (block.len) {
+		kimage_print_block(&block);
+		total += block.len;
+	}
+	pr_info("Total: 0x%lx/%ld bytes\n", total, total);
+}
+#else
+static inline void kimage_print(const struct kimage *image) {}
+#endif
+
 void crash_kexec(struct pt_regs *regs)
 {
 	/* Take the kexec_mutex here to prevent sys_kexec_load
@@ -1090,6 +1164,7 @@ void crash_kexec(struct pt_regs *regs)
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
 			machine_crash_shutdown(&fixed_regs);
+			kimage_print(kexec_crash_image);
 			machine_kexec(kexec_crash_image);
 		}
 		mutex_unlock(&kexec_mutex);
@@ -1680,6 +1755,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kimage_print(kexec_image);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

[]

kernel/kexec.c

Quoted 1 line
kernel/kexec.c +0 -0

[]

kernel/kexec.c asmlinkage long compat_sys_kexec_load(unsigned long entry, · line 1086

Quoted 6 lines
kernel/kexec.c +6 -0
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}

Perhaps pr_debug and this maybe nicer to read like:

	pr_debug("kimage: Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
		 block->src, block->src + block->len - 1,
		 block->dst, block->dst + block->len - 1,
		 block->len);

Using a "kimage: " prefix could help grep too.

#4 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

In reply to Geert Uytterhoeven
Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

[]

kernel/kexec.c

Quoted 1 line
kernel/kexec.c +0 -0

[]

kernel/kexec.c asmlinkage long compat_sys_kexec_load(unsigned long entry, · line 1086

Quoted 6 lines
kernel/kexec.c +6 -0
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}

Perhaps pr_debug and this maybe nicer to read like:

	pr_debug("kimage: Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
		 block->src, block->src + block->len - 1,
		 block->dst, block->dst + block->len - 1,
		 block->len);

Using a "kimage: " prefix could help grep too.

#5 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

In reply to Geert Uytterhoeven
Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

Why is this desirable?

I can understand this as debugging code to understand what is happening, but why would we want to maintain this print statement long term?

Quoted 107 lines
---
 kernel/kexec.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
kernel/kexec.c +76 -0
index 490afc03627e..e25022ac229e 100644
@@ -1073,6 +1073,80 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 }
 #endif
 
+#ifdef DEBUG
+struct kimage_block {
+	unsigned long dst, src, len;
+};
+
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}
+
+static void kimage_print(const struct kimage *image)
+{
+	void *control_code_page;
+	const kimage_entry_t *ptr;
+	kimage_entry_t entry;
+	struct kimage_block block;
+	unsigned long dnext = KIMAGE_NO_DEST, snext = KIMAGE_NO_DEST;
+	unsigned long total = 0;
+
+	control_code_page = page_address(image->control_code_page);
+	pr_info("Control code page 0x%p (phys 0x%lx)\n",
+		control_code_page, virt_to_phys(control_code_page));
+
+	ptr = &image->head;
+	block.dst = KIMAGE_NO_DEST;
+	block.src = KIMAGE_NO_DEST;
+	block.len = 0;
+	while ((entry = *ptr)) {
+		if (entry & IND_DONE)
+			break;
+
+		if (entry & IND_DESTINATION) {
+			if (block.len > 0) {
+				kimage_print_block(&block);
+				total += block.len;
+			}
+			dnext = block.dst = entry & PAGE_MASK;
+			block.src = KIMAGE_NO_DEST;
+			block.len = 0;
+		}
+
+		if (entry & IND_SOURCE) {
+			if (!block.len) {
+				snext = block.src = entry & PAGE_MASK;
+			} else if ((entry & PAGE_MASK) != snext) {
+				kimage_print_block(&block);
+				total += block.len;
+				block.dst = dnext;
+				snext = block.src = entry & PAGE_MASK;
+				block.len = 0;
+			}
+			dnext += PAGE_SIZE;
+			snext += PAGE_SIZE;
+			block.len += PAGE_SIZE;
+		}
+
+		if (entry & IND_INDIRECTION) {
+			pr_info("Indirection page 0x%lx\n", entry & PAGE_MASK);
+			ptr = phys_to_virt(entry & PAGE_MASK);
+		} else
+			ptr++;
+	}
+	if (block.len) {
+		kimage_print_block(&block);
+		total += block.len;
+	}
+	pr_info("Total: 0x%lx/%ld bytes\n", total, total);
+}
+#else
+static inline void kimage_print(const struct kimage *image) {}
+#endif
+
 void crash_kexec(struct pt_regs *regs)
 {
 	/* Take the kexec_mutex here to prevent sys_kexec_load
@@ -1090,6 +1164,7 @@ void crash_kexec(struct pt_regs *regs)
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
 			machine_crash_shutdown(&fixed_regs);
+			kimage_print(kexec_crash_image);
 			machine_kexec(kexec_crash_image);
 		}
 		mutex_unlock(&kexec_mutex);
@@ -1680,6 +1755,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kimage_print(kexec_image);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP
#6 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

In reply to Geert Uytterhoeven
Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

Why is this desirable?

I can understand this as debugging code to understand what is happening, but why would we want to maintain this print statement long term?

Quoted 107 lines
---
 kernel/kexec.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
kernel/kexec.c +76 -0
index 490afc03627e..e25022ac229e 100644
@@ -1073,6 +1073,80 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 }
 #endif
 
+#ifdef DEBUG
+struct kimage_block {
+	unsigned long dst, src, len;
+};
+
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}
+
+static void kimage_print(const struct kimage *image)
+{
+	void *control_code_page;
+	const kimage_entry_t *ptr;
+	kimage_entry_t entry;
+	struct kimage_block block;
+	unsigned long dnext = KIMAGE_NO_DEST, snext = KIMAGE_NO_DEST;
+	unsigned long total = 0;
+
+	control_code_page = page_address(image->control_code_page);
+	pr_info("Control code page 0x%p (phys 0x%lx)\n",
+		control_code_page, virt_to_phys(control_code_page));
+
+	ptr = &image->head;
+	block.dst = KIMAGE_NO_DEST;
+	block.src = KIMAGE_NO_DEST;
+	block.len = 0;
+	while ((entry = *ptr)) {
+		if (entry & IND_DONE)
+			break;
+
+		if (entry & IND_DESTINATION) {
+			if (block.len > 0) {
+				kimage_print_block(&block);
+				total += block.len;
+			}
+			dnext = block.dst = entry & PAGE_MASK;
+			block.src = KIMAGE_NO_DEST;
+			block.len = 0;
+		}
+
+		if (entry & IND_SOURCE) {
+			if (!block.len) {
+				snext = block.src = entry & PAGE_MASK;
+			} else if ((entry & PAGE_MASK) != snext) {
+				kimage_print_block(&block);
+				total += block.len;
+				block.dst = dnext;
+				snext = block.src = entry & PAGE_MASK;
+				block.len = 0;
+			}
+			dnext += PAGE_SIZE;
+			snext += PAGE_SIZE;
+			block.len += PAGE_SIZE;
+		}
+
+		if (entry & IND_INDIRECTION) {
+			pr_info("Indirection page 0x%lx\n", entry & PAGE_MASK);
+			ptr = phys_to_virt(entry & PAGE_MASK);
+		} else
+			ptr++;
+	}
+	if (block.len) {
+		kimage_print_block(&block);
+		total += block.len;
+	}
+	pr_info("Total: 0x%lx/%ld bytes\n", total, total);
+}
+#else
+static inline void kimage_print(const struct kimage *image) {}
+#endif
+
 void crash_kexec(struct pt_regs *regs)
 {
 	/* Take the kexec_mutex here to prevent sys_kexec_load
@@ -1090,6 +1164,7 @@ void crash_kexec(struct pt_regs *regs)
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
 			machine_crash_shutdown(&fixed_regs);
+			kimage_print(kexec_crash_image);
 			machine_kexec(kexec_crash_image);
 		}
 		mutex_unlock(&kexec_mutex);
@@ -1680,6 +1755,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kimage_print(kexec_image);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP
author maintainer
#7 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

Why is this desirable?

I can understand this as debugging code to understand what is happening, but why would we want to maintain this print statement long term?

Because the next person who ports kexec to a new platform may need it, so he doesn't have to reimplement the wheel?

It's disabled by default.

It also serves as documentation for the indirection page.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#8 lore raw

Re: [PATCH 1/3] kexec: Add debug printing of kimage table entries

In reply to Eric W. Biederman
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Geert Uytterhoeven

Print a list of pages to be copied if debugging is enabled. Consecutive entries are merged to reduce screen clutter.

Why is this desirable?

I can understand this as debugging code to understand what is happening, but why would we want to maintain this print statement long term?

Because the next person who ports kexec to a new platform may need it, so he doesn't have to reimplement the wheel?

It's disabled by default.

It also serves as documentation for the indirection page.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#9 lore raw

PATCH 2/3 m68k: Add kexec support

In reply to Geert Uytterhoeven

---
v2:
- KEXEC depends on M68KCLASSIC,
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Support for other CPUs than 68040.

 arch/m68k/Kconfig                  |   17 ++++
 arch/m68k/include/asm/kexec.h      |   29 +++++++
 arch/m68k/kernel/Makefile          |    2 +
 arch/m68k/kernel/asm-offsets.c     |    3 +
 arch/m68k/kernel/machine_kexec.c   |   58 ++++++++++++++
 arch/m68k/kernel/relocate_kernel.S |  155 ++++++++++++++++++++++++++++++++++++
 include/uapi/linux/kexec.h         |    1 +
 7 files changed, 265 insertions(+)
 create mode 100644 arch/m68k/include/asm/kexec.h
 create mode 100644 arch/m68k/kernel/machine_kexec.c
 create mode 100644 arch/m68k/kernel/relocate_kernel.S
arch/m68k/Kconfig +17 -0
index 311a300d48cc..5d65c39bfc69 100644
@@ -86,6 +86,23 @@ config MMU_SUN3
 	bool
 	depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
 
+config KEXEC
+	bool "kexec system call"
+	depends on M68KCLASSIC
+	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 independent of the system firmware.   And like a reboot
+	  you can start any kernel with it, not just Linux.
+
+	  The name comes from the similarity 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.  As of this writing the exact hardware
+	  interface is strongly in flux, so no good recommendation can be
+	  made.
+
 menu "Platform setup"
 
 source arch/m68k/Kconfig.cpu
arch/m68k/include/asm/kexec.h new file +29 -0
new file mode 100644
index 000000000000..3df97abac147
@@ -0,0 +1,29 @@
+#ifndef _ASM_M68K_KEXEC_H
+#define _ASM_M68K_KEXEC_H
+
+#ifdef CONFIG_KEXEC
+
+/* 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 (-1UL)
+
+#define KEXEC_CONTROL_PAGE_SIZE	4096
+
+#define KEXEC_ARCH KEXEC_ARCH_68K
+
+#ifndef __ASSEMBLY__
+
+static inline void crash_setup_regs(struct pt_regs *newregs,
+				    struct pt_regs *oldregs)
+{
+	/* Dummy implementation for now */
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_KEXEC */
+
+#endif /* _ASM_M68K_KEXEC_H */
arch/m68k/kernel/Makefile +2 -0
index 655347d80780..7ee5f00a9abb 100644
@@ -22,3 +22,5 @@ obj-$(CONFIG_PCI) += pcibios.o
 
 obj-$(CONFIG_HAS_DMA)	+= dma.o
 
+obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
+
arch/m68k/kernel/asm-offsets.c +3 -0
index 8b7b22846366..3a386341aa6e 100644
@@ -98,6 +98,9 @@ int main(void)
 	DEFINE(CIABBASE, &ciab);
 	DEFINE(C_PRA, offsetof(struct CIA, pra));
 	DEFINE(ZTWOBASE, zTwoBase);
+
+	/* enum m68k_fixup_type */
+	DEFINE(M68K_FIXUP_MEMOFFSET, m68k_fixup_memoffset);
 #endif
 
 	return 0;
arch/m68k/kernel/machine_kexec.c new file +58 -0

58 lines not on this page · raw message

arch/m68k/kernel/relocate_kernel.S new file +155 -0

155 lines not on this page · raw message

include/uapi/linux/kexec.h +1 -0
index 104838f65bc1..d6629d49a243 100644
@@ -18,6 +18,7 @@
  */
 #define KEXEC_ARCH_DEFAULT ( 0 << 16)
 #define KEXEC_ARCH_386     ( 3 << 16)
+#define KEXEC_ARCH_68K     ( 4 << 16)
 #define KEXEC_ARCH_X86_64  (62 << 16)
 #define KEXEC_ARCH_PPC     (20 << 16)
 #define KEXEC_ARCH_PPC64   (21 << 16)
Signature · 1 line
1.7.9.5
author maintainer
#10 lore raw

PATCH 2/3 m68k: Add kexec support

In reply to Geert Uytterhoeven

---
v2:
- KEXEC depends on M68KCLASSIC,
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Support for other CPUs than 68040.

 arch/m68k/Kconfig                  |   17 ++++
 arch/m68k/include/asm/kexec.h      |   29 +++++++
 arch/m68k/kernel/Makefile          |    2 +
 arch/m68k/kernel/asm-offsets.c     |    3 +
 arch/m68k/kernel/machine_kexec.c   |   58 ++++++++++++++
 arch/m68k/kernel/relocate_kernel.S |  155 ++++++++++++++++++++++++++++++++++++
 include/uapi/linux/kexec.h         |    1 +
 7 files changed, 265 insertions(+)
 create mode 100644 arch/m68k/include/asm/kexec.h
 create mode 100644 arch/m68k/kernel/machine_kexec.c
 create mode 100644 arch/m68k/kernel/relocate_kernel.S
arch/m68k/Kconfig +17 -0
index 311a300d48cc..5d65c39bfc69 100644
@@ -86,6 +86,23 @@ config MMU_SUN3
 	bool
 	depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
 
+config KEXEC
+	bool "kexec system call"
+	depends on M68KCLASSIC
+	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 independent of the system firmware.   And like a reboot
+	  you can start any kernel with it, not just Linux.
+
+	  The name comes from the similarity 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.  As of this writing the exact hardware
+	  interface is strongly in flux, so no good recommendation can be
+	  made.
+
 menu "Platform setup"
 
 source arch/m68k/Kconfig.cpu
arch/m68k/include/asm/kexec.h new file +29 -0
new file mode 100644
index 000000000000..3df97abac147
@@ -0,0 +1,29 @@
+#ifndef _ASM_M68K_KEXEC_H
+#define _ASM_M68K_KEXEC_H
+
+#ifdef CONFIG_KEXEC
+
+/* 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 (-1UL)
+
+#define KEXEC_CONTROL_PAGE_SIZE	4096
+
+#define KEXEC_ARCH KEXEC_ARCH_68K
+
+#ifndef __ASSEMBLY__
+
+static inline void crash_setup_regs(struct pt_regs *newregs,
+				    struct pt_regs *oldregs)
+{
+	/* Dummy implementation for now */
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_KEXEC */
+
+#endif /* _ASM_M68K_KEXEC_H */
arch/m68k/kernel/Makefile +2 -0
index 655347d80780..7ee5f00a9abb 100644
@@ -22,3 +22,5 @@ obj-$(CONFIG_PCI) += pcibios.o
 
 obj-$(CONFIG_HAS_DMA)	+= dma.o
 
+obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
+
arch/m68k/kernel/asm-offsets.c +3 -0
index 8b7b22846366..3a386341aa6e 100644
@@ -98,6 +98,9 @@ int main(void)
 	DEFINE(CIABBASE, &ciab);
 	DEFINE(C_PRA, offsetof(struct CIA, pra));
 	DEFINE(ZTWOBASE, zTwoBase);
+
+	/* enum m68k_fixup_type */
+	DEFINE(M68K_FIXUP_MEMOFFSET, m68k_fixup_memoffset);
 #endif
 
 	return 0;
arch/m68k/kernel/machine_kexec.c new file +58 -0

58 lines not on this page · raw message

arch/m68k/kernel/relocate_kernel.S new file +155 -0

155 lines not on this page · raw message

include/uapi/linux/kexec.h +1 -0
index 104838f65bc1..d6629d49a243 100644
@@ -18,6 +18,7 @@
  */
 #define KEXEC_ARCH_DEFAULT ( 0 << 16)
 #define KEXEC_ARCH_386     ( 3 << 16)
+#define KEXEC_ARCH_68K     ( 4 << 16)
 #define KEXEC_ARCH_X86_64  (62 << 16)
 #define KEXEC_ARCH_PPC     (20 << 16)
 #define KEXEC_ARCH_PPC64   (21 << 16)
Signature · 7 lines
1.7.9.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author maintainer
#11 lore raw

PATCH 3/3 m68k: Add support to export bootinfo in procfs

In reply to Geert Uytterhoeven

Add optional support to export the bootinfo used to boot the kernel in a "bootinfo" file in procfs. This is useful with kexec.

This is based on the similar feature for ATAGS on ARM.

---
 arch/m68k/Kconfig                |    7 ++++
 arch/m68k/include/asm/bootinfo.h |    6 +++
 arch/m68k/kernel/Makefile        |    1 +
 arch/m68k/kernel/bootinfo_proc.c |   78 ++++++++++++++++++++++++++++++++++++++
 arch/m68k/kernel/setup_mm.c      |    2 +
 5 files changed, 94 insertions(+)
 create mode 100644 arch/m68k/kernel/bootinfo_proc.c
arch/m68k/Kconfig +7 -0
index 5d65c39bfc69..17044432f4f4 100644
@@ -103,6 +103,13 @@ config KEXEC
 	  interface is strongly in flux, so no good recommendation can be
 	  made.
 
+config BOOTINFO_PROC
+	bool "Export bootinfo in procfs"
+	depends on KEXEC && M68KCLASSIC
+	help
+	  Say Y to export the bootinfo used to boot the kernel in a
+	  "bootinfo" file in procfs.  This is useful with kexec.
+
 menu "Platform setup"
 
 source arch/m68k/Kconfig.cpu
arch/m68k/include/asm/bootinfo.h +6 -0
index fd5c26707013..007c95759e6b 100644
@@ -46,6 +46,12 @@ struct bi_record {
     unsigned long data[0];		/* data */
 };
 
+#ifdef CONFIG_BOOTINFO_PROC
+extern void save_bootinfo(const struct bi_record *bi);
+#else
+static inline void save_bootinfo(const struct bi_record *bi) {}
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 
arch/m68k/kernel/Makefile +1 -0
index 7ee5f00a9abb..2d5d9be16273 100644
@@ -23,4 +23,5 @@ obj-$(CONFIG_PCI) += pcibios.o
 obj-$(CONFIG_HAS_DMA)	+= dma.o
 
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
+obj-$(CONFIG_BOOTINFO_PROC)	+= bootinfo_proc.o
 
arch/m68k/kernel/bootinfo_proc.c new file +78 -0

78 lines not on this page · raw message

arch/m68k/kernel/setup_mm.c +2 -0
index 1e3e2cbd455e..cb7b0c927869 100644
@@ -143,6 +143,8 @@ extern void paging_init(void);
 
 static void __init m68k_parse_bootinfo(const struct bi_record *record)
 {
+	save_bootinfo(record);
+
 	while (record->tag != BI_LAST) {
 		int unknown = 0;
 		const unsigned long *data = record->data;
Signature · 1 line
1.7.9.5
author maintainer
#12 lore raw

PATCH 3/3 m68k: Add support to export bootinfo in procfs

In reply to Geert Uytterhoeven

Add optional support to export the bootinfo used to boot the kernel in a "bootinfo" file in procfs. This is useful with kexec.

This is based on the similar feature for ATAGS on ARM.

---
 arch/m68k/Kconfig                |    7 ++++
 arch/m68k/include/asm/bootinfo.h |    6 +++
 arch/m68k/kernel/Makefile        |    1 +
 arch/m68k/kernel/bootinfo_proc.c |   78 ++++++++++++++++++++++++++++++++++++++
 arch/m68k/kernel/setup_mm.c      |    2 +
 5 files changed, 94 insertions(+)
 create mode 100644 arch/m68k/kernel/bootinfo_proc.c
arch/m68k/Kconfig +7 -0
index 5d65c39bfc69..17044432f4f4 100644
@@ -103,6 +103,13 @@ config KEXEC
 	  interface is strongly in flux, so no good recommendation can be
 	  made.
 
+config BOOTINFO_PROC
+	bool "Export bootinfo in procfs"
+	depends on KEXEC && M68KCLASSIC
+	help
+	  Say Y to export the bootinfo used to boot the kernel in a
+	  "bootinfo" file in procfs.  This is useful with kexec.
+
 menu "Platform setup"
 
 source arch/m68k/Kconfig.cpu
arch/m68k/include/asm/bootinfo.h +6 -0
index fd5c26707013..007c95759e6b 100644
@@ -46,6 +46,12 @@ struct bi_record {
     unsigned long data[0];		/* data */
 };
 
+#ifdef CONFIG_BOOTINFO_PROC
+extern void save_bootinfo(const struct bi_record *bi);
+#else
+static inline void save_bootinfo(const struct bi_record *bi) {}
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 
arch/m68k/kernel/Makefile +1 -0
index 7ee5f00a9abb..2d5d9be16273 100644
@@ -23,4 +23,5 @@ obj-$(CONFIG_PCI) += pcibios.o
 obj-$(CONFIG_HAS_DMA)	+= dma.o
 
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
+obj-$(CONFIG_BOOTINFO_PROC)	+= bootinfo_proc.o
 
arch/m68k/kernel/bootinfo_proc.c new file +78 -0

78 lines not on this page · raw message

arch/m68k/kernel/setup_mm.c +2 -0
index 1e3e2cbd455e..cb7b0c927869 100644
@@ -143,6 +143,8 @@ extern void paging_init(void);
 
 static void __init m68k_parse_bootinfo(const struct bi_record *record)
 {
+	save_bootinfo(record);
+
 	while (record->tag != BI_LAST) {
 		int unknown = 0;
 		const unsigned long *data = record->data;
Signature · 1 line
1.7.9.5