[RFC] [PATCH 1/2] s390: SCSI dump kernel and userspace application

2007-02-21 Thread Michael Holzheu
Kernel part of the s390 SCSI dumper: zcore character device driver.

Acked-by: Martin Schwidefsky <[EMAIL PROTECTED]>
Signed-off-by: Michael Holzheu <[EMAIL PROTECTED]>

---
 Documentation/s390/zfcpdump.txt |   41 +
 arch/s390/Kconfig   |7 
 arch/s390/kernel/early.c|3 
 arch/s390/kernel/head64.S   |   43 +
 arch/s390/kernel/ipl.c  |   24 -
 arch/s390/kernel/setup.c|3 
 arch/s390/kernel/smp.c  |1 
 drivers/s390/char/Makefile  |2 
 drivers/s390/char/sclp.h|2 
 drivers/s390/char/sclp_sdias.c  |  248 +++
 drivers/s390/char/zcore.c   |  885 
 drivers/s390/cio/cio.c  |1 
 include/asm-s390/ipl.h  |  116 +
 include/asm-s390/processor.h|5 
 include/asm-s390/sclp.h |2 
 include/asm-s390/setup.h|   75 ---
 16 files changed, 1360 insertions(+), 98 deletions(-)

Index: git-linux-2.6/Documentation/s390/zfcpdump.txt
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ git-linux-2.6/Documentation/s390/zfcpdump.txt   2007-02-21 
11:00:15.0 +0100
@@ -0,0 +1,41 @@
+s390 SCSI dump tool (zfcpdump)
+
+System z machines (z900 or higher) provide hardware support for creating system
+dumps on SCSI disks. The dump process is initiated by booting a dump tool, 
which
+has to create a dump of the current (probably crashed) Linux image. In order to
+not overwrite memory of the crashed Linux with data of the dump tool, the
+hardware saves some memory plus the register sets of the boot cpu before the
+dump tool is loaded. There exists an SCLP hardware interface to obtain the 
saved
+memory afterwards. Currently 32 MB are saved.
+
+This zfcpdump implementation consists of a small Linux dump kernel together 
with
+a userspace dump tool, which are loaded together into the saved memory region
+below 32 MB. zfcpdump is installed on a SCSI disk using zipl (as contained in 
the
+s390-tools package) to make the device bootable. The operator of a Linux system
+can then trigger a scsi dump by booting the SCSI disk, where zfcpdump resides 
on.
+
+The kernel part of zfcpdump is implemented as a character device driver named
+"zcore", which exports memory and registers of the crashed Linux in an s390
+standalone dump format. It can be used in the same way as e.g. /dev/mem. The
+dump format defines a 4K header followed by plain uncompressed memory. The
+register sets are stored in the prefix pages of the different cpus. To build an
+dump enabled kernel with the zcore driver, the kernel config option
+"S390_ZFCPDUMP" has to be set. When reading from /dev/zcore, the first part of
+memory, which has been saved by the hardware is read by the driver via the SCLP
+hardware interface. The second part is just copied from the non overwritten 
real
+memory.
+
+The userspace application of zfcpdump resides in an intitramfs. It reads from
+/dev/zcore and writes the system dump to a file on a SCSI disk.
+
+To build zfcpdump you have to do the following:
+- Use /arch/s390/zfcpdump/defconfig.zfcpdump as kernel configuration file, 
which
+  enables the S390_ZFCPDUMP option and sets all other required kernel options.
+- Issue "make zfcpdump" from the toplevel directory of the linux tree to
+  build the userspace application. Note, that the zfcpdump application has a
+  dependency on glibc and libz.
+- Issue "make image" to build the zfcpdump image with initramfs.
+
+The zfcpdump enabled kernel image must be copied to
+/usr/share/zfcpdump/zfcpdump.image, where the zipl tool is looking for the dump
+kernel, when preparing a SCSI dump disk.
Index: git-linux-2.6/arch/s390/Kconfig
===
--- git-linux-2.6.orig/arch/s390/Kconfig2007-02-21 10:22:03.0 
+0100
+++ git-linux-2.6/arch/s390/Kconfig 2007-02-21 11:00:15.0 +0100
@@ -512,6 +512,13 @@ config KEXEC
  current kernel, and to start another kernel.  It is like a reboot
  but is independent of hardware/microcode support.
 
+config S390_ZFCPDUMP
+   bool "zfcp dump kernel"
+   default n
+   help
+ Select this option if you want to build an zfcp dump enabled kernel.
+ Do NOT select this option for normal kernels!
+
 endmenu
 
 source "net/Kconfig"
Index: git-linux-2.6/arch/s390/kernel/early.c
===
--- git-linux-2.6.orig/arch/s390/kernel/early.c 2007-02-21 10:22:04.0 
+0100
+++ git-linux-2.6/arch/s390/kernel/early.c  2007-02-21 10:56:03.0 
+0100
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -129,7 +130,7 @@ static noinline __init void detect_machi
 {
struct cpuinfo_S390 *cpuinfo = _lowcore.cpu_data;
 
-   asm volatile("stidp %0" : "=m" (S390_lowcore.cpu_data.cpu_id));
+   

[RFC] [PATCH 1/2] s390: SCSI dump kernel and userspace application

2007-02-21 Thread Michael Holzheu
Kernel part of the s390 SCSI dumper: zcore character device driver.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Michael Holzheu [EMAIL PROTECTED]

---
 Documentation/s390/zfcpdump.txt |   41 +
 arch/s390/Kconfig   |7 
 arch/s390/kernel/early.c|3 
 arch/s390/kernel/head64.S   |   43 +
 arch/s390/kernel/ipl.c  |   24 -
 arch/s390/kernel/setup.c|3 
 arch/s390/kernel/smp.c  |1 
 drivers/s390/char/Makefile  |2 
 drivers/s390/char/sclp.h|2 
 drivers/s390/char/sclp_sdias.c  |  248 +++
 drivers/s390/char/zcore.c   |  885 
 drivers/s390/cio/cio.c  |1 
 include/asm-s390/ipl.h  |  116 +
 include/asm-s390/processor.h|5 
 include/asm-s390/sclp.h |2 
 include/asm-s390/setup.h|   75 ---
 16 files changed, 1360 insertions(+), 98 deletions(-)

Index: git-linux-2.6/Documentation/s390/zfcpdump.txt
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ git-linux-2.6/Documentation/s390/zfcpdump.txt   2007-02-21 
11:00:15.0 +0100
@@ -0,0 +1,41 @@
+s390 SCSI dump tool (zfcpdump)
+
+System z machines (z900 or higher) provide hardware support for creating system
+dumps on SCSI disks. The dump process is initiated by booting a dump tool, 
which
+has to create a dump of the current (probably crashed) Linux image. In order to
+not overwrite memory of the crashed Linux with data of the dump tool, the
+hardware saves some memory plus the register sets of the boot cpu before the
+dump tool is loaded. There exists an SCLP hardware interface to obtain the 
saved
+memory afterwards. Currently 32 MB are saved.
+
+This zfcpdump implementation consists of a small Linux dump kernel together 
with
+a userspace dump tool, which are loaded together into the saved memory region
+below 32 MB. zfcpdump is installed on a SCSI disk using zipl (as contained in 
the
+s390-tools package) to make the device bootable. The operator of a Linux system
+can then trigger a scsi dump by booting the SCSI disk, where zfcpdump resides 
on.
+
+The kernel part of zfcpdump is implemented as a character device driver named
+zcore, which exports memory and registers of the crashed Linux in an s390
+standalone dump format. It can be used in the same way as e.g. /dev/mem. The
+dump format defines a 4K header followed by plain uncompressed memory. The
+register sets are stored in the prefix pages of the different cpus. To build an
+dump enabled kernel with the zcore driver, the kernel config option
+S390_ZFCPDUMP has to be set. When reading from /dev/zcore, the first part of
+memory, which has been saved by the hardware is read by the driver via the SCLP
+hardware interface. The second part is just copied from the non overwritten 
real
+memory.
+
+The userspace application of zfcpdump resides in an intitramfs. It reads from
+/dev/zcore and writes the system dump to a file on a SCSI disk.
+
+To build zfcpdump you have to do the following:
+- Use /arch/s390/zfcpdump/defconfig.zfcpdump as kernel configuration file, 
which
+  enables the S390_ZFCPDUMP option and sets all other required kernel options.
+- Issue make zfcpdump from the toplevel directory of the linux tree to
+  build the userspace application. Note, that the zfcpdump application has a
+  dependency on glibc and libz.
+- Issue make image to build the zfcpdump image with initramfs.
+
+The zfcpdump enabled kernel image must be copied to
+/usr/share/zfcpdump/zfcpdump.image, where the zipl tool is looking for the dump
+kernel, when preparing a SCSI dump disk.
Index: git-linux-2.6/arch/s390/Kconfig
===
--- git-linux-2.6.orig/arch/s390/Kconfig2007-02-21 10:22:03.0 
+0100
+++ git-linux-2.6/arch/s390/Kconfig 2007-02-21 11:00:15.0 +0100
@@ -512,6 +512,13 @@ config KEXEC
  current kernel, and to start another kernel.  It is like a reboot
  but is independent of hardware/microcode support.
 
+config S390_ZFCPDUMP
+   bool zfcp dump kernel
+   default n
+   help
+ Select this option if you want to build an zfcp dump enabled kernel.
+ Do NOT select this option for normal kernels!
+
 endmenu
 
 source net/Kconfig
Index: git-linux-2.6/arch/s390/kernel/early.c
===
--- git-linux-2.6.orig/arch/s390/kernel/early.c 2007-02-21 10:22:04.0 
+0100
+++ git-linux-2.6/arch/s390/kernel/early.c  2007-02-21 10:56:03.0 
+0100
@@ -14,6 +14,7 @@
 #include linux/module.h
 #include linux/pfn.h
 #include linux/uaccess.h
+#include asm/ipl.h
 #include asm/lowcore.h
 #include asm/processor.h
 #include asm/sections.h
@@ -129,7 +130,7 @@ static noinline __init void detect_machi
 {
struct cpuinfo_S390 *cpuinfo = S390_lowcore.cpu_data;
 
-   asm