Accepting request 562565 from home:michals

Fix kexec error on ppc64 (bsc#1074947).
  0046-powerpc-fix-command-line-overflow-error.patch
  0047-fix-how-RMA-top-is-deduced.patch

OBS-URL: https://build.opensuse.org/request/show/562565
OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=89
This commit is contained in:
Tony Jones 2018-01-10 17:58:57 +00:00 committed by Git OBS Bridge
parent 00fa134abf
commit cb1b6091af
4 changed files with 285 additions and 1 deletions

View File

@ -0,0 +1,145 @@
From 21eb397a5fc9227cd95d23e8c74a49cf6a293e57 Mon Sep 17 00:00:00 2001
From: Hari Bathini <hbathini@linux.vnet.ibm.com>
Date: Wed, 9 Aug 2017 23:47:42 +0530
Subject: [PATCH] kexec-tools: powerpc: fix command line overflow error
References: bsc#1074947
Patch-mainline: v2.0.16-rc1
Git-commit: 21eb397a5fc9227cd95d23e8c74a49cf6a293e57
Since kernel commit a5980d064fe2 ("powerpc: Bump COMMAND_LINE_SIZE
to 2048"), powerpc bumped command line size to 2048 but the size
used here is still the default value of 512. Bump it to 2048 to
fix command line overflow errors observed when command line length
is above 512 bytes. Also, get rid of the multiple definitions of
COMMAND_LINE_SIZE macro in ppc architecture.
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
kexec/arch/ppc/crashdump-powerpc.c | 6 +++++-
kexec/arch/ppc/crashdump-powerpc.h | 2 --
kexec/arch/ppc/fs2dt.c | 1 -
kexec/arch/ppc/kexec-ppc.h | 3 ++-
kexec/arch/ppc/ops.h | 1 -
kexec/arch/ppc64/crashdump-ppc64.c | 6 ++++--
kexec/arch/ppc64/crashdump-ppc64.h | 2 +-
7 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c
index dde6de7ec7a1..4ad026f38dd0 100644
--- a/kexec/arch/ppc/crashdump-powerpc.c
+++ b/kexec/arch/ppc/crashdump-powerpc.c
@@ -252,8 +252,12 @@ static void ulltoa(unsigned long long i, char *str)
/* Append str to cmdline */
static void add_cmdline(char *cmdline, char *str)
{
+ int cmdline_size;
int cmdlen = strlen(cmdline) + strlen(str);
- if (cmdlen > (COMMAND_LINE_SIZE - 1))
+
+ cmdline_size = (kernel_version() < KERNEL_VERSION(3, 15, 0) ?
+ 512 : COMMAND_LINE_SIZE);
+ if (cmdlen > (cmdline_size - 1))
die("Command line overflow\n");
strcat(cmdline, str);
}
diff --git a/kexec/arch/ppc/crashdump-powerpc.h b/kexec/arch/ppc/crashdump-powerpc.h
index 9b9b01e3157b..97b5095ba748 100644
--- a/kexec/arch/ppc/crashdump-powerpc.h
+++ b/kexec/arch/ppc/crashdump-powerpc.h
@@ -20,8 +20,6 @@ extern struct arch_options_t arch_options;
#define KERNELBASE PAGE_OFFSET
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
-#define COMMAND_LINE_SIZE 512 /* from kernel */
-
#ifdef CONFIG_BOOKE
/* We don't need backup region in Book E */
#define BACKUP_SRC_START 0x0000
diff --git a/kexec/arch/ppc/fs2dt.c b/kexec/arch/ppc/fs2dt.c
index 6e7737919695..fed499b4da9d 100644
--- a/kexec/arch/ppc/fs2dt.c
+++ b/kexec/arch/ppc/fs2dt.c
@@ -37,7 +37,6 @@
#define TREEWORDS 65536 /* max 32 bit words for properties */
#define MEMRESERVE 256 /* max number of reserved memory blks */
#define MAX_MEMORY_RANGES 1024
-#define COMMAND_LINE_SIZE 512 /* from kernel */
static char pathname[MAXPATH];
static char propnames[NAMESPACE] = { 0 };
diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h
index f8fd67827e43..04e728eddf7f 100644
--- a/kexec/arch/ppc/kexec-ppc.h
+++ b/kexec/arch/ppc/kexec-ppc.h
@@ -6,6 +6,8 @@
#define CORE_TYPE_ELF32 1
#define CORE_TYPE_ELF64 2
+#define COMMAND_LINE_SIZE 2048 /* from kernel */
+
extern unsigned char setup_simple_start[];
extern uint32_t setup_simple_size;
@@ -76,7 +78,6 @@ 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);
diff --git a/kexec/arch/ppc/ops.h b/kexec/arch/ppc/ops.h
index 7334a059dd94..5e7a070808d3 100644
--- a/kexec/arch/ppc/ops.h
+++ b/kexec/arch/ppc/ops.h
@@ -12,7 +12,6 @@
#define _PPC_BOOT_OPS_H_
#include "types.h"
-#define COMMAND_LINE_SIZE 512
#define MAX_PATH_LEN 256
#define MAX_PROP_LEN 256 /* What should this be? */
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index 5a71d5161c87..13995bfb8fc1 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -381,7 +381,7 @@ static void ultoa(uint64_t i, char *str)
static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr,
char *byte)
{
- int cmdlen, len, align = 1024;
+ int cmdline_size, cmdlen, len, align = 1024;
char str[COMMAND_LINE_SIZE], *ptr;
/* Passing in =xxxK / =xxxM format. Saves space required in cmdline.*/
@@ -402,7 +402,9 @@ static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr,
strcat(str, byte);
len = strlen(str);
cmdlen = strlen(cmdline) + len;
- if (cmdlen > (COMMAND_LINE_SIZE - 1))
+ cmdline_size = (kernel_version() < KERNEL_VERSION(3, 15, 0) ?
+ 512 : COMMAND_LINE_SIZE);
+ if (cmdlen > (cmdline_size - 1))
die("Command line overflow\n");
strcat(cmdline, str);
dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline);
diff --git a/kexec/arch/ppc64/crashdump-ppc64.h b/kexec/arch/ppc64/crashdump-ppc64.h
index d654c6b5e8a9..42ccc31e538c 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.h
+++ b/kexec/arch/ppc64/crashdump-ppc64.h
@@ -16,7 +16,7 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size);
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
#define MAXMEM (-KERNELBASE-VMALLOCBASE)
-#define COMMAND_LINE_SIZE 512 /* from kernel */
+#define COMMAND_LINE_SIZE 2048 /* from kernel */
/* Backup Region, First 64K of System RAM. */
#define BACKUP_SRC_START 0x0000
#define BACKUP_SRC_END 0xffff
--
2.13.6

View File

@ -0,0 +1,128 @@
From 47478ea66d4301b12a07862aebc8447a2932f0ed Mon Sep 17 00:00:00 2001
From: Hari Bathini <hbathini@linux.vnet.ibm.com>
Date: Wed, 26 Jul 2017 22:49:41 +0530
Subject: [PATCH] kexec-tools: ppc64: fix how RMA top is deduced
References: bsc#1074947
Patch-mainline: v2.0.16-rc1
Git-commit: 47478ea66d4301b12a07862aebc8447a2932f0ed
Hang was observed, in purgatory, on a machine configured with
single LPAR. This was because one of the segments was loaded
outside the actual Real Memory Area (RMA) due to wrongly
deduced RMA top value.
Currently, top of real memory area, which is crucial for loading
kexec/kdump kernel, is obtained by iterating through mem nodes
and setting its value based on the base and size values of the
last mem node in the iteration. That can't always be correct as
the order of iteration may not be same and RMA base & size are
always based on the first memory property. Fix this by setting
RMA top value based on the base and size values of the memory
node that has the smallest base value (first memory property)
among all the memory nodes.
Also, correct the misnomers rmo_base and rmo_top to rma_base
and rma_top respectively.
While how RMA top is deduced was broken for sometime, the issue
may not have been seen so far, for couple of possible reasons:
1. Only one mem node was available.
2. First memory property has been the last node in
iteration when multiple mem nodes were present.
Fixes: 02f4088ffded ("kexec fix ppc64 device-tree mem node")
Reported-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Geoff Levand <geoff@infradead.org>
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
kexec/arch/ppc64/kexec-ppc64.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c
index 6e8c175878a4..a7d708b8f8c6 100644
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -38,7 +38,7 @@
static struct memory_range *exclude_range = NULL;
static struct memory_range *memory_range = NULL;
static struct memory_range *base_memory_range = NULL;
-static uint64_t rmo_top;
+static uint64_t rma_top;
uint64_t memory_max = 0;
uint64_t memory_limit;
static int nr_memory_ranges, nr_exclude_ranges;
@@ -385,7 +385,7 @@ int get_devtree_value(const char *fname, unsigned long long *value)
*/
static int get_devtree_details(unsigned long kexec_flags)
{
- uint64_t rmo_base;
+ uint64_t rma_base = -1, base;
uint64_t tce_base;
unsigned int tce_size;
uint64_t htab_base, htab_size;
@@ -696,10 +696,13 @@ static int get_devtree_details(unsigned long kexec_flags)
perror(fname);
goto error_openfile;
}
- rmo_base = be64_to_cpu(((uint64_t *)buf)[0]);
- rmo_top = rmo_base + be64_to_cpu(((uint64_t *)buf)[1]);
- if (rmo_top > 0x30000000UL)
- rmo_top = 0x30000000UL;
+ base = be64_to_cpu(((uint64_t *)buf)[0]);
+ if (base < rma_base) {
+ rma_base = base;
+ rma_top = base + be64_to_cpu(((uint64_t *)buf)[1]);
+ if (rma_top > 0x30000000UL)
+ rma_top = 0x30000000UL;
+ }
fclose(file);
closedir(cdir);
@@ -811,14 +814,14 @@ int setup_memory_ranges(unsigned long kexec_flags)
j++;
if (j >= max_memory_ranges)
realloc_memory_ranges();
- /* Limit the end to rmo_top */
- if (memory_range[j-1].start >= rmo_top) {
+ /* Limit the end to rma_top */
+ if (memory_range[j-1].start >= rma_top) {
j--;
break;
}
- if ((memory_range[j-1].start < rmo_top) &&
- (memory_range[j-1].end >= rmo_top)) {
- memory_range[j-1].end = rmo_top;
+ if ((memory_range[j-1].start < rma_top) &&
+ (memory_range[j-1].end >= rma_top)) {
+ memory_range[j-1].end = rma_top;
break;
}
continue;
@@ -833,14 +836,14 @@ int setup_memory_ranges(unsigned long kexec_flags)
j++;
if (j >= max_memory_ranges)
realloc_memory_ranges();
- /* Limit range to rmo_top */
- if (memory_range[j-1].start >= rmo_top) {
+ /* Limit range to rma_top */
+ if (memory_range[j-1].start >= rma_top) {
j--;
break;
}
- if ((memory_range[j-1].start < rmo_top) &&
- (memory_range[j-1].end >= rmo_top)) {
- memory_range[j-1].end = rmo_top;
+ if ((memory_range[j-1].start < rma_top) &&
+ (memory_range[j-1].end >= rma_top)) {
+ memory_range[j-1].end = rma_top;
break;
}
}
--
2.13.6

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jan 8 15:14:57 UTC 2018 - msuchanek@suse.com
- Fix kexec error on ppc64 (bsc#1074947).
0046-powerpc-fix-command-line-overflow-error.patch
0047-fix-how-RMA-top-is-deduced.patch
-------------------------------------------------------------------
Tue Oct 31 10:23:51 MDT 2017 - carnold@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package kexec-tools
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -84,6 +84,8 @@ Patch142: 0042-arm64-kdump-set-up-other-segments.patch
Patch143: 0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch
Patch144: 0044-arm64-kdump-Add-support-for-binary-image-files.patch
Patch145: 0045-Handle-additional-e820-memmap-type-strings.patch
Patch146: 0046-powerpc-fix-command-line-overflow-error.patch
Patch147: 0047-fix-how-RMA-top-is-deduced.patch
Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -152,6 +154,8 @@ the loaded kernel after it panics.
%patch143 -p1
%patch144 -p1
%patch145 -p1
%patch146 -p1
%patch147 -p1
%patch1 -p1
%patch2 -p1