Skip to contentSkip to conversation

s390: Patch series for s390 kdump support

PATCH Applied Michael Holzheu 2 participants 6 messages Aug 19, 2011 – Sep 5, 2011

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 kexec-tools: Add s390 kdump support

From: Michael Holzheu <[email protected]>

This patch adds kdump support for s390 to the kexec tool and enables the "--load-panic" option. When loading the kdump kernel and ramdisk we add the address of the crashkernel memory to the normal load address.

---
 include/elf.h                        |    8 ++-
 kexec/arch/s390/Makefile             |    1 
 kexec/arch/s390/crashdump-s390.c     |   74 +++++++++++++++++++++++++++
 kexec/arch/s390/kexec-elf-rel-s390.c |   66 +++++++++++++++++++++---
 kexec/arch/s390/kexec-image.c        |   69 ++++++++++++++++++-------
 kexec/arch/s390/kexec-s390.c         |   68 ++++++++++++++++++-------
 kexec/arch/s390/kexec-s390.h         |    9 +++
 purgatory/arch/s390/Makefile         |    5 +
 purgatory/arch/s390/console-s390.c   |   14 +++++
 purgatory/arch/s390/purgatory-s390.c |   93 +++++++++++++++++++++++++++++++++++
 purgatory/arch/s390/setup-s390.S     |   33 ++++++++++++
 11 files changed, 390 insertions(+), 50 deletions(-)
include/elf.h +6 -2
@@ -2304,9 +2304,13 @@ typedef Elf32_Addr Elf32_Conflict;
 #define R_390_TLS_DTPOFF	55	/* Offset in TLS block.	 */
 #define R_390_TLS_TPOFF		56	/* Negated offset in static TLS
 					   block.  */
-
+#define R_390_20		57	/* Direct 20 bit.  */
+#define R_390_GOT20		58	/* 20 bit GOT offset.  */
+#define R_390_GOTPLT20		59	/* 20 bit offset to jump slot.  */
+#define R_390_TLS_GOTIE20	60	/* 20 bit GOT offset for static TLS
+					   block offset.  */
 /* Keep this the last entry.  */
-#define R_390_NUM		57
+#define R_390_NUM		61
 
 /* CRIS relocations.  */
 #define R_CRIS_NONE		0
kexec/arch/s390/Makefile +1 -0
@@ -4,6 +4,7 @@
 s390_KEXEC_SRCS =  kexec/arch/s390/kexec-s390.c
 s390_KEXEC_SRCS += kexec/arch/s390/kexec-image.c
 s390_KEXEC_SRCS += kexec/arch/s390/kexec-elf-rel-s390.c
+s390_KEXEC_SRCS += kexec/arch/s390/crashdump-s390.c
 
 dist += kexec/arch/s390/Makefile $(s390_KEXEC_SRCS)			\
 	kexec/arch/s390/kexec-s390.h					\
kexec/arch/s390/crashdump-s390.c new file +74 -0

74 lines not on this page · raw message

kexec/arch/s390/kexec-elf-rel-s390.c +58 -8

80 lines not on this page · raw message

kexec/arch/s390/kexec-image.c +50 -19

128 lines not on this page · raw message

kexec/arch/s390/kexec-s390.c +48 -20

111 lines not on this page · raw message

kexec/arch/s390/kexec-s390.h +9 -0
@@ -15,11 +15,20 @@
 #define RAMDISK_ORIGIN_ADDR   0x800000
 #define INITRD_START_OFFS     0x408
 #define INITRD_SIZE_OFFS      0x410
+#define OLDMEM_BASE_OFFS      0x418
+#define OLDMEM_SIZE_OFFS      0x420
 #define COMMAND_LINE_OFFS     0x480
 #define COMMAND_LINESIZE      896
+#define MAX_MEMORY_RANGES     64
 
 extern int image_s390_load(int, char **, const char *, off_t, struct kexec_info *);
 extern int image_s390_probe(const char *, off_t);
 extern void image_s390_usage(void);
+extern int load_crashdump_segments(struct kexec_info *info,
+				   unsigned long crash_base,
+				   unsigned long crash_end);
+extern int get_memory_ranges_s390(struct memory_range range[], int *ranges,
+				  int with_crashk);
+extern int command_line_add(const char *str);
 
 #endif /* KEXEC_IA64_H */
purgatory/arch/s390/Makefile +4 -1
@@ -2,7 +2,10 @@
 # Purgatory s390
 #
 
-s390_PURGATORY_SRCS =
+s390_PURGATORY_EXTRA_CFLAGS += -fno-stack-protector
+s390_PURGATORY_SRCS += purgatory/arch/s390/console-s390.c
+s390_PURGATORY_SRCS += purgatory/arch/s390/setup-s390.S
+s390_PURGATORY_SRCS += purgatory/arch/s390/purgatory-s390.c
 
 dist += purgatory/arch/s390/Makefile $(s390_PURGATORY_SRCS)
 
purgatory/arch/s390/console-s390.c new file +14 -0
@@ -0,0 +1,14 @@
+/*
+ * S390 console code (currently not implemented)
+ *
+ * Copyright IBM Corp. 2011
+ *
+ * Author(s): Michael Holzheu <[email protected]>
+ */
+
+#include <purgatory.h>
+#include "unused.h"
+
+void putchar(int UNUSED(ch))
+{
+}
purgatory/arch/s390/purgatory-s390.c new file +93 -0

93 lines not on this page · raw message

purgatory/arch/s390/setup-s390.S new file +33 -0
@@ -0,0 +1,33 @@
+/*
+ * Purgatory setup code
+ *
+ * Copyright IBM Corp. 2011
+ *
+ * Author(s): Michael Holzheu <[email protected]>
+ */
+
+	.text
+	.globl purgatory_start
+	.balign 16
+purgatory_start:
+#ifdef __s390x__
+	larl	%r15,lstack_end
+	aghi	%r15,-160
+	brasl	%r14,purgatory
+	larl	%r14,kdump_psw
+	lpswe	0(%r14)
+
+	.section ".data"
+	.balign 16
+kdump_psw:
+	.quad 0x0000000180000000
+	.quad 0x0000000000010010
+
+	.bss
+	.balign 4096
+lstack:
+	.skip 4096
+lstack_end:
+#else
+0:	j	0
+#endif
#2 lore raw

PATCH 2/2 kexec-tools: Allow to call verify_sha256_digest() from kernel

In reply to Michael Holzheu

From: Michael Holzheu <[email protected]>

For s390 we first want to check if kdump checksums are valid before we start the kdump kernel. With this patch on s390 the purgatory entry point is called with a parameter. If the parameter is "0", only the checksum test is done and the result (0 = ok, 1 = invalid) is passed as return code back to the caller (kernel). If the parameter is "1", the complete purgatory code is executed and kdump is started.

---
 purgatory/arch/s390/setup-s390.S |   14 ++++++++++++++
 purgatory/purgatory.c            |   13 ++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)
purgatory/arch/s390/setup-s390.S +14 -0
@@ -11,12 +11,23 @@
 	.balign 16
 purgatory_start:
 #ifdef __s390x__
+	larl	%r5,gprs_save_area
+	stmg	%r6,%r15,0(%r5)
 	larl	%r15,lstack_end
 	aghi	%r15,-160
+
+	clgfi	%r2,0
+	je	verify_checksums
+
 	brasl	%r14,purgatory
 	larl	%r14,kdump_psw
 	lpswe	0(%r14)
 
+verify_checksums:
+	brasl	%r14,verify_sha256_digest
+	larl	%r5,gprs_save_area
+	lmg	%r6,%r15,0(%r5)
+	br	%r14
 	.section ".data"
 	.balign 16
 kdump_psw:
@@ -24,6 +35,9 @@ kdump_psw:
 	.quad 0x0000000000010010
 
 	.bss
+gprs_save_area:
+	.fill 80
+
 	.balign 4096
 lstack:
 	.skip 4096
purgatory/purgatory.c +8 -5
@@ -9,7 +9,7 @@
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
 
-void verify_sha256_digest(void)
+int verify_sha256_digest(void)
 {
 	struct sha256_region *ptr, *end;
 	sha256_digest_t digest;
@@ -34,16 +34,19 @@ void verify_sha256_digest(void)
 			printf("%hhx ", sha256_digest[i]);
 		}
 		printf("\n");
-		for(;;) {
-			/* loop forever */
-		}
+		return 1;
 	}
+	return 0;
 }
 
 void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	verify_sha256_digest();
+	if (verify_sha256_digest()) {
+		for(;;) {
+			/* loop forever */
+		}
+	}
 	post_verification_setup_arch();
 }
Applied
#3 lore raw
In reply to Michael Holzheu
Quoted 6 lines · Michael Holzheu

Hello Simon,

The following two patches add s390 kdump support (64 bit only) to the kexec-tools:
[0] Add s390 kdump support
[1] Allow to call verify_sha256_digest() from kernel

Thanks, applied.

#4 lore raw

Hello Simon,

Quoted 9 lines · Simon Horman
Quoted 6 lines · Michael Holzheu

Hello Simon,

The following two patches add s390 kdump support (64 bit only) to the kexec-tools:
[0] Add s390 kdump support
[1] Allow to call verify_sha256_digest() from kernel

Thanks, applied.

I checked out kexec-tools git head. Everything worked as expected.

Thanks!

Michael

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
Quoted 6 lines · Michael Holzheu

Hello Simon,

Quoted 3 lines · Simon Horman
Quoted 2 lines · Michael Holzheu

Hello Simon,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The following two patches add s390 kdump support (64 bit only) to the kexec-tools:
[0] Add s390 kdump support
[1] Allow to call verify_sha256_digest() from kernel

Thanks, applied.

I checked out kexec-tools git head. Everything worked as expected.

Great. If you have any further patches to kexec-tools please let me know.