Skip to contentSkip to conversation

IA64 kexec

PATCH In review Zou Nan hai 5 participants 13 messages Nov 7, 2005 – Feb 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IA64 kexec

Here is my patches of kexec on IA64.

The kernel patch is against 2.6.14
The kexec-tools patch is against kexec-tools-1.101

I have tested it on a Tiger-4 and a ZX1 machine.

Please test and review it.

Thanks.
Zou Nan hai

kexec/arch/ia64/kexec-elf-ia64.c +51 -8
diff -Nraup a/kexec/arch/ia64/kexec-elf-ia64.c b/kexec/arch/ia64/kexec-elf-ia64.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2004 Silicon Graphics, Inc.
  *   Jesse Barnes <[email protected]>
  * Copyright (C) 2004 Khalid Aziz <[email protected]> Hewlett Packard Co
+ * Copyright (C) 2005 Zou Nan hai <[email protected]> Intel Corp
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,6 +35,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <limits.h>
 #include <elf.h>
 #include <boot/elf_boot.h>
 #include <ip_checksum.h>
@@ -74,23 +76,29 @@ void elf_ia64_usage(void)
 {
 	printf(
 		"    --command-line=STRING Set the kernel command line to STRING.\n"
-		"    --append=STRING       Set the kernel command line to STRING.\n");
+		"    --append=STRING       Set the kernel command line to STRING.\n"
+		"    --initrd=STRING       Set the kernel initrd to STRING.\n");
 }
 
 int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info)
 {
 	struct mem_ehdr ehdr;
-	const char *command_line;
-	int command_line_len;
-	unsigned long entry, max_addr;
+	const char *command_line, *ramdisk=0;
+	char *ramdisk_buf;
+	off_t ramdisk_size = 0;
+	unsigned long command_line_len;
+	unsigned long entry, max_addr, gp_value;
+	unsigned command_line_base, ramdisk_base;
 	int result;
 	int opt;
 #define OPT_APPEND	(OPT_ARCH_MAX+0)
+#define OPT_RAMDISK	(OPT_ARCH_MAX+1)
 	static const struct option options[] = {
 		KEXEC_ARCH_OPTIONS
 		{"command-line", 1, 0, OPT_APPEND},
 		{"append",       1, 0, OPT_APPEND},
+		{"initrd",       1, 0, OPT_RAMDISK},
 		{0, 0, 0, 0},
 	};
 
@@ -110,11 +118,14 @@ int elf_ia64_load(int argc, char **argv,
 		case OPT_APPEND:
 			command_line = optarg;
 			break;
+		case OPT_RAMDISK:
+			ramdisk = optarg;
+			break;
 		}
 	}
 	command_line_len = 0;
 	if (command_line) {
-		command_line_len = strlen(command_line) + 1;
+		command_line_len = strlen(command_line) + 16;
 	}
 
 	/* Parse the Elf file */
@@ -129,13 +140,45 @@ int elf_ia64_load(int argc, char **argv,
 
 	/* Load the Elf data */
 	result = elf_exec_load(&ehdr, info);
-	free_elf_info(&ehdr);
 	if (result < 0) {
 		fprintf(stderr, "ELF load failed\n");
 		return result;
 	}
+
+
+	/* Load the setup code */
+	elf_rel_build_load(info, &info->rhdr, purgatory, purgatory_size,
+			0x80000, ULONG_MAX, 1);
+
+	if (command_line_len) {
+		char *cmdline = xmalloc(command_line_len);
+		strcpy(cmdline, command_line);
+		command_line_len = (command_line_len + 15)&(~15);
+		elf_rel_set_symbol(&info->rhdr, "__command_line_len",
+				&command_line_len, sizeof(long));
+		command_line_base = add_buffer(info, cmdline,
+					command_line_len, command_line_len,
+					16, 0, max_addr, 1);
+		elf_rel_set_symbol(&info->rhdr, "__command_line",
+				&command_line_base, sizeof(long));
+	}
 	
-	/* For now we don't have arguments to pass :( */
-	info->entry = (void *)entry;
+	if (ramdisk) {
+		ramdisk_buf = slurp_file(ramdisk, &ramdisk_size);
+		ramdisk_base = add_buffer(info, ramdisk_buf, ramdisk_size,
+				ramdisk_size,
+				getpagesize(), 0, max_addr, 1);
+		elf_rel_set_symbol(&info->rhdr, "__ramdisk_base",
+				&ramdisk_base, sizeof(long));
+		elf_rel_set_symbol(&info->rhdr, "__ramdisk_size",
+				&ramdisk_size, sizeof(long));
+	}
+
+	gp_value = info->rhdr.rel_addr + 0x200000;
+        elf_rel_set_symbol(&info->rhdr, "__gp_value", &gp_value,
+                        sizeof(gp_value));
+
+	elf_rel_set_symbol(&info->rhdr, "__kernel_entry", &entry, sizeof(entry));
+	free_elf_info(&ehdr);
 	return 0;
 }
kexec/arch/ia64/kexec-elf-rel-ia64.c +91 -5

126 lines not on this page · raw message

kexec/arch/ia64/kexec-ia64.c +8 -32
diff -Nraup a/kexec/arch/ia64/kexec-ia64.c b/kexec/arch/ia64/kexec-ia64.c
@@ -27,6 +27,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <getopt.h>
+#include <sched.h>
 #include <sys/utsname.h>
 #include "../../kexec.h"
 #include "../../kexec-syscall.h"
@@ -56,7 +57,7 @@ int get_memory_ranges(struct memory_rang
 	 */
 	fprintf(stderr, "Warning assuming memory at 0-64MB is present\n");
 	memory_ranges = 0;
-	memory_range[memory_ranges].start = 0x00010000;
+	memory_range[memory_ranges].start = 0x00100000;
 	memory_range[memory_ranges].end   = 0x10000000;
 	memory_range[memory_ranges].type  = RANGE_RAM;
 	memory_ranges++;
@@ -76,9 +77,6 @@ void arch_usage(void)
 {
 }
 
-static struct {
-} arch_options = {
-};
 int arch_process_options(int argc, char **argv)
 {
 	static const struct option options[] = {
@@ -87,8 +85,11 @@ int arch_process_options(int argc, char 
 	};
 	static const char short_options[] = KEXEC_ARCH_OPT_STR;
 	int opt;
-	unsigned long value;
-	char *end;
+	/* execute from BP */
+        cpu_set_t affinity;
+	CPU_ZERO(&affinity);
+	CPU_SET(0, &affinity);
+        sched_setaffinity(0, sizeof(affinity), &affinity);
 
 	opterr = 0; /* Don't complain about unrecognized options here */
 	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
@@ -115,32 +116,7 @@ int arch_compat_trampoline(struct kexec_
 	}
 	if (strcmp(utsname.machine, "ia64") == 0)
 	{
-		*flags |= KEXEC_ARCH_X86_64;
-	}
-	else {
-		fprintf(stderr, "Unsupported machine type: %s\n",
-			utsname.machine);
-		return -1;
-	}
-	return 0;
-}
-
-int arch_compat_trampoline(struct kexec_info *info, unsigned long *flags)
-{
-	int result;
-	struct utsname utsname;
-	result = uname(&utsname);
-	if (result < 0) {
-		fprintf(stderr, "uname failed: %s\n",
-			strerror(errno));
-		return -1;
-	}
-	if (strcmp(utsname.machine, "ia64") == 0)
-	{
-		/* For compatibility with older patches 
-		 * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_IA64 here.
-		 */
-		*flags |= KEXEC_ARCH_DEFAULT;
+		*flags |= KEXEC_ARCH_IA_64;
 	}
 	else {
 		fprintf(stderr, "Unsupported machine type: %s\n",
kexec/kexec.c +1 -1
diff -Nraup a/kexec/kexec.c b/kexec/kexec.c
@@ -187,7 +187,7 @@ unsigned long locate_hole(struct kexec_i
 	}
 
 	/* Compute the free memory ranges */
-	max_mem_ranges = memory_ranges + (info->nr_segments -1);
+	max_mem_ranges = memory_ranges + info->nr_segments;
 	mem_range = malloc(max_mem_ranges *sizeof(struct memory_range));
 	mem_ranges = 0;
 		
purgatory/arch/ia64/entry.S +85 -0

85 lines not on this page · raw message

purgatory/arch/ia64/Makefile +2 -2
diff -Nraup a/purgatory/arch/ia64/Makefile b/purgatory/arch/ia64/Makefile
@@ -1,8 +1,8 @@
 #
 # Purgatory ia64
 #
-
-PURGATORY_S_SRCS+=
+PCFLAGS		+= -ffixed-r28
+PURGATORY_S_SRCS+= purgatory/arch/ia64/entry.S
 PURGATORY_C_SRCS+= purgatory/arch/ia64/purgatory-ia64.c
 PURGATORY_C_SRCS+= purgatory/arch/ia64/console-ia64.c
 PURGATORY_C_SRCS+=
purgatory/arch/ia64/purgatory-ia64.c +106 -0

113 lines not on this page · raw message

arch/ia64/Kconfig +11 -0
diff -Nraup a/arch/ia64/Kconfig b/arch/ia64/Kconfig
@@ -334,6 +334,17 @@ config IA64_PALINFO
 	  To use this option, you have to ensure that the "/proc file system
 	  support" (CONFIG_PROC_FS) is enabled, too.
 
+config KEXEC
+       bool "kexec system call (EXPERIMENTAL)"
+       depends on EXPERIMENTAL && (!SMP || HOTPLUG_CPU)
+       help
+         kexec is a system call that implements the ability to shutdown your
+         current kernel, and to start another kernel.  It is like a reboot
+         but it is indepedent of the system firmware.   And like a reboot
+         you can start any kernel with it, not just Linux.
+
+         The name comes from the similiarity to the exec system call.
+
 source "drivers/firmware/Kconfig"
 
 source "fs/Kconfig.binfmt"
arch/ia64/kernel/crash.c +22 -0
diff -Nraup a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c
@@ -0,0 +1,22 @@
+/*
+ *  arch/ia64/kernel/crash.c
+ *
+ *  Copyright (C) 2005 Intel Corp
+ *  Zou Nan hai <[email protected]>
+ */
+#include <linux/smp.h>
+#include <linux/kexec.h>
+
+note_buf_t crash_notes[NR_CPUS];
+void machine_crash_shutdown(void)
+{
+       /* This function is only called after the system
+        * has paniced or is otherwise in a critical state.
+        * The minimum amount of code to allow a kexec'd kernel
+        * to run successfully needs to happen here.
+        *
+        * In practice this means shooting down the other cpus in
+        * an SMP system.
+        */
+}
+
arch/ia64/kernel/entry.S +1 -1
diff -Nraup a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
@@ -1588,7 +1588,7 @@ sys_call_table:
 	data8 sys_mq_timedreceive		// 1265
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
-	data8 sys_ni_syscall			// reserved for kexec_load
+	data8 sys_kexec_load
 	data8 sys_ni_syscall			// reserved for vserver
 	data8 sys_waitid			// 1270
 	data8 sys_add_key
arch/ia64/kernel/machine_kexec.c +67 -0

67 lines not on this page · raw message

arch/ia64/kernel/Makefile +1 -0
diff -Nraup a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)	+= mca_recovery.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o jprobes.o
+obj-$(CONFIG_KEXEC)             += machine_kexec.o crash.o relocate_kernel.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)	+= uncached.o
 mca_recovery-y			+= mca_drv.o mca_drv_asm.o
 
arch/ia64/kernel/relocate_kernel.S +187 -0

187 lines not on this page · raw message

include/asm-ia64/kexec.h +29 -0
diff -Nraup a/include/asm-ia64/kexec.h b/include/asm-ia64/kexec.h
@@ -0,0 +1,29 @@
+#ifndef _IA64_KEXEC_H
+#define _IA64_KEXEC_H
+
+/*
+ * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
+ * I.e. Maximum page that is mapped directly into kernel memory,
+ * and kmap is not required.
+ *
+ * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
+ * calculation for the amount of memory directly mappable into the
+ * kernel memory space.
+ */
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
+
+#define KEXEC_CONTROL_CODE_SIZE        (1UL << 14)
+
+/* The native architecture */
+#define KEXEC_ARCH KEXEC_ARCH_IA_64
+
+#define MAX_NOTE_BYTES 1024
+typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+extern note_buf_t crash_notes[];
+#endif
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Zou Nan hai
Sent: 2005Äê11ÔÂ8ÈÕ 7:28
To: [email protected]
Cc: [email protected]
Subject: [Patch]IA64 kexec

Here is my patches of kexec on IA64.

The kernel patch is against 2.6.14
The kexec-tools patch is against kexec-tools-1.101

Quoted 7 lines

I have tested it on a Tiger-4 and a ZX1 machine.

Please test and review it.

Thanks.
Zou Nan hai

To try the patches,
You may download kexec-tools
From http://www.xmission.com/~ebiederm/files/kexec/kexec-tools-1.101.tar.gz
Then patch the kexec-tools and install it.
Run
kexec -l vmlinuz --initrd=initrd --append="root=...";
kexec -e to see the second kernel booting.

Thanks
Zou Nan hai

#2 lore raw
In reply to Zou Nan hai
Quoted 4 lines · On 2005-11-07 at 23:27:49 Zou Nan Hai wrote:

Here is my patches of kexec on IA64.

The kernel patch is against 2.6.14
The kexec-tools patch is against kexec-tools-1.101

Am i right in assuming that this is still the latest version of kexec for ia64? If not, could someone point me to a newer one.

Quoted 1 line

I have tested it on a Tiger-4 and a ZX1 machine.

Is it possible to get the config that you used on Tiger-4?

Quoted 1 line

Please test and review it.

Signature · 1 line
Horms
#3 lore raw
In reply to Zou Nan hai
Quoted 6 lines · Horms
Quoted 4 lines · On 2005-11-07 at 23:27:49 Zou Nan Hai wrote:

Here is my patches of kexec on IA64.

The kernel patch is against 2.6.14
The kexec-tools patch is against kexec-tools-1.101

Quoted 8 lines

Am i right in assuming that this is still the latest version of kexec for ia64? If not, could someone point me to a newer one.

Quoted 1 line

I have tested it on a Tiger-4 and a ZX1 machine.

Is it possible to get the config that you used on Tiger-4?

Quoted 1 line

Please test and review it.

Hi,

Here is an as-yet untested forward port of the kexec-ia64 patch to today's Linus git tree (~2.6.16-rc3).

The only real change to the 2.6.14 incarnation was to remove the definitions of note_buf_t and note_buf_t as these are now in the generic code. And to change the declaration of machine_crash_shutdown.

machine_crash_shutdown still does nothing. As the original i386 version did. However I notice that code has been enhanced to:

* Shut down the other CPU's using (NMI)
* Snapshot the registers
* Shut down APICS

I haven't looked into what other features have been added to other arches kexec. Nor if the features above are applicable - seems that they probably are, exept that ia64 doesn't have NMI (right?) so the cpu shutdown would need to be done another way.

Signature · 1 line
Horms
arch/ia64/Kconfig +11 -0
index 845cd09..a33c092 100644
@@ -376,6 +376,17 @@ config IA64_PALINFO
 config SGI_SN
 	def_bool y if (IA64_SGI_SN2 || IA64_GENERIC)
 
+config KEXEC
+       bool "kexec system call (EXPERIMENTAL)"
+       depends on EXPERIMENTAL && (!SMP || HOTPLUG_CPU)
+       help
+         kexec is a system call that implements the ability to shutdown your
+         current kernel, and to start another kernel.  It is like a reboot
+         but it is indepedent of the system firmware.   And like a reboot
+         you can start any kernel with it, not just Linux.
+
+         The name comes from the similiarity to the exec system call.
+
 source "drivers/firmware/Kconfig"
 
 source "fs/Kconfig.binfmt"
arch/ia64/kernel/Makefile +1 -0
index 09a0dbc..d2e15df 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)	+= mca_recovery.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o jprobes.o
+obj-$(CONFIG_KEXEC)             += machine_kexec.o crash.o relocate_kernel.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)	+= uncached.o
 mca_recovery-y			+= mca_drv.o mca_drv_asm.o
 
arch/ia64/kernel/crash.c new file +21 -0
new file mode 100644
index 0000000..f8276d0
@@ -0,0 +1,21 @@
+/*
+ *  arch/ia64/kernel/crash.c
+ *
+ *  Copyright (C) 2005 Intel Corp
+ *  Zou Nan hai <[email protected]>
+ */
+#include <linux/smp.h>
+#include <linux/kexec.h>
+
+void machine_crash_shutdown(struct pt_regs *regs)
+{
+       /* This function is only called after the system
+        * has paniced or is otherwise in a critical state.
+        * The minimum amount of code to allow a kexec'd kernel
+        * to run successfully needs to happen here.
+        *
+        * In practice this means shooting down the other cpus in
+        * an SMP system.
+        */
+}
+
arch/ia64/kernel/entry.S +1 -1
index 27b222c..c2fce91 100644
@@ -1588,7 +1588,7 @@ sys_call_table:
 	data8 sys_mq_timedreceive		// 1265
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
-	data8 sys_ni_syscall			// reserved for kexec_load
+	data8 sys_kexec_load
 	data8 sys_ni_syscall			// reserved for vserver
 	data8 sys_waitid			// 1270
 	data8 sys_add_key
arch/ia64/kernel/machine_kexec.c new file +67 -0

67 lines not on this page · raw message

arch/ia64/kernel/relocate_kernel.S new file +187 -0

187 lines not on this page · raw message

include/asm-ia64/kexec.h new file +27 -0
new file mode 100644
index 0000000..782bcbb
@@ -0,0 +1,27 @@
+#ifndef _IA64_KEXEC_H
+#define _IA64_KEXEC_H
+
+/*
+ * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
+ * I.e. Maximum page that is mapped directly into kernel memory,
+ * and kmap is not required.
+ *
+ * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
+ * calculation for the amount of memory directly mappable into the
+ * kernel memory space.
+ */
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
+
+#define KEXEC_CONTROL_CODE_SIZE        (1UL << 14)
+
+/* The native architecture */
+#define KEXEC_ARCH KEXEC_ARCH_IA_64
+
+#define MAX_NOTE_BYTES 1024
+#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Zou Nan hai
Quoted 2 lines

Here is an as-yet untested forward port of the kexec-ia64 patch to today's Linus git tree (~2.6.16-rc3).

Thanks for taking a look at this ... I'm glad to see that there is still interest in kexec.

Khalid Aziz at HP is woking on merging the good parts of that patch from Nan Hai with the kexec patch that he had produced earlier). We should see the results of that merge next week, & I hope to see lots more commentary and testing this time around.

Quoted 4 lines

I haven't looked into what other features have been added to other arches kexec. Nor if the features above are applicable - seems that they probably are, exept that ia64 doesn't have NMI (right?) so the cpu shutdown would need to be done another way.

Nan Hai makes use of HOTPLUG_CPU to offline the other cpus ... which in many ways is a very elegant solution (as it puts the cpus neatly back into SAL ready for the new OS to bring it back online again). But there are a couple of downsides:
1) Requires CONFIG_HOTPLUG_CPU (perhaps this isn't really a big issue)
2) May run into trouble for kdump case where we'd like to rely on less known state/code to get a good dump when the Linux kernel is known to be in some unstable state.

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

-Tony

#5 lore raw
In reply to Zou Nan hai
Quoted 4 lines · "Luck, Tony" (on Mon, 13 Feb 2006 09:26:58 -0800) wrote:

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

Which raises a small problem. As of about 2.6.15, INIT is a recoverable event. INIT _must_ be recoverable, because it can be sent when an MCA occurs and one or more cpus was running with interrupts disabled. For example, when the cpu that takes the MCA owns a disabled spinlock that other cpus are waiting on. If INIT is not recoverable then some MCAs that could be recovered also become unrecoverable, at random.

Since INIT is recoverable, pressing NMI gives you a stack trace for each cpu, then the system resumes. This allows a user to see if the system is making progress, albeit slowly, or if it really is stuck. The downside of a recoverable INIT is that you cannot use it to take a dump, or at least not the first time that NMI is issued. Unfortunately there is no way to distinguish between an NMI where the user wants to see what the system is doing and an NMI to take a dump. Nobody has implemented the "Read Programmer's Mind" instruction yet.

#6 lore raw
In reply to Zou Nan hai
Quoted 5 lines · Tony
Quoted 2 lines

Here is an as-yet untested forward port of the kexec-ia64 patch to today's Linus git tree (~2.6.16-rc3).

Thanks for taking a look at this ... I'm glad to see that there is still interest in kexec.

Likewise.

In case anyone cares, my interest in kexec is twofold. Firstly the ia64 box I have takes a really long time to reboot, and it would be nice if kexec could trim that down to speed up my crash-and-burn development cycle.

But more importantly, I'm interested in using it for kdump functionality, hopefully in conjunction with Xen - though as you can see, I haven't got that far yet.

Quoted 4 lines

Khalid Aziz at HP is woking on merging the good parts of that patch from Nan Hai with the kexec patch that he had produced earlier). We should see the results of that merge next week, & I hope to see lots more commentary and testing this time around.

Awsome, I look forward to seeing it. Would I be right in thinking that it will show up on this list?

Quoted 10 lines
Quoted 4 lines

I haven't looked into what other features have been added to other arches kexec. Nor if the features above are applicable - seems that they probably are, exept that ia64 doesn't have NMI (right?) so the cpu shutdown would need to be done another way.

Nan Hai makes use of HOTPLUG_CPU to offline the other cpus ... which in many ways is a very elegant solution (as it puts the cpus neatly back into SAL ready for the new OS to bring it back online again). But there are a couple of downsides:
1) Requires CONFIG_HOTPLUG_CPU (perhaps this isn't really a big issue)

That isn't a particular concern to me.

Quoted 10 lines

2) May run into trouble for kdump case where we'd like to rely on less known state/code to get a good dump when the Linux kernel is known to be in some unstable state.

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

-Tony

Quoted 14 lines · Keith Owens
Quoted 4 lines · "Luck, Tony" (on Mon, 13 Feb 2006 09:26:58 -0800) wrote:

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

Which raises a small problem. As of about 2.6.15, INIT is a recoverable event. INIT _must_ be recoverable, because it can be sent when an MCA occurs and one or more cpus was running with interrupts disabled. For example, when the cpu that takes the MCA owns a disabled spinlock that other cpus are waiting on. If INIT is not recoverable then some MCAs that could be recovered also become unrecoverable, at random.

Quoted 8 lines

Since INIT is recoverable, pressing NMI gives you a stack trace for each cpu, then the system resumes. This allows a user to see if the system is making progress, albeit slowly, or if it really is stuck. The downside of a recoverable INIT is that you cannot use it to take a dump, or at least not the first time that NMI is issued. Unfortunately there is no way to distinguish between an NMI where the user wants to see what the system is doing and an NMI to take a dump. Nobody has implemented the "Read Programmer's Mind" instruction yet.

I sense pain. Looking over the code - very naievely - would it be possible to register an alternate INIT handler when kexecing.

What I'm getting at is ia64_os_init_dispatch_monarch and ia64_os_init_dispatch_slave are basically the same, but r19 is set so the code knows which variant is running for the core that cares. I wonder if an aditional bit in r19 could be used by alternate handlers that are registered when kexec wants to shut down the cpus.

Off course, this assume that reregistering handlers is possible, which is where the "naieve" bit comes in.

Signature · 1 line
Horms
#7 lore raw
In reply to Zou Nan hai
Quoted 2 lines · Tony
Quoted 2 lines

Here is an as-yet untested forward port of the kexec-ia64 patch to today's Linus git tree (~2.6.16-rc3).

I relaised that yesterday's patch failed to build
(I swear I tested that) because crash_setup_regs() is missing. This revised patch adds a dummy one (as per the current s390 code).

Signature · 1 line
Horms
arch/ia64/Kconfig +11 -0
index 845cd09..a33c092 100644
@@ -376,6 +376,17 @@ config IA64_PALINFO
 config SGI_SN
 	def_bool y if (IA64_SGI_SN2 || IA64_GENERIC)
 
+config KEXEC
+       bool "kexec system call (EXPERIMENTAL)"
+       depends on EXPERIMENTAL && (!SMP || HOTPLUG_CPU)
+       help
+         kexec is a system call that implements the ability to shutdown your
+         current kernel, and to start another kernel.  It is like a reboot
+         but it is indepedent of the system firmware.   And like a reboot
+         you can start any kernel with it, not just Linux.
+
+         The name comes from the similiarity to the exec system call.
+
 source "drivers/firmware/Kconfig"
 
 source "fs/Kconfig.binfmt"
arch/ia64/kernel/Makefile +1 -0
index 09a0dbc..d2e15df 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)	+= mca_recovery.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o jprobes.o
+obj-$(CONFIG_KEXEC)             += machine_kexec.o crash.o relocate_kernel.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)	+= uncached.o
 mca_recovery-y			+= mca_drv.o mca_drv_asm.o
 
arch/ia64/kernel/crash.c new file +21 -0
new file mode 100644
index 0000000..f8276d0
@@ -0,0 +1,21 @@
+/*
+ *  arch/ia64/kernel/crash.c
+ *
+ *  Copyright (C) 2005 Intel Corp
+ *  Zou Nan hai <[email protected]>
+ */
+#include <linux/smp.h>
+#include <linux/kexec.h>
+
+void machine_crash_shutdown(struct pt_regs *regs)
+{
+       /* This function is only called after the system
+        * has paniced or is otherwise in a critical state.
+        * The minimum amount of code to allow a kexec'd kernel
+        * to run successfully needs to happen here.
+        *
+        * In practice this means shooting down the other cpus in
+        * an SMP system.
+        */
+}
+
arch/ia64/kernel/entry.S +1 -1
index 27b222c..c2fce91 100644
@@ -1588,7 +1588,7 @@ sys_call_table:
 	data8 sys_mq_timedreceive		// 1265
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
-	data8 sys_ni_syscall			// reserved for kexec_load
+	data8 sys_kexec_load
 	data8 sys_ni_syscall			// reserved for vserver
 	data8 sys_waitid			// 1270
 	data8 sys_add_key
arch/ia64/kernel/machine_kexec.c new file +67 -0

67 lines not on this page · raw message

arch/ia64/kernel/relocate_kernel.S new file +187 -0

187 lines not on this page · raw message

include/asm-ia64/kexec.h new file +32 -0
new file mode 100644
index 0000000..fa0bc22
@@ -0,0 +1,32 @@
+#ifndef _IA64_KEXEC_H
+#define _IA64_KEXEC_H
+
+/*
+ * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
+ * I.e. Maximum page that is mapped directly into kernel memory,
+ * and kmap is not required.
+ *
+ * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
+ * calculation for the amount of memory directly mappable into the
+ * kernel memory space.
+ */
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
+
+#define KEXEC_CONTROL_CODE_SIZE        (1UL << 14)
+
+/* The native architecture */
+#define KEXEC_ARCH KEXEC_ARCH_IA_64
+
+#define MAX_NOTE_BYTES 1024
+
+/* Provide a dummy definition to avoid build failures. */
+static inline void crash_setup_regs(struct pt_regs *newregs,
+				    struct pt_regs *oldregs) { }
+
+#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
In reply to Zou Nan hai
Quoted 18 lines · Horms (on Tue, 14 Feb 2006 13:06:44 +0900) wrote:
Quoted 8 lines · Keith Owens

Which raises a small problem. As of about 2.6.15, INIT is a recoverable event. INIT _must_ be recoverable, because it can be sent when an MCA occurs and one or more cpus was running with interrupts disabled. For example, when the cpu that takes the MCA owns a disabled spinlock that other cpus are waiting on. If INIT is not recoverable then some MCAs that could be recovered also become unrecoverable, at random.

Quoted 8 lines

Since INIT is recoverable, pressing NMI gives you a stack trace for each cpu, then the system resumes. This allows a user to see if the system is making progress, albeit slowly, or if it really is stuck. The downside of a recoverable INIT is that you cannot use it to take a dump, or at least not the first time that NMI is issued. Unfortunately there is no way to distinguish between an NMI where the user wants to see what the system is doing and an NMI to take a dump. Nobody has implemented the "Read Programmer's Mind" instruction yet.

Quoted 2 lines

I sense pain. Looking over the code - very naievely - would it be possible to register an alternate INIT handler when kexecing.

Not a good idea, the INIT handler code is very closely tied to the SAL/OS interface. But what kexec can do is to register itself on the notify_die() chain, it will get called for multiple events including DIE_INIT_SLAVE_ENTER, DIE_INIT_SLAVE_PROCESS, DIE_INIT_SLAVE_LEAVE, DIE_INIT_MONARCH_ENTER, DIE_INIT_MONARCH_PROCESS and DIE_INIT_MONARCH_LEAVE. That chain and the associated events is meant for debuggers, crash dumpers and assorted RAS tools. See also the DIE_MCA_* events on the same chain.

#9 lore raw
In reply to Zou Nan hai
Quoted 18 lines · Horms
Quoted 5 lines · Tony
Quoted 2 lines

Here is an as-yet untested forward port of the kexec-ia64 patch to today's Linus git tree (~2.6.16-rc3).

Thanks for taking a look at this ... I'm glad to see that there is still interest in kexec.

Likewise.

In case anyone cares, my interest in kexec is twofold. Firstly the ia64 box I have takes a really long time to reboot, and it would be nice if kexec could trim that down to speed up my crash-and-burn development cycle.

But more importantly, I'm interested in using it for kdump functionality, hopefully in conjunction with Xen - though as you can see, I haven't got that far yet.

Quoted 7 lines
Quoted 4 lines

Khalid Aziz at HP is woking on merging the good parts of that patch from Nan Hai with the kexec patch that he had produced earlier). We should see the results of that merge next week, & I hope to see lots more commentary and testing this time around.

Awsome, I look forward to seeing it. Would I be right in thinking that it will show up on this list?

Yes, I will release my patch to this list later next week.

--
Khalid

Quoted 62 lines
Quoted 11 lines
Quoted 5 lines

I haven't looked into what other features have been added to other arches kexec. Nor if the features above are applicable - seems that they probably are, exept that ia64 doesn't have NMI (right?) so the cpu shutdown would need to be done another way.

Nan Hai makes use of HOTPLUG_CPU to offline the other cpus ... which in many ways is a very elegant solution (as it puts the cpus neatly back into SAL ready for the new OS to bring it back online again). But there are a couple of downsides:
1) Requires CONFIG_HOTPLUG_CPU (perhaps this isn't really a big issue)

That isn't a particular concern to me.

Quoted 10 lines

2) May run into trouble for kdump case where we'd like to rely on less known state/code to get a good dump when the Linux kernel is known to be in some unstable state.

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

-Tony

Quoted 14 lines · Keith Owens
Quoted 4 lines · "Luck, Tony" (on Mon, 13 Feb 2006 09:26:58 -0800) wrote:

The ia64 equivalent of NMI (large brick through the window) is INIT. Some systems have a button on the front panel to generate INIT, or have a maintenance processor that can send INIT. So a good kdump solution should eventually make use of INIT.

Which raises a small problem. As of about 2.6.15, INIT is a recoverable event. INIT _must_ be recoverable, because it can be sent when an MCA occurs and one or more cpus was running with interrupts disabled. For example, when the cpu that takes the MCA owns a disabled spinlock that other cpus are waiting on. If INIT is not recoverable then some MCAs that could be recovered also become unrecoverable, at random.

Quoted 8 lines

Since INIT is recoverable, pressing NMI gives you a stack trace for each cpu, then the system resumes. This allows a user to see if the system is making progress, albeit slowly, or if it really is stuck. The downside of a recoverable INIT is that you cannot use it to take a dump, or at least not the first time that NMI is issued. Unfortunately there is no way to distinguish between an NMI where the user wants to see what the system is doing and an NMI to take a dump. Nobody has implemented the "Read Programmer's Mind" instruction yet.

I sense pain. Looking over the code - very naievely - would it be possible to register an alternate INIT handler when kexecing.

What I'm getting at is ia64_os_init_dispatch_monarch and ia64_os_init_dispatch_slave are basically the same, but r19 is set so the code knows which variant is running for the core that cares. I wonder if an aditional bit in r19 could be used by alternate handlers that are registered when kexec wants to shut down the cpus.

Off course, this assume that reregistering handlers is possible, which is where the "naieve" bit comes in.

Signature · 7 lines
==================================
Khalid Aziz                       Open Source and Linux Organization
(970)898-9214                                        Hewlett-Packard
[email protected]                                  Fort Collins, CO

"The Linux kernel is subject to relentless development" 
                                - Alessandro Rubini
#10 lore raw
In reply to Zou Nan hai
Quoted 5 lines · Keith Owens
Quoted 3 lines · Horms (on Tue, 14 Feb 2006 13:06:44 +0900) wrote:

I sense pain. Looking over the code - very naievely - would it be possible to register an alternate INIT handler when kexecing.

Quoted 8 lines

Not a good idea, the INIT handler code is very closely tied to the SAL/OS interface. But what kexec can do is to register itself on the notify_die() chain, it will get called for multiple events including DIE_INIT_SLAVE_ENTER, DIE_INIT_SLAVE_PROCESS, DIE_INIT_SLAVE_LEAVE, DIE_INIT_MONARCH_ENTER, DIE_INIT_MONARCH_PROCESS and DIE_INIT_MONARCH_LEAVE. That chain and the associated events is meant for debuggers, crash dumpers and assorted RAS tools. See also the DIE_MCA_* events on the same chain.

Thanks, that looks quite promising indeed. However, after poking round a bit more I'm a little confused about what the intent of using INIT is.

Is the idea to intercept an INIT, produced by the front panel, a maintenence processor, (or perhaps an internal error), and then start kexecing? Or is the idea for kexec to use INIT internally to halt the processors.

In the case of the latter, which is what I have been thinking of up to now, does anyone have pointers as to how kexec might produce an INIT? I've spend a bit of time hunting through Intel documentation to no avail, other than that perhaps the BMC could do the trick (via IPMI?).

Lastly, if INIT is being used to shut off the processors by kexec, is it reasonable to assume that an INIT will hit all processors, and thus the slave processors can halt themselves in the callback (using cpu_die()?). Or is it better to only watch for a monarch norifier, and have it kill off the slave CPUs somehow.

Signature · 1 line
Horms
#11 lore raw
In reply to Zou Nan hai
Quoted 11 lines · Horms (on Wed, 15 Feb 2006 11:10:57 +0900) wrote:
Quoted 2 lines · Keith Owens

But what kexec can do is to register itself on the notify_die() chain ...

Thanks, that looks quite promising indeed. However, after poking round a bit more I'm a little confused about what the intent of using INIT is.

Is the idea to intercept an INIT, produced by the front panel, a maintenence processor, (or perhaps an internal error), and then start kexecing? Or is the idea for kexec to use INIT internally to halt the processors.

kexec (or any other RAS tool) should avoid using INIT itself. The ia64 INIT handlers are coded on the assumption that INIT is sent to all cpus at the same time, or that INIT is issued as part of the MCA rendezvous. In either case, the code assumes that the entire system is first brought to a dead stop, with all cpus under MCA or INIT control, before processing with the RAS code. IOW, the user invokes INIT via a button or BMC command, all cpus stop, then you start the debug process.

But there is still the problem of working out what the user means when they send INIT. Do they want a debugger or kexec to run, followed by reboot? Or do they just want a stack trace followed by resumption of normal processing. Some people want one option, some want another, and they are mutually exclusive.

Quoted 3 lines

Lastly, if INIT is being used to shut off the processors by kexec, is it reasonable to assume that an INIT will hit all processors, and thus the slave processors can halt themselves in the callback (using cpu_die()?).

The combination of MCA and INIT will hit all processors. Both the MCA and INIT handlers call ia64_wait_for_slaves(), so the monarch event will not proceed until all slaves have been stopped, or we decide that they are never going to stop and proceed anyway. So kexec should run off the monarch notifier.

Have you read linux/Documentation/ia64/mca.txt?

#12 lore raw
In reply to Zou Nan hai
Quoted 13 lines · Keith Owens
Quoted 11 lines · Horms (on Wed, 15 Feb 2006 11:10:57 +0900) wrote:
Quoted 2 lines · Keith Owens

But what kexec can do is to register itself on the notify_die() chain ...

Thanks, that looks quite promising indeed. However, after poking round a bit more I'm a little confused about what the intent of using INIT is.

Is the idea to intercept an INIT, produced by the front panel, a maintenence processor, (or perhaps an internal error), and then start kexecing? Or is the idea for kexec to use INIT internally to halt the processors.

Quoted 7 lines

kexec (or any other RAS tool) should avoid using INIT itself. The ia64 INIT handlers are coded on the assumption that INIT is sent to all cpus at the same time, or that INIT is issued as part of the MCA rendezvous. In either case, the code assumes that the entire system is first brought to a dead stop, with all cpus under MCA or INIT control, before processing with the RAS code. IOW, the user invokes INIT via a button or BMC command, all cpus stop, then you start the debug process.

Understood. So the idea is that INIT would be a way of triggering kexec? That is in addition to it being triggerable from user-space (kexec -e) and being triggerable on panic (presumably not using INIT).

Quoted 5 lines

But there is still the problem of working out what the user means when they send INIT. Do they want a debugger or kexec to run, followed by reboot? Or do they just want a stack trace followed by resumption of normal processing. Some people want one option, some want another, and they are mutually exclusive.

If its just a user prefereance, then it seems like it would be easy enough to let them select the action to take on INIT, say through proc.

Or if the only two methods are debug, which is the existing behaviour, and kexec. Then perhaps when they register a kernel for kexecing on INIT. I think that would be consistent with the way that a kernel can be registered for kexecing on panic.

Quoted 11 lines
Quoted 3 lines

Lastly, if INIT is being used to shut off the processors by kexec, is it reasonable to assume that an INIT will hit all processors, and thus the slave processors can halt themselves in the callback (using cpu_die()?).

The combination of MCA and INIT will hit all processors. Both the MCA and INIT handlers call ia64_wait_for_slaves(), so the monarch event will not proceed until all slaves have been stopped, or we decide that they are never going to stop and proceed anyway. So kexec should run off the monarch notifier.

Have you read linux/Documentation/ia64/mca.txt?

Indeed I have. I know that it mentions having software workarounds for various INIT delivery indosyncracies, but I wasn't sure if that meant the callbacks have to worry about it. Thanks for clearing that up.

Signature · 1 line
Horms