From b786d3484b799319b0a64cfe7d7529f77a3cd6ebd894f77308c93eff5aac3404 Mon Sep 17 00:00:00 2001 From: Tony Jones Date: Tue, 6 Oct 2015 16:33:34 +0000 Subject: [PATCH] Accepting request 336688 from home:ptesarik:branches:Kernel:kdump Fix bug 946365 OBS-URL: https://build.opensuse.org/request/show/336688 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=66 --- kexec-tools-load-crash-kernel-high.patch | 97 ++++++++++++++++++++++++ kexec-tools.changes | 6 ++ kexec-tools.spec | 2 + 3 files changed, 105 insertions(+) create mode 100644 kexec-tools-load-crash-kernel-high.patch diff --git a/kexec-tools-load-crash-kernel-high.patch b/kexec-tools-load-crash-kernel-high.patch new file mode 100644 index 0000000..1b323f6 --- /dev/null +++ b/kexec-tools-load-crash-kernel-high.patch @@ -0,0 +1,97 @@ +From: Petr Tesarik +Date: Thu Sep 24 08:48:52 2015 +0200 +Subject: Load crash kernel high on x86 +References: bsc#946365 +Patch-mainline: post-v2.0.10 +Git-commit: 4fbf781eb0383a491906d3851b066657b29c2816 + +There may be more than one crash kernel regions on x86. Currently, +kexec-tools picks the largest one. If high reservation is smaller +than low, it will try to load panic kernel low. However, the kexec +syscall checks that target address is within crashk_res boundaries, +so attempts to load crash kernel low result in -EADDRNOTAVAIL, and +kexec prints out this error message: + +kexec_load failed: Cannot assign requested address + +Looking at the logic in arch/x86/kernel/setup.c, there are only two +possible layouts: + + 1. crashk_res is below 4G, and there is only one region, + 2. crashk_res is above 4G, and crashk_low_res is below 4G + +In either case, kexec-tools must pick the highest region. + +Changelog: + + * v3: rename function to get_crash_kernel_load_range + * v2: remove unnecessary local variables + +Signed-off-by: Petr Tesarik +Signed-off-by: Simon Horman + +--- + kexec/arch/i386/crashdump-x86.c | 21 +++++++-------------- + kexec/arch/i386/kexec-x86-common.c | 4 ++-- + kexec/kexec.h | 2 +- + 3 files changed, 10 insertions(+), 17 deletions(-) + +--- a/kexec/arch/i386/crashdump-x86.c ++++ b/kexec/arch/i386/crashdump-x86.c +@@ -1017,24 +1017,17 @@ int load_crashdump_segments(struct kexec + return 0; + } + +-int get_max_crash_kernel_limit(uint64_t *start, uint64_t *end) ++/* On x86, the kernel may make a low reservation in addition to the ++ * normal reservation. However, the kernel refuses to load the panic ++ * kernel to low memory, so always choose the highest range. ++ */ ++int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) + { +- int i, idx = -1; +- unsigned long sz_max = 0, sz; +- + if (!crash_reserved_mem_nr) + return -1; + +- for (i = crash_reserved_mem_nr - 1; i >= 0; i--) { +- sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1; +- if (sz <= sz_max) +- continue; +- sz_max = sz; +- idx = i; +- } +- +- *start = crash_reserved_mem[idx].start; +- *end = crash_reserved_mem[idx].end; ++ *start = crash_reserved_mem[crash_reserved_mem_nr - 1].start; ++ *end = crash_reserved_mem[crash_reserved_mem_nr - 1].end; + + return 0; + } +--- a/kexec/arch/i386/kexec-x86-common.c ++++ b/kexec/arch/i386/kexec-x86-common.c +@@ -361,9 +361,9 @@ int get_memory_ranges(struct memory_rang + !(kexec_flags & KEXEC_PRESERVE_CONTEXT)) { + uint64_t start, end; + +- ret = get_max_crash_kernel_limit(&start, &end); ++ ret = get_crash_kernel_load_range(&start, &end); + if (ret != 0) { +- fprintf(stderr, "get_max_crash_kernel_limit failed.\n"); ++ fprintf(stderr, "get_crash_kernel_load_range failed.\n"); + return -1; + } + +--- a/kexec/kexec.h ++++ b/kexec/kexec.h +@@ -286,7 +286,7 @@ int arch_process_options(int argc, char + int arch_compat_trampoline(struct kexec_info *info); + void arch_update_purgatory(struct kexec_info *info); + int is_crashkernel_mem_reserved(void); +-int get_max_crash_kernel_limit(uint64_t *start, uint64_t *end); ++int get_crash_kernel_load_range(uint64_t *start, uint64_t *end); + char *get_command_line(void); + + int kexec_iomem_for_each_line(char *match, diff --git a/kexec-tools.changes b/kexec-tools.changes index ac27fe2..243fdee 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Oct 6 09:34:20 UTC 2015 - ptesarik@suse.com + +- kexec-tools-load-crash-kernel-high.patch: Load crash kernel high + on x86 (bsc#946365). + ------------------------------------------------------------------- Fri Jun 26 07:33:16 UTC 2015 - ptesarik@suse.cz diff --git a/kexec-tools.spec b/kexec-tools.spec index 7295527..3e833ac 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -38,6 +38,7 @@ Patch2: %{name}-xen-balloon-up.patch Patch3: %{name}-disable-test.patch Patch4: %{name}-enable-aarch64.patch Patch5: %{name}-enable-aarch64-fixup.patch +Patch6: %{name}-load-crash-kernel-high.patch Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -64,6 +65,7 @@ the loaded kernel after it panics. %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 %build # disable as-needed