All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/10] kexec: Add option to get crash kernel region size
@ 2017-02-10 22:07 Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 01/11] crashdump/arm: Add get_crash_kernel_load_range() function Eric DeVolder
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

This is the third version of a patch series originally posted by
Daniel Kiper on December 5.

This version differs from the previous version based on feedback
received from the mailing list, as such:
- changes for coding convention and formatting
- restructured to introduce get_crash_kernel_load_range() for each
  architecture, and then a single function in kexec/kexec.c to call
  the per-architecture get_crash_kernel_load_range() and print the
  result.

Eric

 kexec/arch/arm/crashdump-arm.c     |  5 +++++
 kexec/arch/arm64/crashdump-arm64.c |  6 ++++++
 kexec/arch/cris/kexec-cris.c       |  6 ++++++
 kexec/arch/ia64/crashdump-ia64.c   |  5 +++++
 kexec/arch/m68k/kexec-m68k.c       |  6 ++++++
 kexec/arch/mips/crashdump-mips.c   |  4 ++++
 kexec/arch/ppc/crashdump-powerpc.c | 22 +++++++++++++++++++++-
 kexec/arch/ppc/kexec-ppc.c         | 27 +++++++++++++++++++++++++++
 kexec/arch/ppc/kexec-ppc.h         |  1 +
 kexec/arch/ppc64/crashdump-ppc64.c | 21 +++++++++++++++++++++
 kexec/arch/ppc64/kexec-ppc64.c     | 27 +++++++++++++++++++++++++++
 kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
 kexec/arch/s390/kexec-s390.c       |  5 +++++
 kexec/arch/sh/crashdump-sh.c       |  5 +++++
 kexec/kexec.8                      |  3 +++
 kexec/kexec.c                      | 20 ++++++++++++++++++++
 kexec/kexec.h                      |  4 +++-
 17 files changed, 167 insertions(+), 2 deletions(-)

Daniel Kiper (10):
      crashdump/arm: Add get_crash_kernel_load_range() function
      crashdump/cris: Add get_crash_kernel_load_range() function
      crashdump/ia64: Add get_crash_kernel_load_range() function
      crashdump/m68k: Add get_crash_kernel_load_range() function
      crashdump/mips: Add get_crash_kernel_load_range() function
      crashdump/ppc: Add get_crash_kernel_load_range() function
      crashdump/ppc64: Add get_crash_kernel_load_range() function
      crashdump/s390: Add get_crash_kernel_load_range() function
      crashdump/sh: Add get_crash_kernel_load_range() function
      kexec: Add option to get crash kernel region size

Eric DeVolder (1):
      crashdump/arm64: Add get_crash_kernel_load_range() function


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v3 01/11] crashdump/arm: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 02/11] crashdump/arm64: " Eric DeVolder
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/arm/crashdump-arm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 4a89b5e..ac76e0a 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -413,3 +413,8 @@ int is_crashkernel_mem_reserved(void)
 
 	return crash_kernel_mem.start != crash_kernel_mem.end;
 }
+
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	return parse_iomem_single("Crash kernel\n", start, end);
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 02/11] crashdump/arm64: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 01/11] crashdump/arm: Add get_crash_kernel_load_range() function Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 21:58   ` Daniel Kiper
  2017-02-10 22:07 ` [PATCH v3 03/11] crashdump/cris: " Eric DeVolder
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/arm64/crashdump-arm64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
index d2272c8..b0e4713 100644
--- a/kexec/arch/arm64/crashdump-arm64.c
+++ b/kexec/arch/arm64/crashdump-arm64.c
@@ -19,3 +19,9 @@ int is_crashkernel_mem_reserved(void)
 {
 	return 0;
 }
+
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	/* Crash kernel region size is not exposed by the system */
+	return -1;
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 03/11] crashdump/cris: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 01/11] crashdump/arm: Add get_crash_kernel_load_range() function Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 02/11] crashdump/arm64: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 21:59   ` Daniel Kiper
  2017-02-10 22:07 ` [PATCH v3 04/11] crashdump/ia64: " Eric DeVolder
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/cris/kexec-cris.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kexec/arch/cris/kexec-cris.c b/kexec/arch/cris/kexec-cris.c
index 4ac2f89..3b69709 100644
--- a/kexec/arch/cris/kexec-cris.c
+++ b/kexec/arch/cris/kexec-cris.c
@@ -77,6 +77,12 @@ int is_crashkernel_mem_reserved(void)
 	return 0;
 }
 
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	/* Crash kernel region size is not exposed by the system */
+	return -1;
+}
+
 unsigned long virt_to_phys(unsigned long addr)
 {
 	return (addr) & 0x7fffffff;
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 04/11] crashdump/ia64: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (2 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 03/11] crashdump/cris: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 05/11] crashdump/m68k: " Eric DeVolder
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/ia64/crashdump-ia64.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kexec/arch/ia64/crashdump-ia64.c b/kexec/arch/ia64/crashdump-ia64.c
index 726c9f4..755ee5e 100644
--- a/kexec/arch/ia64/crashdump-ia64.c
+++ b/kexec/arch/ia64/crashdump-ia64.c
@@ -286,3 +286,8 @@ int is_crashkernel_mem_reserved(void)
 	return parse_iomem_single("Crash kernel\n", &start,
 				  &end) == 0 ?  (start != end) : 0;
 }
+
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	return parse_iomem_single("Crash kernel\n", start, end);
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 05/11] crashdump/m68k: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (3 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 04/11] crashdump/ia64: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 22:01   ` Daniel Kiper
  2017-02-10 22:07 ` [PATCH v3 06/11] crashdump/mips: " Eric DeVolder
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/m68k/kexec-m68k.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kexec/arch/m68k/kexec-m68k.c b/kexec/arch/m68k/kexec-m68k.c
index 372aa37..cb54927 100644
--- a/kexec/arch/m68k/kexec-m68k.c
+++ b/kexec/arch/m68k/kexec-m68k.c
@@ -89,6 +89,12 @@ int is_crashkernel_mem_reserved(void)
 	return 0;
 }
 
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	/* Crash kernel region size is not exposed by the system */
+	return -1;
+}
+
 unsigned long virt_to_phys(unsigned long addr)
 {
 	return addr + m68k_memoffset;
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 06/11] crashdump/mips: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (4 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 05/11] crashdump/m68k: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 07/11] crashdump/ppc: " Eric DeVolder
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/mips/crashdump-mips.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index d6cff5a..9c33599 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -385,3 +385,7 @@ int is_crashkernel_mem_reserved(void)
 		(start != end) : 0;
 }
 
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	return parse_iomem_single("Crash kernel\n", start, end);
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 07/11] crashdump/ppc: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (5 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 06/11] crashdump/mips: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 22:24   ` Daniel Kiper
  2017-02-10 22:07 ` [PATCH v3 08/11] crashdump/ppc64: " Eric DeVolder
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/ppc/crashdump-powerpc.c | 22 +++++++++++++++++++++-
 kexec/arch/ppc/kexec-ppc.c         | 27 +++++++++++++++++++++++++++
 kexec/arch/ppc/kexec-ppc.h         |  1 +
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c
index 3dc35eb..fc5d70c 100644
--- a/kexec/arch/ppc/crashdump-powerpc.c
+++ b/kexec/arch/ppc/crashdump-powerpc.c
@@ -397,6 +397,27 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size)
 		usablemem_rgns.size, base, size);
 }
 
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	unsigned long long value;
+	int ret = 0;
+
+	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-base", &value))
+		*start = value;
+	else {
+		*start = 0;
+		ret = -1;
+	}
+	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-size", &value))
+		*end = *start + value - 1;
+	else {
+		*end = 0;
+		ret = -1;
+	}
+
+	return ret;
+}
+
 int is_crashkernel_mem_reserved(void)
 {
 	int fd;
@@ -407,4 +428,3 @@ int is_crashkernel_mem_reserved(void)
 	close(fd);
 	return 1;
 }
-
diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c
index d046110..d9cdb9c 100644
--- a/kexec/arch/ppc/kexec-ppc.c
+++ b/kexec/arch/ppc/kexec-ppc.c
@@ -423,6 +423,33 @@ err_out:
 	return -1;
 }
 
+int get_devtree_value(const char *fname, unsigned long long *pvalue)
+{
+	/* Return 1 if fname/value valid, 0 otherwise */
+	FILE *file;
+	char buf[MAXBYTES];
+	int ret = 1, n = -1;
+	unsigned long long value = 0;
+
+	if ((file = fopen(fname, "r"))) {
+		n = fread(buf, 1, MAXBYTES, file);
+		fclose(file);
+	}
+
+	if (n == sizeof(uint32_t))
+		value = ((uint32_t *)buf)[0];
+	else if (n == sizeof(uint64_t)) {
+		value = ((uint64_t *)buf)[0];
+	else {
+		fprintf(stderr, "%s node has invalid size: %d\n", fname, n);
+		ret = 0;
+	}
+
+	if (pvalue)
+		*pvalue = value;
+	return ret;
+}
+
 /* Get devtree details and create exclude_range array
  * Also create usablemem_ranges for KEXEC_ON_CRASH
  */
diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h
index 904cf48..0e52d18 100644
--- a/kexec/arch/ppc/kexec-ppc.h
+++ b/kexec/arch/ppc/kexec-ppc.h
@@ -75,6 +75,7 @@ extern unsigned long dt_address_cells, dt_size_cells;
 extern int init_memory_region_info(void);
 extern int read_memory_region_limits(int fd, unsigned long long *start,
 					unsigned long long *end);
+extern int get_devtree_value (const char *fname, unsigned long long *pvalue);
 #define COMMAND_LINE_SIZE	512 /* from kernel */
 /*fs2dt*/
 void reserve(unsigned long long where, unsigned long long length);
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 08/11] crashdump/ppc64: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (6 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 07/11] crashdump/ppc: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 22:26   ` Daniel Kiper
  2017-02-10 22:07 ` [PATCH v3 09/11] crashdump/s390: " Eric DeVolder
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/ppc64/crashdump-ppc64.c | 21 +++++++++++++++++++++
 kexec/arch/ppc64/kexec-ppc64.c     | 27 +++++++++++++++++++++++++++
 kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
 3 files changed, 50 insertions(+)

diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index f62b159..af9adb4 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -526,6 +526,27 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size)
 		usablemem_rgns.size, base, size);
 }
 
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	unsigned long long value;
+	int ret = 0;
+
+	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-base", &value))
+		*start = value;
+	else {
+		*start = 0;
+		ret = -1;
+	}
+	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-size", &value))
+		*end = *start + value - 1;
+	else {
+		*end = 0;
+		ret = -1;
+	}
+
+	return ret;
+}
+
 int is_crashkernel_mem_reserved(void)
 {
 	int fd;
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c
index 09ee025..33bc76f 100644
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -356,6 +356,33 @@ void scan_reserved_ranges(unsigned long kexec_flags, int *range_index)
 	*range_index = i;
 }
 
+int get_devtree_value(const char *fname, unsigned long long *pvalue)
+{
+	/* Return 1 if fname/value valid, 0 otherwise */
+	FILE *file;
+	char buf[MAXBYTES];
+	int ret = 1, n = -1;
+	unsigned long long value = 0;
+
+	if ((file = fopen(fname, "r"))) {
+		n = fread(buf, 1, MAXBYTES, file);
+		fclose(file);
+	}
+
+	if (n == sizeof(uint32_t))
+		value = ((uint32_t *)buf)[0];
+	else if (n == sizeof(uint64_t))
+		value = ((uint64_t *)buf)[0];
+	else {
+		fprintf(stderr, "%s node has invalid size: %d\n", fname, n);
+		ret = 0;
+	}
+
+	if (pvalue)
+		*pvalue = value;
+	return ret;
+}
+
 /* Get devtree details and create exclude_range array
  * Also create usablemem_ranges for KEXEC_ON_CRASH
  */
diff --git a/kexec/arch/ppc64/kexec-ppc64.h b/kexec/arch/ppc64/kexec-ppc64.h
index 89ee942..3d20419 100644
--- a/kexec/arch/ppc64/kexec-ppc64.h
+++ b/kexec/arch/ppc64/kexec-ppc64.h
@@ -14,6 +14,8 @@
 #define HAVE_DYNAMIC_MEMORY
 #define NEED_RESERVE_DTB
 
+extern int get_devtree_value (const char *fname, unsigned long long *pvalue);
+
 int setup_memory_ranges(unsigned long kexec_flags);
 
 int elf_ppc64_probe(const char *buf, off_t len);
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 09/11] crashdump/s390: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (7 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 08/11] crashdump/ppc64: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 10/11] crashdump/sh: " Eric DeVolder
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/s390/kexec-s390.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c
index 074575e..f863483 100644
--- a/kexec/arch/s390/kexec-s390.c
+++ b/kexec/arch/s390/kexec-s390.c
@@ -262,3 +262,8 @@ int is_crashkernel_mem_reserved(void)
 	return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
 		(start != end) : 0;
 }
+
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	return parse_iomem_single("Crash kernel\n", start, end);
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 10/11] crashdump/sh: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (8 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 09/11] crashdump/s390: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-10 22:07 ` [PATCH v3 11/11] kexec: Add option to get crash kernel region size Eric DeVolder
  2017-02-13  4:23 ` [PATCH v3 0/10] " Pratyush Anand
  11 siblings, 0 replies; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

Implement get_crash_kernel_load_range() in support of
print crash kernel region size option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/arch/sh/crashdump-sh.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kexec/arch/sh/crashdump-sh.c b/kexec/arch/sh/crashdump-sh.c
index 9e6af6b..aa25dea 100644
--- a/kexec/arch/sh/crashdump-sh.c
+++ b/kexec/arch/sh/crashdump-sh.c
@@ -178,3 +178,8 @@ int is_crashkernel_mem_reserved(void)
 	return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
 	  (start != end) : 0;
 }
+
+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
+{
+	return parse_iomem_single("Crash kernel\n", start, end);
+}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 11/11] kexec: Add option to get crash kernel region size
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (9 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 10/11] crashdump/sh: " Eric DeVolder
@ 2017-02-10 22:07 ` Eric DeVolder
  2017-02-13 22:41   ` Daniel Kiper
  2017-02-13  4:23 ` [PATCH v3 0/10] " Pratyush Anand
  11 siblings, 1 reply; 19+ messages in thread
From: Eric DeVolder @ 2017-02-10 22:07 UTC (permalink / raw)
  To: horms, kexec, andrew.cooper3, dyoung, panand; +Cc: daniel.kiper, konrad.wilk

From: Daniel Kiper <daniel.kiper@oracle.com>

From: Daniel Kiper <daniel.kiper@oracle.com>

Crash kernel region size is available via sysfs on Linux running on
bare metal. However, this does not work when Linux runs as Xen dom0.
In this case Xen crash kernel region size should be established using
__HYPERVISOR_kexec_op hypercall (Linux kernel kexec functionality does
not make a lot of sense in Xen dom0). Sadly hypercalls are not easily
accessible using shell scripts or something like that. Potentially we
can check "xl dmesg" output for crashkernel option but this is not nice.
So, let's add this functionality, for Linux running on bare metal and
as Xen dom0, to kexec-tools. This way kdump scripts may establish crash
kernel region size in one way regardless of platform. All burden of
platform detection lies on kexec-tools.

Figure (and unit) displayed by this new kexec-tools functionality is
the same as one taken from /sys/kernel/kexec_crash_size.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/kexec.8 |  3 +++
 kexec/kexec.c | 20 ++++++++++++++++++++
 kexec/kexec.h |  4 +++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/kexec/kexec.8 b/kexec/kexec.8
index f4b39a6..e0131b4 100644
--- a/kexec/kexec.8
+++ b/kexec/kexec.8
@@ -179,6 +179,9 @@ Load a helper image to jump back to original kernel.
 .TP
 .BI \-\-reuseinitrd
 Reuse initrd from first boot.
+.TP
+.BI \-\-print-ckr-size
+Print crash kernel region size, if available.
 
 
 .SH SUPPORTED KERNEL FILE TYPES AND OPTIONS
diff --git a/kexec/kexec.c b/kexec/kexec.c
index a2ba79d..0be1be4 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -995,6 +995,7 @@ void usage(void)
 	       "     --mem-max=<addr> Specify the highest memory address to\n"
 	       "                      load code into.\n"
 	       "     --reuseinitrd    Reuse initrd from first boot.\n"
+	       "     --print-ckr-size Print crash kernel region size.\n"
 	       "     --load-preserve-context Load the new kernel and preserve\n"
 	       "                      context of current kernel during kexec.\n"
 	       "     --load-jump-back-helper Load a helper image to jump back\n"
@@ -1218,6 +1219,22 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,
 	return ret;
 }
 
+static void print_crashkernel_region_size(void)
+{
+	uint64_t start = 0, end = 0;
+
+	if (is_crashkernel_mem_reserved()) {
+		int ret = get_crash_kernel_load_range(&start, &end);
+		if (ret != 0) {
+			fprintf(stderr, "get_crash_kernel_load_range failed.\n");
+			return;
+		}
+	}
+	if (start != end)
+		printf("%lu\n", end - start + 1);
+	else
+		printf("0\n");
+}
 
 int main(int argc, char *argv[])
 {
@@ -1375,6 +1392,9 @@ int main(int argc, char *argv[])
 		case OPT_STATUS:
 			do_status = 1;
 			break;
+		case OPT_PRINT_CKR_SIZE:
+			print_crashkernel_region_size();
+			return 0;
 		default:
 			break;
 		}
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 2b06f59..52bef9b 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -226,7 +226,8 @@ extern int file_types;
 #define OPT_LOAD_PRESERVE_CONTEXT 259
 #define OPT_LOAD_JUMP_BACK_HELPER 260
 #define OPT_ENTRY		261
-#define OPT_MAX			262
+#define OPT_PRINT_CKR_SIZE	262
+#define OPT_MAX			263
 #define KEXEC_OPTIONS \
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
@@ -247,6 +248,7 @@ extern int file_types;
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 	{ "status",		0, 0, OPT_STATUS }, \
+	{ "print-ckr-size",     0, 0, OPT_PRINT_CKR_SIZE }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:psS"
 
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/10] kexec: Add option to get crash kernel region size
  2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
                   ` (10 preceding siblings ...)
  2017-02-10 22:07 ` [PATCH v3 11/11] kexec: Add option to get crash kernel region size Eric DeVolder
@ 2017-02-13  4:23 ` Pratyush Anand
  11 siblings, 0 replies; 19+ messages in thread
From: Pratyush Anand @ 2017-02-13  4:23 UTC (permalink / raw)
  To: Eric DeVolder, horms, kexec, andrew.cooper3, dyoung
  Cc: daniel.kiper, konrad.wilk



On Saturday 11 February 2017 03:37 AM, Eric DeVolder wrote:
> This is the third version of a patch series originally posted by
> Daniel Kiper on December 5.
>
> This version differs from the previous version based on feedback
> received from the mailing list, as such:
> - changes for coding convention and formatting
> - restructured to introduce get_crash_kernel_load_range() for each
>   architecture, and then a single function in kexec/kexec.c to call
>   the per-architecture get_crash_kernel_load_range() and print the
>   result.
>
> Eric
>
>  kexec/arch/arm/crashdump-arm.c     |  5 +++++
>  kexec/arch/arm64/crashdump-arm64.c |  6 ++++++
>  kexec/arch/cris/kexec-cris.c       |  6 ++++++
>  kexec/arch/ia64/crashdump-ia64.c   |  5 +++++
>  kexec/arch/m68k/kexec-m68k.c       |  6 ++++++
>  kexec/arch/mips/crashdump-mips.c   |  4 ++++
>  kexec/arch/ppc/crashdump-powerpc.c | 22 +++++++++++++++++++++-
>  kexec/arch/ppc/kexec-ppc.c         | 27 +++++++++++++++++++++++++++
>  kexec/arch/ppc/kexec-ppc.h         |  1 +
>  kexec/arch/ppc64/crashdump-ppc64.c | 21 +++++++++++++++++++++
>  kexec/arch/ppc64/kexec-ppc64.c     | 27 +++++++++++++++++++++++++++
>  kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
>  kexec/arch/s390/kexec-s390.c       |  5 +++++
>  kexec/arch/sh/crashdump-sh.c       |  5 +++++
>  kexec/kexec.8                      |  3 +++
>  kexec/kexec.c                      | 20 ++++++++++++++++++++
>  kexec/kexec.h                      |  4 +++-
>  17 files changed, 167 insertions(+), 2 deletions(-)
>
> Daniel Kiper (10):
>       crashdump/arm: Add get_crash_kernel_load_range() function
>       crashdump/cris: Add get_crash_kernel_load_range() function
>       crashdump/ia64: Add get_crash_kernel_load_range() function
>       crashdump/m68k: Add get_crash_kernel_load_range() function
>       crashdump/mips: Add get_crash_kernel_load_range() function
>       crashdump/ppc: Add get_crash_kernel_load_range() function
>       crashdump/ppc64: Add get_crash_kernel_load_range() function
>       crashdump/s390: Add get_crash_kernel_load_range() function
>       crashdump/sh: Add get_crash_kernel_load_range() function
>       kexec: Add option to get crash kernel region size
>
> Eric DeVolder (1):
>       crashdump/arm64: Add get_crash_kernel_load_range() function
>

Reviewed-by: Pratyush Anand <panand@redhat.com>

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 02/11] crashdump/arm64: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 ` [PATCH v3 02/11] crashdump/arm64: " Eric DeVolder
@ 2017-02-13 21:58   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 21:58 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

Two nitpicks below...

On Fri, Feb 10, 2017 at 04:07:33PM -0600, Eric DeVolder wrote:
> Implement get_crash_kernel_load_range() in support of
> print crash kernel region size option.

This contradicts what is provided in patch body. You should rather say here
that you provide a stub to fulfill requirements of subsequent patch(es).

> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
> ---
>  kexec/arch/arm64/crashdump-arm64.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
> index d2272c8..b0e4713 100644
> --- a/kexec/arch/arm64/crashdump-arm64.c
> +++ b/kexec/arch/arm64/crashdump-arm64.c
> @@ -19,3 +19,9 @@ int is_crashkernel_mem_reserved(void)
>  {
>  	return 0;
>  }
> +
> +int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
> +{
> +	/* Crash kernel region size is not exposed by the system */

Usually I add a full stop at the end of comment. Just my preference.

Otherwise:

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 03/11] crashdump/cris: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 ` [PATCH v3 03/11] crashdump/cris: " Eric DeVolder
@ 2017-02-13 21:59   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 21:59 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

On Fri, Feb 10, 2017 at 04:07:34PM -0600, Eric DeVolder wrote:
> From: Daniel Kiper <daniel.kiper@oracle.com>
>
> Implement get_crash_kernel_load_range() in support of
> print crash kernel region size option.

Ditto.

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 05/11] crashdump/m68k: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 ` [PATCH v3 05/11] crashdump/m68k: " Eric DeVolder
@ 2017-02-13 22:01   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 22:01 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

On Fri, Feb 10, 2017 at 04:07:36PM -0600, Eric DeVolder wrote:
> From: Daniel Kiper <daniel.kiper@oracle.com>
>
> Implement get_crash_kernel_load_range() in support of
> print crash kernel region size option.

Ditto.

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 07/11] crashdump/ppc: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 ` [PATCH v3 07/11] crashdump/ppc: " Eric DeVolder
@ 2017-02-13 22:24   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 22:24 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

On Fri, Feb 10, 2017 at 04:07:38PM -0600, Eric DeVolder wrote:
> From: Daniel Kiper <daniel.kiper@oracle.com>
>
> Implement get_crash_kernel_load_range() in support of
> print crash kernel region size option.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
> ---
>  kexec/arch/ppc/crashdump-powerpc.c | 22 +++++++++++++++++++++-
>  kexec/arch/ppc/kexec-ppc.c         | 27 +++++++++++++++++++++++++++
>  kexec/arch/ppc/kexec-ppc.h         |  1 +
>  3 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c
> index 3dc35eb..fc5d70c 100644
> --- a/kexec/arch/ppc/crashdump-powerpc.c
> +++ b/kexec/arch/ppc/crashdump-powerpc.c
> @@ -397,6 +397,27 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size)
>  		usablemem_rgns.size, base, size);
>  }
>
> +int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
> +{
> +	unsigned long long value;
> +	int ret = 0;
> +
> +	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-base", &value))

Could not you define this path as a constant somewhere? It is used in a
few places, so, it would be nice.

> +		*start = value;
> +	else {
> +		*start = 0;
> +		ret = -1;
> +	}

I would add empty line here.

> +	if (get_devtree_value("/proc/device-tree/chosen/linux,crashkernel-size", &value))

Ditto.

> +		*end = *start + value - 1;
> +	else {
> +		*end = 0;
> +		ret = -1;
> +	}
> +
> +	return ret;
> +}
> +
>  int is_crashkernel_mem_reserved(void)
>  {
>  	int fd;
> @@ -407,4 +428,3 @@ int is_crashkernel_mem_reserved(void)
>  	close(fd);
>  	return 1;
>  }
> -

Nice but this cleanup should be a separate patch if you wish.
Otherwise it is a bit confusing.

> diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c
> index d046110..d9cdb9c 100644
> --- a/kexec/arch/ppc/kexec-ppc.c
> +++ b/kexec/arch/ppc/kexec-ppc.c
> @@ -423,6 +423,33 @@ err_out:
>  	return -1;
>  }
>
> +int get_devtree_value(const char *fname, unsigned long long *pvalue)
> +{
> +	/* Return 1 if fname/value valid, 0 otherwise */

Most if not all functions in kexec/arch/ppc/kexec-ppc.c return -1 in case
of error and 0 if everything went OK. Please follow this convention.

> +	FILE *file;
> +	char buf[MAXBYTES];
> +	int ret = 1, n = -1;
> +	unsigned long long value = 0;
> +
> +	if ((file = fopen(fname, "r"))) {
> +		n = fread(buf, 1, MAXBYTES, file);
> +		fclose(file);
> +	}
> +
> +	if (n == sizeof(uint32_t))
> +		value = ((uint32_t *)buf)[0];

I would prefer *((uint32_t *)buf) but as I can see this is a convention
in this file, so, let's leave it as is.

> +	else if (n == sizeof(uint64_t)) {
> +		value = ((uint64_t *)buf)[0];

Ditto.

> +	else {
> +		fprintf(stderr, "%s node has invalid size: %d\n", fname, n);
> +		ret = 0;
> +	}
> +
> +	if (pvalue)
> +		*pvalue = value;

Add empty line here.

> +	return ret;
> +}
> +
>  /* Get devtree details and create exclude_range array
>   * Also create usablemem_ranges for KEXEC_ON_CRASH
>   */
> diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h
> index 904cf48..0e52d18 100644
> --- a/kexec/arch/ppc/kexec-ppc.h
> +++ b/kexec/arch/ppc/kexec-ppc.h
> @@ -75,6 +75,7 @@ extern unsigned long dt_address_cells, dt_size_cells;
>  extern int init_memory_region_info(void);
>  extern int read_memory_region_limits(int fd, unsigned long long *start,
>  					unsigned long long *end);
> +extern int get_devtree_value (const char *fname, unsigned long long *pvalue);

Remove extra space between function name and parentheses.

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 08/11] crashdump/ppc64: Add get_crash_kernel_load_range() function
  2017-02-10 22:07 ` [PATCH v3 08/11] crashdump/ppc64: " Eric DeVolder
@ 2017-02-13 22:26   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 22:26 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

On Fri, Feb 10, 2017 at 04:07:39PM -0600, Eric DeVolder wrote:
> From: Daniel Kiper <daniel.kiper@oracle.com>
>
> Implement get_crash_kernel_load_range() in support of
> print crash kernel region size option.

Most of comments for #07 applies here too.

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 11/11] kexec: Add option to get crash kernel region size
  2017-02-10 22:07 ` [PATCH v3 11/11] kexec: Add option to get crash kernel region size Eric DeVolder
@ 2017-02-13 22:41   ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2017-02-13 22:41 UTC (permalink / raw)
  To: Eric DeVolder; +Cc: panand, konrad.wilk, andrew.cooper3, kexec, horms, dyoung

On Fri, Feb 10, 2017 at 04:07:42PM -0600, Eric DeVolder wrote:
> From: Daniel Kiper <daniel.kiper@oracle.com>
>
> From: Daniel Kiper <daniel.kiper@oracle.com>

Hmmm... One is sufficient...

> Crash kernel region size is available via sysfs on Linux running on
> bare metal. However, this does not work when Linux runs as Xen dom0.
> In this case Xen crash kernel region size should be established using
> __HYPERVISOR_kexec_op hypercall (Linux kernel kexec functionality does
> not make a lot of sense in Xen dom0). Sadly hypercalls are not easily
> accessible using shell scripts or something like that. Potentially we
> can check "xl dmesg" output for crashkernel option but this is not nice.
> So, let's add this functionality, for Linux running on bare metal and
> as Xen dom0, to kexec-tools. This way kdump scripts may establish crash
> kernel region size in one way regardless of platform. All burden of
> platform detection lies on kexec-tools.
>
> Figure (and unit) displayed by this new kexec-tools functionality is
> the same as one taken from /sys/kernel/kexec_crash_size.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
> ---
>  kexec/kexec.8 |  3 +++
>  kexec/kexec.c | 20 ++++++++++++++++++++
>  kexec/kexec.h |  4 +++-
>  3 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/kexec/kexec.8 b/kexec/kexec.8
> index f4b39a6..e0131b4 100644
> --- a/kexec/kexec.8
> +++ b/kexec/kexec.8
> @@ -179,6 +179,9 @@ Load a helper image to jump back to original kernel.
>  .TP
>  .BI \-\-reuseinitrd
>  Reuse initrd from first boot.
> +.TP
> +.BI \-\-print-ckr-size
> +Print crash kernel region size, if available.
>
>
>  .SH SUPPORTED KERNEL FILE TYPES AND OPTIONS
> diff --git a/kexec/kexec.c b/kexec/kexec.c
> index a2ba79d..0be1be4 100644
> --- a/kexec/kexec.c
> +++ b/kexec/kexec.c
> @@ -995,6 +995,7 @@ void usage(void)
>  	       "     --mem-max=<addr> Specify the highest memory address to\n"
>  	       "                      load code into.\n"
>  	       "     --reuseinitrd    Reuse initrd from first boot.\n"
> +	       "     --print-ckr-size Print crash kernel region size.\n"
>  	       "     --load-preserve-context Load the new kernel and preserve\n"
>  	       "                      context of current kernel during kexec.\n"
>  	       "     --load-jump-back-helper Load a helper image to jump back\n"
> @@ -1218,6 +1219,22 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,
>  	return ret;
>  }
>
> +static void print_crashkernel_region_size(void)
> +{
> +	uint64_t start = 0, end = 0;

This initialization is not needed.

> +
> +	if (is_crashkernel_mem_reserved()) {
> +		int ret = get_crash_kernel_load_range(&start, &end);

I do not like mixing code with variable declarations.

> +		if (ret != 0) {

if (ret)

> +			fprintf(stderr, "get_crash_kernel_load_range failed.\n");

s/get_crash_kernel_load_range/get_crash_kernel_load_range()/

> +			return;
> +		}
> +	}

Please add empty line here.

> +	if (start != end)

if (!ret && start != end)

There is no guarantee that in case of error nobody touched start and/or
end in get_crash_kernel_load_range() call.

> +		printf("%lu\n", end - start + 1);
> +	else
> +		printf("0\n");
> +}

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-02-13 22:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 22:07 [PATCH v3 0/10] kexec: Add option to get crash kernel region size Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 01/11] crashdump/arm: Add get_crash_kernel_load_range() function Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 02/11] crashdump/arm64: " Eric DeVolder
2017-02-13 21:58   ` Daniel Kiper
2017-02-10 22:07 ` [PATCH v3 03/11] crashdump/cris: " Eric DeVolder
2017-02-13 21:59   ` Daniel Kiper
2017-02-10 22:07 ` [PATCH v3 04/11] crashdump/ia64: " Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 05/11] crashdump/m68k: " Eric DeVolder
2017-02-13 22:01   ` Daniel Kiper
2017-02-10 22:07 ` [PATCH v3 06/11] crashdump/mips: " Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 07/11] crashdump/ppc: " Eric DeVolder
2017-02-13 22:24   ` Daniel Kiper
2017-02-10 22:07 ` [PATCH v3 08/11] crashdump/ppc64: " Eric DeVolder
2017-02-13 22:26   ` Daniel Kiper
2017-02-10 22:07 ` [PATCH v3 09/11] crashdump/s390: " Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 10/11] crashdump/sh: " Eric DeVolder
2017-02-10 22:07 ` [PATCH v3 11/11] kexec: Add option to get crash kernel region size Eric DeVolder
2017-02-13 22:41   ` Daniel Kiper
2017-02-13  4:23 ` [PATCH v3 0/10] " Pratyush Anand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.