[patch 0/6] kexec kernel efi runtime support
by Dave Young
Hi,
Here is the 1st version for supporting kexec kernel efi runtime.
Per pervious discussion I pass the 1st kernel efi runtime mapping
via setup_data to 2nd kernel. Besides of the runtime mapping
info I also pass the fw_vendor, runtime, config table, smbios
physical address in setup_data. EFI spec mentioned fw_vendor,
runtime, config table addresses will be converted to virt address
after entering virtual mode, but we will use it as physical address
in efi_init. For smbios EFI spec did not mention about the address
updating, but during my test on a HP workstation, the bios will
convert it to Virt addr, thus pass it in setup_data as well.
For fw_vendor, runtime, config table, I export them in /sys/firmware/
efi/systab, smbios is already in that file.
For efi runtime mapping I add a new directory /sys/firmware/efi/
efi-runtime-map/ like below
[dave@darkstar ~]$ tree /sys/firmware/efi/efi-runtime-map/
/sys/firmware/efi/efi-runtime-map/
├── 0
│ ├── attribute
│ ├── num_pages
│ ├── phys_addr
│ ├── type
│ └── virt_addr
├── 1
│ ├── attribute
│ ├── num_pages
│ ├── phys_addr
│ ├── type
│ └── virt_addr
[snip]
kexec-tools will assemble them as setup_data and pass to 2nd kernel.
I will send userspace patches as well.
Limitation is I only write support for x86_64, test on below machines:
Lenovo thinkpad t420
Dell inspiron 14 - 3421
HP Z420 workstation
Qemu + OVMF
Please help to review the patches.
The patches are based on linus tree (3.12.0-rc6+) + matt's next tree + bp's efi mapping patches
Boris's last patch can not directly apply, need a little line shifting.
--
Thanks
Dave
10 years, 1 month
[patch 0/4] kexec-tools: efi runtime support on kexec kernel
by Dave Young
This patchset is for adding efi runtime support on kexec kernel
kernel patches see below thread:
http://thread.gmane.org/gmane.linux.kernel.efi/2491
in kexec-tools, this patchset will do below:
1. retrieve efi_info from debugfs boot_params, and fill the
x86 setup header
2. collect data efi runtime needed:
/sys/firmware/efi/systab: fw_vendor, runtime, config_tables and smbios
/sys/firmware/efi/efi-runtime-map/*, the phys-virt mappings in 1st kernel
3. assemble setup_data based on data get in 2) then pass it to 2nd kernel
Tested on OVMF, dell laptop, lenovo laptop and HP workstation
Please help to review
--
Thanks
Dave
10 years, 1 month
[PATCH] fix sadump format phys_base calculating error
by Arthur Zou
Description of Problem:
This is a REGRESSION issue.
At fedora makedumpfile has been updated toward v1.5.4. Unfortunately,
this version fails calculating phys_base on sadump format and then
fails converting vmcore.
x86_64 kernel is relocatable kernel and there can be a gap between
the physical address statically assigned to kernel data and texts
and the address that is really assigned to each object corresponding
to the kernel symbols. The gap is phys_base. makedump calculates the
phys_base in an ad-hoc way that comparing the addresses of some of
occurrences of "Linux kernel" strings in certain range of vmcore.
Resolution:
Fix patch has already been posted in upstream. so just back port.
The commit ID are:
commit e23dc0a1aa5fa7a4429f72ff1c2fe87a87291065
commit 92563d7a7a5175ef78c4a94ee269b1b455331b4c
Signed-off-by: arthur <zzou(a)redhat.com>
---
...ache-Allocate-buffers-at-initialization-t.patch | 107 ++++++++++++++++++
...umpfile-cache-Reuse-entry-in-pending-list.patch | 122 +++++++++++++++++++++
kexec-tools.spec | 4 +
3 files changed, 233 insertions(+)
create mode 100644 kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch
create mode 100644 kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch b/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch
new file mode 100644
index 0000000..f0889a6
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch
@@ -0,0 +1,107 @@
+From 92563d7a7a5175ef78c4a94ee269b1b455331b4c Mon Sep 17 00:00:00 2001
+Message-Id: <92563d7a7a5175ef78c4a94ee269b1b455331b4c.1381891355.git.zzou(a)redhat.com>
+From: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Date: Tue, 17 Sep 2013 15:29:33 +0900
+Subject: [PATCH] [PATCH 1/2] cache: Allocate buffers at initialization to
+ detect malloc() failure.
+
+malloc() is used in cache_alloc() but there's no check for it. If I
+added check in cache_alloc() directly, cache_alloc() needs to return
+one more error status and code gets somewhat complicated. Instead, I
+move malloc() in initial() to detect allocation failure at
+initialization. By this change, 8 buffers are allocated at the same
+time, no longer incrementally. However, 8 buffers are almost always
+used throughout execution. There's essential differnece from the
+incremental one.
+
+Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Signed-off-by: arthur <zzou(a)redhat.com>
+---
+ cache.c | 29 ++++++++++++++++++++++-------
+ cache.h | 1 +
+ makedumpfile.c | 3 +++
+ 3 files changed, 26 insertions(+), 7 deletions(-)
+
+diff --git a/makedumpfile-1.5.4/cache.c b/makedumpfile-1.5.4/cache.c
+index 3bea089..dad8d80 100644
+--- a/makedumpfile-1.5.4/cache.c
++++ b/makedumpfile-1.5.4/cache.c
+@@ -18,6 +18,7 @@
+
+ #include "makedumpfile.h"
+ #include "cache.h"
++#include "print_info.h"
+
+ struct cache_entry {
+ unsigned long long paddr;
+@@ -36,6 +37,25 @@ static int avail = CACHE_SIZE;
+
+ static struct cache used, pending;
+
++int
++cache_init(void)
++{
++ void *bufptr;
++ int i;
++
++ for (i = 0; i < CACHE_SIZE; ++i) {
++ bufptr = malloc(info->page_size);
++ if (bufptr == NULL) {
++ ERRMSG("Can't allocate memory for cache. %s\n",
++ strerror(errno));
++ return FALSE;
++ }
++ pool[i].bufptr = bufptr;
++ }
++
++ return TRUE;
++}
++
+ static void
+ add_entry(struct cache *cache, struct cache_entry *entry)
+ {
+@@ -83,13 +103,8 @@ cache_alloc(unsigned long long paddr)
+ {
+ struct cache_entry *entry = NULL;
+
+- if (avail) {
+- void *bufptr = malloc(info->page_size);
+- if (bufptr) {
+- entry = &pool[--avail];
+- entry->bufptr = bufptr;
+- }
+- }
++ if (avail)
++ entry = &pool[--avail];
+
+ if (!entry) {
+ if (used.tail) {
+diff --git a/makedumpfile-1.5.4/cache.h b/makedumpfile-1.5.4/cache.h
+index f37d883..4730e12 100644
+--- a/makedumpfile-1.5.4/cache.h
++++ b/makedumpfile-1.5.4/cache.h
+@@ -19,6 +19,7 @@
+ #ifndef _CACHE_H
+ #define _CACHE_H
+
++int cache_init(void);
+ void *cache_search(unsigned long long paddr);
+ void *cache_alloc(unsigned long long paddr);
+ void cache_add(unsigned long long paddr);
+diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
+index 1718f88..e01ff50 100644
+--- a/makedumpfile-1.5.4/makedumpfile.c
++++ b/makedumpfile-1.5.4/makedumpfile.c
+@@ -3017,6 +3017,9 @@ out:
+ DEBUG_MSG("Buffer size for the cyclic mode: %ld\n", info->bufsize_cyclic);
+ }
+
++ if (!cache_init())
++ return FALSE;
++
+ if (debug_info) {
+ if (info->flag_sadump)
+ (void) sadump_virt_phys_base();
+--
+1.8.3.1
+
diff --git a/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch b/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch
new file mode 100644
index 0000000..bc58c94
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch
@@ -0,0 +1,122 @@
+From e23dc0a1aa5fa7a4429f72ff1c2fe87a87291065 Mon Sep 17 00:00:00 2001
+Message-Id: <e23dc0a1aa5fa7a4429f72ff1c2fe87a87291065.1381891368.git.zzou(a)redhat.com>
+From: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Date: Tue, 17 Sep 2013 15:29:38 +0900
+Subject: [PATCH] [PATCH 2/2] cache: Reuse entry in pending list.
+
+Currently, sadump_virt_phys_base() fails to calculate phys_base as
+below:
+
+$ /pub/repos/makedumpfile/makedumpfile -f -p -d 31 -x /pub3/vmcores/comparevmcore_data/vmlinux-2.6.18-363.el5 /pub3/vmcores/comparevmcore_data/vmcore-2.6.18-363.el5-sadump /pub3/vmcores/comparevmcore_data/vmcore-pd31
+Switched running mode from cyclic to non-cyclic,
+because the cyclic mode doesn't support sadump format.
+readmem: type_addr: 1, addr:296020, size:13
+readmem: type_addr: 1, addr:ffffffffff296020, size:13
+readmem: type_addr: 1, addr:ffffffffff396020, size:13
+readmem: type_addr: 1, addr:ffffffffff496020, size:13
+readmem: type_addr: 1, addr:ffffffffff596020, size:13
+readmem: type_addr: 1, addr:ffffffffff696020, size:13
+readmem: type_addr: 1, addr:ffffffffff796020, size:13
+readmem: type_addr: 1, addr:ffffffffff896020, size:13
+readmem: type_addr: 1, addr:ffffffffff996020, size:13
+readmem: type_addr: 1, addr:ffffffffffa96020, size:13
+readmem: type_addr: 1, addr:ffffffffffb96020, size:13
+readmem: type_addr: 1, addr:ffffffffffc96020, size:13
+readmem: type_addr: 1, addr:ffffffffffd96020, size:13
+readmem: type_addr: 1, addr:ffffffffffe96020, size:13
+readmem: type_addr: 1, addr:fffffffffff96020, size:13
+readmem: type_addr: 1, addr:96020, size:13
+readmem: type_addr: 1, addr:196020, size:13
+readmem: type_addr: 1, addr:296020, size:13
+readmem: type_addr: 1, addr:396020, size:13
+readmem: type_addr: 1, addr:496020, size:13
+readmem: type_addr: 1, addr:596020, size:13
+readmem: type_addr: 1, addr:696020, size:13
+readmem: type_addr: 1, addr:796020, size:13
+readmem: type_addr: 1, addr:896020, size:13
+readmem: type_addr: 1, addr:996020, size:13
+readmem: type_addr: 1, addr:a96020, size:13
+readmem: type_addr: 1, addr:b96020, size:13
+readmem: type_addr: 1, addr:c96020, size:13
+readmem: type_addr: 1, addr:d96020, size:13
+readmem: type_addr: 1, addr:e96020, size:13
+readmem: type_addr: 1, addr:f96020, size:13
+readmem: type_addr: 1, addr:1096020, size:13
+readmem: type_addr: 1, addr:1196020, size:13
+readmem: type_addr: 1, addr:1296020, size:13
+readmem: type_addr: 0, addr:ffffffff8045e260, size:32
+cpu_online_mask_init: Can't read cpu_online_mask memory.
+
+makedumpfile Failed.
+
+By git bisect, I found this bug is caused by the following commit:
+
+commit 0aff0e5174d0708bf1bfb039ab863e1fea8a1029
+Author: Petr Tesarik <ptesarik(a)suse.cz>
+Date: Wed Oct 31 16:12:47 2012 +0900
+
+ [PATCH] keep dumpfile pages in a cache.
+
+Then, I found this bug happens in the following senario.
+
+If one of the readpage_xxx() methods fails reading 8 pages in a row, 8
+entries in pool are fully contained in pending list. Then,
+cache_alloc() returns NULL and this continues forever in the
+execution. In other words, there's assumption in cache_alloc() that if
+pool is fully used, they are fully in used list, not in pending list
+at all. However, the buggy path here breaks the assumption. This patch
+changes cache_alloc() so that it first tries to reuse enty in pending
+list if exists.
+
+In fact, I found this bug in ad-hoc phys_base calculation performed in
+sadump_virt_phys_base(). However, I fixed cache side since this bug
+can occur in general on every vmcore format. Crash dump can contain
+broken data in any part of vmcore and so requested physical address to
+read can be broken likewise.
+
+Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Signed-off-by: arthur <zzou(a)redhat.com>
+---
+ cache.c | 25 +++++++++++++------------
+ 1 file changed, 13 insertions(+), 12 deletions(-)
+
+diff --git a/makedumpfile-1.5.4/cache.c b/makedumpfile-1.5.4/cache.c
+index dad8d80..0dd957c 100644
+--- a/makedumpfile-1.5.4/cache.c
++++ b/makedumpfile-1.5.4/cache.c
+@@ -103,19 +103,20 @@ cache_alloc(unsigned long long paddr)
+ {
+ struct cache_entry *entry = NULL;
+
+- if (avail)
++ if (avail) {
+ entry = &pool[--avail];
+-
+- if (!entry) {
+- if (used.tail) {
+- entry = used.tail;
+- remove_entry(&used, entry);
+- } else
+- return NULL;
+- }
+-
+- entry->paddr = paddr;
+- add_entry(&pending, entry);
++ entry->paddr = paddr;
++ add_entry(&pending, entry);
++ } else if (pending.tail) {
++ entry = pending.tail;
++ entry->paddr = paddr;
++ } else if (used.tail) {
++ entry = used.tail;
++ remove_entry(&used, entry);
++ entry->paddr = paddr;
++ add_entry(&pending, entry);
++ } else
++ return NULL;
+
+ return entry->bufptr;
+ }
+--
+1.8.3.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 34f1e69..f1538f6 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -82,6 +82,8 @@ Patch301: kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-p
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch
Patch605: kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch
+Patch606: kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch
+Patch607: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -117,6 +119,8 @@ tar -z -x -v -f %{SOURCE19}
%patch001 -p1
%patch002 -p1
%patch003 -p1
+%patch606 -p1
+%patch607 -p1
tar -z -x -v -f %{SOURCE13}
--
1.8.3.1
10 years, 1 month
Fwd: Your message to kexec awaits moderator approval
by Dave Young
Hi, Vivek
I remember I have subscribed to it. I wonder if there's an config
option to make the list a real public list (not subscriber only)
so we can safely cc it when we post patches to upstream.
I really do not want to add subscriber only list to cc because it's
annoying.
----- Forwarded message from kexec-bounces(a)lists.fedoraproject.org -----
> Date: Mon, 28 Oct 2013 01:25:43 +0000
> From: kexec-bounces(a)lists.fedoraproject.org
> To: dyoung(a)redhat.com
> Subject: Your message to kexec awaits moderator approval
>
> Your mail to 'kexec' with the subject
>
> Re: [patch 1/6] Add function efi_remap_region for remapping to
> saved virt address
>
> Is being held until the list moderator can review it for approval.
>
> The reason it is being held:
>
> Too many recipients to the message
>
> Either the message will get posted to the list, or you will receive
> notification of the moderator's decision. If you would like to cancel
> this posting, please visit the following URL:
>
> https://lists.fedoraproject.org/mailman/confirm/kexec/477860dc50cff252188...
>
----- End forwarded message -----
10 years, 1 month
[PATCH] Fix max_mapnr issue on system has over 44-bit addressing.
by Baoquan He
The dumpfile header has this field, which was inherited from
the old "diskdump" facility:
struct disk_dump_header {
...
unsigned int max_mapnr; /* = max_mapnr */
...
and which, among other things, is used by the crash utility as a
delimiter to determine whether a physical address read request is
legitimate. And obviously the field cannot handle PFN values greater
than 32-bits.
The makedumpfile source code does have its own max_mapnr representation
in its DumpInfo structure in "makedumpfile.h":
struct DumpInfo {
...
unsigned long long max_mapnr; /* number of page descriptor */
...
But in its "diskdump_mod.h" file, it carries forward the old diskdump
header format, which has the 32-bit field:
struct disk_dump_header {
...
unsigned int max_mapnr; /* = max_mapnr */
...
And here in "makedumpfile.c", the inadvertent truncation occurs
when the PFN is greater than 32-bits:
int
write_kdump_header(void)
{
...
dh->max_mapnr = info->max_mapnr;
...
Now upstream has below commit to fix this, back port it:
commit 8e124174b62376b17ac909bc68622ef07bde6840
Author: Jingbai Ma <jingbai.ma(a)hp.com>
Date: Fri Oct 18 18:53:38 2013 +0900
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
...x-max_mapnr-issue-on-system-has-over-44-b.patch | 329 +++++++++++++++++++++
kexec-tools.spec | 2 +
2 files changed, 331 insertions(+)
create mode 100644 kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch b/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch
new file mode 100644
index 0000000..fee9cb8
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch
@@ -0,0 +1,329 @@
+From 8e124174b62376b17ac909bc68622ef07bde6840 Mon Sep 17 00:00:00 2001
+Message-Id: <8e124174b62376b17ac909bc68622ef07bde6840.1382323707.git.bhe(a)redhat.com>
+From: Jingbai Ma <jingbai.ma(a)hp.com>
+Date: Fri, 18 Oct 2013 18:53:38 +0900
+Subject: [PATCH] [PATCH v4] Fix max_mapnr issue on system has over 44-bit
+ addressing.
+
+This patch will fix a bug of makedumpfile doesn't work correctly on system
+has over 44-bit addressing in compression dump mode.
+This bug was posted here:
+http://lists.infradead.org/pipermail/kexec/2013-September/009587.html
+
+This patch will add 3 new fields in struct kdump_sub_header.
+unsigned long long start_pfn_64; /* header_version 6 and later */
+unsigned long long end_pfn_64; /* header_version 6 and later */
+unsigned long long max_mapnr_64; /* header_version 6 and later */
+
+And the old "unsigned int max_mapnr" in struct disk_dump_header will
+not be used anymore, but still be there for compatibility purpose.
+
+The max_mapnr_64 only exists in strcut kdump_sub_header, and that only
+for compressed kdump format, so for ELF format kdump files (non-compressed),
+only the max_mapnr is available, so it still may be truncated for addresses
+exceed 44bit (above 16TB).
+
+This patch will change the header_version to 6.
+
+The corresponding patch for crash utility can be found here:
+http://lists.infradead.org/pipermail/kexec/2013-October/009750.html
+
+This patch doesn't change sadump_header.
+
+Changelog:
+v4:
+- Do not change max_mapnr_64 in kdump_sub_header in memory for old kernel.
+
+v3:
+- Change notes for max_mapnr, start_pfn and end_pfn as obsolete.
+- Remove "(32bit)" from debug messages of max_mapnr, start_pfn and end_pfn.
+- Set the 32bit start_pfn and end_pfn to UINT_MAX.
+- Remove bitmap writting enhancement to another seperate patch.
+- Change type of len_bitmap in struct DumpInfo back to unsigned long.
+
+v2:
+- Rename max_mapnr in struct kdump_sub_header to max_mapnr_64.
+- Change type of max_mapnr_64 from unsigned long to unsigned long long.
+ In x86 PAE mode on x86_32 kernel, the address may exceeds 44bit limit.
+- Add start_pfn_64, end_pfn_64 for struct kdump_sub_header.
+- Only print 64bit start_pfn_64, end_pfn_64 and max_mapnr_64
+ debug messages for disk dump header version >= 6.
+- Change type of bitmap_len in struct DumpInfo, from unsigned long to
+ unsigned long long.
+- Enhance bitmap writting function in reassemble_kdump_header().
+ Prevent bitmap writting failure if the size of bitmap is too large to
+ fit a sigle write.
+
+v1:
+- http://lists.infradead.org/pipermail/kexec/2013-September/009662.html
+
+Signed-off-by: Jingbai Ma <jingbai.ma(a)hp.com>
+Tested-by: Lisa Mitchell <lisa.mitchell(a)hp.com>
+---
+ IMPLEMENTATION | 15 ++++++++++---
+ diskdump_mod.h | 15 ++++++++++---
+ makedumpfile.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------------
+ 3 files changed, 77 insertions(+), 20 deletions(-)
+
+diff --git a/makedumpfile-1.5.4/IMPLEMENTATION b/makedumpfile-1.5.4/IMPLEMENTATION
+index f0f3135..2f4cfd6 100644
+--- a/makedumpfile-1.5.4/IMPLEMENTATION
++++ b/makedumpfile-1.5.4/IMPLEMENTATION
+@@ -48,7 +48,9 @@
+ header in blocks */
+ unsigned int bitmap_blocks; /* Size of Memory bitmap in
+ block */
+- unsigned int max_mapnr; /* = max_mapnr */
++ unsigned int max_mapnr; /* = max_mapnr, OBSOLETE!
++ 32bit only, full 64bit
++ in sub header. */
+ unsigned int total_ram_blocks;/* Number of blocks should be
+ written */
+ unsigned int device_blocks; /* Number of total blocks in
+@@ -69,14 +71,21 @@
+ unsigned long phys_base;
+ int dump_level; /* header_version 1 and later */
+ int split; /* header_version 2 and later */
+- unsigned long start_pfn; /* header_version 2 and later */
+- unsigned long end_pfn; /* header_version 2 and later */
++ unsigned long start_pfn; /* header_version 2 and later,
++ OBSOLETE! 32bit only, full
++ 64bit in start_pfn_64. */
++ unsigned long end_pfn; /* header_version 2 and later,
++ OBSOLETE! 32bit only, full
++ 64bit in end_pfn_64. */
+ off_t offset_vmcoreinfo;/* header_version 3 and later */
+ unsigned long size_vmcoreinfo; /* header_version 3 and later */
+ off_t offset_note; /* header_version 4 and later */
+ unsigned long size_note; /* header_version 4 and later */
+ off_t offset_eraseinfo; /* header_version 5 and later */
+ unsigned long size_eraseinfo; /* header_version 5 and later */
++ unsigned long long start_pfn_64; /* header_version 6 and later */
++ unsigned long long end_pfn_64; /* header_version 6 and later */
++ unsigned long long max_mapnr_64; /* header_version 6 and later */
+ };
+
+ - 1st-bitmap
+diff --git a/makedumpfile-1.5.4/diskdump_mod.h b/makedumpfile-1.5.4/diskdump_mod.h
+index 00ab852..dd24eb2 100644
+--- a/makedumpfile-1.5.4/diskdump_mod.h
++++ b/makedumpfile-1.5.4/diskdump_mod.h
+@@ -52,7 +52,9 @@ struct disk_dump_header {
+ header in blocks */
+ unsigned int bitmap_blocks; /* Size of Memory bitmap in
+ block */
+- unsigned int max_mapnr; /* = max_mapnr */
++ unsigned int max_mapnr; /* = max_mapnr, OBSOLETE!
++ 32bit only, full 64bit
++ in sub header. */
+ unsigned int total_ram_blocks;/* Number of blocks should be
+ written */
+ unsigned int device_blocks; /* Number of total blocks in
+@@ -71,14 +73,21 @@ struct kdump_sub_header {
+ unsigned long phys_base;
+ int dump_level; /* header_version 1 and later */
+ int split; /* header_version 2 and later */
+- unsigned long start_pfn; /* header_version 2 and later */
+- unsigned long end_pfn; /* header_version 2 and later */
++ unsigned long start_pfn; /* header_version 2 and later,
++ OBSOLETE! 32bit only, full
++ 64bit in start_pfn_64. */
++ unsigned long end_pfn; /* header_version 2 and later,
++ OBSOLETE! 32bit only, full
++ 64bit in end_pfn_64. */
+ off_t offset_vmcoreinfo;/* header_version 3 and later */
+ unsigned long size_vmcoreinfo; /* header_version 3 and later */
+ off_t offset_note; /* header_version 4 and later */
+ unsigned long size_note; /* header_version 4 and later */
+ off_t offset_eraseinfo; /* header_version 5 and later */
+ unsigned long size_eraseinfo; /* header_version 5 and later */
++ unsigned long long start_pfn_64; /* header_version 6 and later */
++ unsigned long long end_pfn_64; /* header_version 6 and later */
++ unsigned long long max_mapnr_64; /* header_version 6 and later */
+ };
+
+ /* page flags */
+diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
+index 9892108..428c53e 100644
+--- a/makedumpfile-1.5.4/makedumpfile.c
++++ b/makedumpfile-1.5.4/makedumpfile.c
+@@ -23,6 +23,7 @@
+ #include <stddef.h>
+ #include <ctype.h>
+ #include <sys/time.h>
++#include <limits.h>
+
+ struct symbol_table symbol_table;
+ struct size_table size_table;
+@@ -125,7 +126,10 @@ get_max_mapnr(void)
+ unsigned long long max_paddr;
+
+ if (info->flag_refiltering) {
+- info->max_mapnr = info->dh_memory->max_mapnr;
++ if (info->dh_memory->header_version >= 6)
++ info->max_mapnr = info->kh_memory->max_mapnr_64;
++ else
++ info->max_mapnr = info->dh_memory->max_mapnr;
+ return TRUE;
+ }
+
+@@ -802,6 +806,12 @@ get_kdump_compressed_header_info(char *filename)
+ DEBUG_MSG(" split : %d\n", kh.split);
+ DEBUG_MSG(" start_pfn : 0x%lx\n", kh.start_pfn);
+ DEBUG_MSG(" end_pfn : 0x%lx\n", kh.end_pfn);
++ if (dh.header_version >= 6) {
++ /* A dumpfile contains full 64bit values. */
++ DEBUG_MSG(" start_pfn_64 : 0x%llx\n", kh.start_pfn_64);
++ DEBUG_MSG(" end_pfn_64 : 0x%llx\n", kh.end_pfn_64);
++ DEBUG_MSG(" max_mapnr_64 : 0x%llx\n", kh.max_mapnr_64);
++ }
+
+ info->dh_memory = malloc(sizeof(dh));
+ if (info->dh_memory == NULL) {
+@@ -2799,14 +2809,16 @@ int
+ initialize_bitmap_memory(void)
+ {
+ struct disk_dump_header *dh;
++ struct kdump_sub_header *kh;
+ struct dump_bitmap *bmp;
+ off_t bitmap_offset;
+- int bitmap_len, max_sect_len;
++ off_t bitmap_len, max_sect_len;
+ unsigned long pfn;
+ int i, j;
+ long block_size;
+
+ dh = info->dh_memory;
++ kh = info->kh_memory;
+ block_size = dh->block_size;
+
+ bitmap_offset
+@@ -2826,7 +2838,10 @@ initialize_bitmap_memory(void)
+ bmp->offset = bitmap_offset + bitmap_len / 2;
+ info->bitmap_memory = bmp;
+
+- max_sect_len = divideup(dh->max_mapnr, BITMAP_SECT_LEN);
++ if (dh->header_version >= 6)
++ max_sect_len = divideup(kh->max_mapnr_64, BITMAP_SECT_LEN);
++ else
++ max_sect_len = divideup(dh->max_mapnr, BITMAP_SECT_LEN);
+ info->valid_pages = calloc(sizeof(ulong), max_sect_len);
+ if (info->valid_pages == NULL) {
+ ERRMSG("Can't allocate memory for the valid_pages. %s\n",
+@@ -4743,7 +4758,7 @@ create_2nd_bitmap(void)
+ int
+ prepare_bitmap_buffer(void)
+ {
+- unsigned long tmp;
++ unsigned long long tmp;
+
+ /*
+ * Create 2 bitmaps (1st-bitmap & 2nd-bitmap) on block_size boundary.
+@@ -4775,7 +4790,7 @@ prepare_bitmap_buffer(void)
+ int
+ prepare_bitmap_buffer_cyclic(void)
+ {
+- unsigned long tmp;
++ unsigned long long tmp;
+
+ /*
+ * Create 2 bitmaps (1st-bitmap & 2nd-bitmap) on block_size boundary.
+@@ -5190,11 +5205,12 @@ write_kdump_header(void)
+ * Write common header
+ */
+ strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
+- dh->header_version = 5;
++ dh->header_version = 6;
+ dh->block_size = info->page_size;
+ dh->sub_hdr_size = sizeof(kh) + size_note;
+ dh->sub_hdr_size = divideup(dh->sub_hdr_size, dh->block_size);
+- dh->max_mapnr = info->max_mapnr;
++ /* dh->max_mapnr may be truncated, full 64bit in kh.max_mapnr_64 */
++ dh->max_mapnr = MIN(info->max_mapnr, UINT_MAX);
+ dh->nr_cpus = get_nr_cpus();
+ dh->bitmap_blocks = divideup(info->len_bitmap, dh->block_size);
+ memcpy(&dh->timestamp, &info->timestamp, sizeof(dh->timestamp));
+@@ -5219,12 +5235,22 @@ write_kdump_header(void)
+ */
+ size = sizeof(struct kdump_sub_header);
+ memset(&kh, 0, size);
++ /* 64bit max_mapnr_64 */
++ kh.max_mapnr_64 = info->max_mapnr;
+ kh.phys_base = info->phys_base;
+ kh.dump_level = info->dump_level;
+ if (info->flag_split) {
+ kh.split = 1;
+- kh.start_pfn = info->split_start_pfn;
+- kh.end_pfn = info->split_end_pfn;
++ /*
++ * start_pfn and end_pfn may be truncated,
++ * only for compatibility purpose
++ */
++ kh.start_pfn = MIN(info->split_start_pfn, UINT_MAX);
++ kh.end_pfn = MIN(info->split_end_pfn, UINT_MAX);
++
++ /* 64bit start_pfn_64 and end_pfn_64 */
++ kh.start_pfn_64 = info->split_start_pfn;
++ kh.end_pfn_64 = info->split_end_pfn;
+ }
+ if (has_pt_note()) {
+ /*
+@@ -6470,7 +6496,7 @@ int
+ write_kdump_bitmap(void)
+ {
+ struct cache_data bm;
+- long buf_size;
++ long long buf_size;
+ off_t offset;
+
+ int ret = FALSE;
+@@ -7853,10 +7879,8 @@ store_splitting_info(void)
+
+ if (i == 0) {
+ memcpy(&dh, &tmp_dh, sizeof(tmp_dh));
+- info->max_mapnr = dh.max_mapnr;
+ if (!set_page_size(dh.block_size))
+ return FALSE;
+- DEBUG_MSG("max_mapnr : %llx\n", info->max_mapnr);
+ DEBUG_MSG("page_size : %ld\n", info->page_size);
+ }
+
+@@ -7873,11 +7897,24 @@ store_splitting_info(void)
+ return FALSE;
+
+ if (i == 0) {
++ if (dh.header_version >= 6)
++ info->max_mapnr = kh.max_mapnr_64;
++ else
++ info->max_mapnr = dh.max_mapnr;
++
++ DEBUG_MSG("max_mapnr : %llx\n", info->max_mapnr);
++
+ info->dump_level = kh.dump_level;
+ DEBUG_MSG("dump_level : %d\n", info->dump_level);
+ }
+- SPLITTING_START_PFN(i) = kh.start_pfn;
+- SPLITTING_END_PFN(i) = kh.end_pfn;
++
++ if (dh.header_version >= 6) {
++ SPLITTING_START_PFN(i) = kh.start_pfn_64;
++ SPLITTING_END_PFN(i) = kh.end_pfn_64;
++ } else {
++ SPLITTING_START_PFN(i) = kh.start_pfn;
++ SPLITTING_END_PFN(i) = kh.end_pfn;
++ }
+ SPLITTING_OFFSET_EI(i) = kh.offset_eraseinfo;
+ SPLITTING_SIZE_EI(i) = kh.size_eraseinfo;
+ }
+@@ -8039,6 +8076,8 @@ reassemble_kdump_header(void)
+ kh.split = 0;
+ kh.start_pfn = 0;
+ kh.end_pfn = 0;
++ kh.start_pfn_64 = 0;
++ kh.end_pfn_64 = 0;
+
+ if (lseek(info->fd_dumpfile, info->page_size, SEEK_SET) < 0) {
+ ERRMSG("Can't seek a file(%s). %s\n",
+--
+1.8.3.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 73098bb..513537a 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -82,6 +82,7 @@ Patch301: kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-p
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch
Patch605: kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch
+Patch606: kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -114,6 +115,7 @@ tar -z -x -v -f %{SOURCE19}
%patch601 -p1
%patch604 -p1
%patch605 -p1
+%patch606 -p1
%patch001 -p1
%patch002 -p1
%patch003 -p1
--
1.8.3.1
10 years, 1 month
[PATCH] makedumpfile: wrong cyclic buffer size recalculation causes bitmap data corruption
by Baoquan He
Description of Problem:
In cyclic mode, makedumpfile recalculates cyclic buffer size as the
largest multiple of the largest block size managed by buddy
allocator, i.e. 4MB, smaller than the cyclic buffer size in order to
enable to process each unit of blocks managed by buddy allocator in
each cycle.
However, makedumpfile does two wrong things in the recalculations:
1) While updating size of cyclic buffer, makedumpfile doesn't update
length of range of cycle in page frame numbers, due to which, if
cyclic buffer size is updated, because cyclic buffer size is always
reduced during udpate, some buffer overrun can happen on the cyclic
buffer. This can cause segmentation violation in the worst case.
2) roundup() is used to calculate bitmap size for maximum block size
managed by buddy allocator, here divideup() is correct, due to
which, although memory filtering is not affected, cyclic buffer size
get too much aligned and less efficient.
Fix patches has already been posted and merged in makedumpfile
development devel branch.
git://git.code.sf.net/p/makedumpfile/code
f8c8218856effc43ea01cd9394761cfb8aeaa8df
a785fa7dd7a7bd7dcbb017d0bea8848243b0924f
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
...e-pfn_cyclic-when-the-cyclic-buffer-size-.patch | 34 ++++++++++++++++
...ivideup-to-calculate-maximum-required-bit.patch | 45 ++++++++++++++++++++++
kexec-tools.spec | 4 ++
3 files changed, 83 insertions(+)
create mode 100644 kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch
create mode 100644 kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch
diff --git a/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch b/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch
new file mode 100644
index 0000000..dc5bde4
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch
@@ -0,0 +1,34 @@
+From a785fa7dd7a7bd7dcbb017d0bea8848243b0924f Mon Sep 17 00:00:00 2001
+Message-Id: <a785fa7dd7a7bd7dcbb017d0bea8848243b0924f.1382423400.git.bhe(a)redhat.com>
+From: Atsushi Kumagai <kumagai-atsushi(a)mxc.nes.nec.co.jp>
+Date: Thu, 12 Sep 2013 08:31:28 +0900
+Subject: [PATCH 1/2] [PATCH] Update pfn_cyclic when the cyclic buffer size is
+ corrected.
+
+When the clearing bit operation for excluding free pages can overrun
+the cyclic buffer, the buffer size is changed with
+check_cyclic_buffer_overrun().
+Then pfn_cyclic should be recalculated.
+
+Reviewed-by: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Signed-off-by: Atsushi Kumagai <kumagai-atsushi(a)mxc.nes.nec.co.jp>
+Signed-off-by: Baoquan He <bhe(a)redhat.com>
+---
+ makedumpfile.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
+index 09c0d4a..164b3f1 100644
+--- a/makedumpfile-1.5.4/makedumpfile.c
++++ b/makedumpfile-1.5.4/makedumpfile.c
+@@ -4091,6 +4091,7 @@ check_cyclic_buffer_overrun(void)
+
+ bufsize = info->bufsize_cyclic;
+ info->bufsize_cyclic = round(bufsize, max_block_size);
++ info->pfn_cyclic = info->bufsize_cyclic * BITPERBYTE;
+
+ MSG("cyclic buffer size has been changed: %lu => %lu\n",
+ bufsize, info->bufsize_cyclic);
+--
+1.8.3.1
+
diff --git a/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch b/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch
new file mode 100644
index 0000000..e2e2b49
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch
@@ -0,0 +1,45 @@
+From f8c8218856effc43ea01cd9394761cfb8aeaa8df Mon Sep 17 00:00:00 2001
+Message-Id: <f8c8218856effc43ea01cd9394761cfb8aeaa8df.1382423400.git.bhe(a)redhat.com>
+In-Reply-To: <a785fa7dd7a7bd7dcbb017d0bea8848243b0924f.1382423400.git.bhe(a)redhat.com>
+References: <a785fa7dd7a7bd7dcbb017d0bea8848243b0924f.1382423400.git.bhe(a)redhat.com>
+From: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Date: Thu, 12 Sep 2013 13:19:00 +0900
+Subject: [PATCH 2/2] [PATCH] Use divideup() to calculate maximum required
+ bitmap size.
+
+Currently, check_cyclic_buffer_overrun() wrongly calculates maximum
+bitmap size required to represent maximum block size managed by buddy
+allocator with roundup(). Then, max_block_size is BITPERBYTE-time
+larger than its correct size. As a result, although the bug never
+affect free-page filtering since roundup(max_order_nr_pages,
+BITPERBYTE) is a multiple of divideup(max_order_nr_pages, BITPERBYTE),
+the following sanity check, (max_block_size > info->bufsize_cyclic),
+and recalculation of info->bufsize_cyclic becomes BITPERBYTE-time
+conservative and inefficient.
+
+Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com>
+Signed-off-by: Baoquan He <bhe(a)redhat.com>
+---
+ makedumpfile.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
+index 164b3f1..1718f88 100644
+--- a/makedumpfile-1.5.4/makedumpfile.c
++++ b/makedumpfile-1.5.4/makedumpfile.c
+@@ -4078,10 +4078,9 @@ check_cyclic_buffer_overrun(void)
+ {
+ int max_order = ARRAY_LENGTH(zone.free_area);
+ int max_order_nr_pages = 1 << (max_order - 1);
+- unsigned long max_block_size = roundup(max_order_nr_pages, BITPERBYTE);
++ unsigned long max_block_size = divideup(max_order_nr_pages, BITPERBYTE);
+
+- if (info->bufsize_cyclic %
+- roundup(max_order_nr_pages, BITPERBYTE)) {
++ if (info->bufsize_cyclic % max_block_size) {
+ unsigned long bufsize;
+
+ if (max_block_size > info->bufsize_cyclic) {
+--
+1.8.3.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 513537a..b1b9e68 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -82,6 +82,8 @@ Patch301: kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-p
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch
Patch605: kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch
+Patch606: kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch
+Patch607: kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch
Patch606: kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch
%description
@@ -116,6 +118,8 @@ tar -z -x -v -f %{SOURCE19}
%patch604 -p1
%patch605 -p1
%patch606 -p1
+%patch607 -p1
+%patch606 -p1
%patch001 -p1
%patch002 -p1
%patch003 -p1
--
1.8.3.1
10 years, 1 month
[PATCH] remove the selinux filpping code in propagate_ssh_key
by Arthur Zou
Resolves bz971279
description of problem:
Previously with selinux in enforcing mode, could prevent ssh-keygen
from generating keys. Support for selinux policy for allowing applications to
access ssh-keygen for generating ssh keys was added with
selinux-policy-3.7.19-126.el6_2.6 and RHEL 6.3 ships
selinux-policy-targeted-3.7.19-142.el6 which already has the
support for ssh_keygen_t.
Solutions:
Because of the context was added for ssh key generation,
so the keys were generated without fliping from enforcing mode to
permissive mode for ssh key generation. This patch removes selinux code which
switches between enforcing and permissive modes.
Signed-off-by: arthur <zzou(a)redhat.com>
---
kdumpctl | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 358ef05..b626f61 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -317,13 +317,6 @@ function propagate_ssh_key()
exit 1
fi
- #Check if selinux is on... must flip to permissive mode
- #for the moment to create key, then flip back...
- se_enforce=`/usr/sbin/sestatus | grep -c "^Current mode.*enforcing"`
- if [ "$se_enforce" -ge 1 ]; then
- /usr/sbin/setenforce 0 2>&1 > /dev/null
- fi
-
local KEYFILE=$SSH_KEY_LOCATION
local errmsg="Failed to propagate ssh key"
@@ -335,11 +328,6 @@ function propagate_ssh_key()
/usr/bin/ssh-keygen -t rsa -f $KEYFILE -N "" 2>&1 > /dev/null
echo "done."
fi
-
- #If necessary, flip selinux back to enforcing
- if [ "$se_enforce" -ge 1 ]; then
- /usr/sbin/setenforce 1 2>&1 > /dev/null
- fi
#now find the target ssh user and server to contact.
SSH_USER=`echo $DUMP_TARGET | cut -d\ -f2 | cut -d@ -f1`
--
1.8.3.1
10 years, 1 month
[PATCH] kdump, x86: Process multiple Crash kernel in /proc/iomem
by WANG Chao
Resolves: bz1018104
Boot with "crashkernel=128M,high", kernel now uses "Crash kernel" in
/proc/iomem for crash kernel memory reservations at both low and high:
commit 157752d
Author: Yinghai Lu <yinghai(a)kernel.org>
kexec: use Crash kernel for Crash kernel low
But kexec is still scanning for "Crash kernel low" in /proc/iomem, and
will fail immediately when load/unload crash kernel.
So let's pull the following commit from kexec upstream to make
it compatible with our kernel:
commit e25e6e7
Author: Yinghai Lu <yinghai(a)kernel.org>
kdump, x86: Process multiple Crash kernel in /proc/iomem
(This patch from upstream is untouched and can be applied cleanly)
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
...rocess-multiple-Crash-kernel-in-proc-iome.patch | 230 +++++++++++++++++++++
kexec-tools.spec | 2 +
2 files changed, 232 insertions(+)
create mode 100644 kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch
diff --git a/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch b/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch
new file mode 100644
index 0000000..9e2fb41
--- /dev/null
+++ b/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch
@@ -0,0 +1,230 @@
+From e25e6e7593cae350ecaa3fcd6d20c7de87f4c309 Mon Sep 17 00:00:00 2001
+From: Yinghai Lu <yinghai(a)kernel.org>
+Date: Fri, 22 Mar 2013 13:54:06 -0700
+Subject: [PATCH] kdump, x86: Process multiple Crash kernel in /proc/iomem
+
+Vivek found specical handling crashkernel low in not good.
+We should extend kexec-tools to handle multiple Crash kernel instead.
+
+Extend crash_reserved_mem to array instead and use
+kexec_iomem_for_each_line directly. After that we can drop
+crashkernel low.
+
+-v2: fix left over calling of parse_iomem_single() found by Vivek.
+
+Suggested-by: Vivek Goyal <vgoyal(a)redhat.com>
+Signed-off-by: Yinghai Lu <yinghai(a)kernel.org>
+Signed-off-by: Simon Horman <horms(a)verge.net.au>
+---
+ kexec/arch/i386/crashdump-x86.c | 107 +++++++++++++++++++++----------------
+ kexec/arch/i386/kexec-x86-common.c | 4 +-
+ kexec/kexec.h | 1 +
+ 3 files changed, 65 insertions(+), 47 deletions(-)
+
+diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
+index 9ab648b..4167e5e 100644
+--- a/kexec/arch/i386/crashdump-x86.c
++++ b/kexec/arch/i386/crashdump-x86.c
+@@ -188,9 +188,9 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);
+ static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
+
+ /* Memory region reserved for storing panic kernel and other data. */
+-static struct memory_range crash_reserved_mem;
+-/* under 4G parts */
+-static struct memory_range crash_reserved_low_mem;
++#define CRASH_RESERVED_MEM_NR 8
++static struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
++static int crash_reserved_mem_nr;
+
+ /* Reads the appropriate file and retrieves the SYSTEM RAM regions for whom to
+ * create Elf headers. Keeping it separate from get_memory_ranges() as
+@@ -207,7 +207,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
+ int kexec_flags, unsigned long lowmem_limit)
+ {
+ const char *iomem = proc_iomem();
+- int memory_ranges = 0, gart = 0;
++ int memory_ranges = 0, gart = 0, i;
+ char line[MAX_LINE];
+ FILE *fp;
+ unsigned long long start, end;
+@@ -268,29 +268,28 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
+ }
+ fclose(fp);
+ if (kexec_flags & KEXEC_PRESERVE_CONTEXT) {
+- int i;
+ for (i = 0; i < memory_ranges; i++) {
+ if (crash_memory_range[i].end > 0x0009ffff) {
+- crash_reserved_mem.start = \
++ crash_reserved_mem[0].start = \
+ crash_memory_range[i].start;
+ break;
+ }
+ }
+- if (crash_reserved_mem.start >= mem_max) {
++ if (crash_reserved_mem[0].start >= mem_max) {
+ fprintf(stderr, "Too small mem_max: 0x%llx.\n",
+ mem_max);
+ return -1;
+ }
+- crash_reserved_mem.end = mem_max;
+- crash_reserved_mem.type = RANGE_RAM;
++ crash_reserved_mem[0].end = mem_max;
++ crash_reserved_mem[0].type = RANGE_RAM;
++ crash_reserved_mem_nr = 1;
+ }
+- if (exclude_region(&memory_ranges, crash_reserved_mem.start,
+- crash_reserved_mem.end) < 0)
+- return -1;
+- if (crash_reserved_low_mem.start &&
+- exclude_region(&memory_ranges, crash_reserved_low_mem.start,
+- crash_reserved_low_mem.end) < 0)
+- return -1;
++
++ for (i = 0; i < crash_reserved_mem_nr; i++)
++ if (exclude_region(&memory_ranges, crash_reserved_mem[i].start,
++ crash_reserved_mem[i].end) < 0)
++ return -1;
++
+ if (gart) {
+ /* exclude GART region if the system has one */
+ if (exclude_region(&memory_ranges, gart_start, gart_end) < 0)
+@@ -351,9 +350,10 @@ static int get_crash_memory_ranges_xen(struct memory_range **range,
+
+ qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
+
+- if (exclude_region(ranges, crash_reserved_mem.start,
+- crash_reserved_mem.end) < 0)
+- goto err;
++ for (i = 0; i < crash_reserved_mem_nr; i++)
++ if (exclude_region(ranges, crash_reserved_mem[i].start,
++ crash_reserved_mem[i].end) < 0)
++ goto err;
+
+ ret = 0;
+
+@@ -434,9 +434,10 @@ static int get_crash_memory_ranges_xen(struct memory_range **range,
+
+ qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
+
+- if (exclude_region(ranges, crash_reserved_mem.start,
+- crash_reserved_mem.end) < 0)
+- goto err;
++ for (i = 0; i < crash_reserved_mem_nr; i++)
++ if (exclude_region(ranges, crash_reserved_mem[i].start,
++ crash_reserved_mem[i].end) < 0)
++ goto err;
+
+ ret = 0;
+
+@@ -1014,15 +1015,10 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
+ memmap_p = xmalloc(sz);
+ memset(memmap_p, 0, sz);
+ add_memmap(memmap_p, info->backup_src_start, info->backup_src_size);
+- sz = crash_reserved_mem.end - crash_reserved_mem.start +1;
+- if (add_memmap(memmap_p, crash_reserved_mem.start, sz) < 0) {
+- return ENOCRASHKERNEL;
+- }
+-
+- if (crash_reserved_low_mem.start) {
+- sz = crash_reserved_low_mem.end - crash_reserved_low_mem.start
+- +1;
+- add_memmap(memmap_p, crash_reserved_low_mem.start, sz);
++ for (i = 0; i < crash_reserved_mem_nr; i++) {
++ sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1;
++ if (add_memmap(memmap_p, crash_reserved_mem[i].start, sz) < 0)
++ return ENOCRASHKERNEL;
+ }
+
+ /* Create a backup region segment to store backup data*/
+@@ -1093,25 +1089,46 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
+ return 0;
+ }
+
+-int is_crashkernel_mem_reserved(void)
++int get_max_crash_kernel_limit(uint64_t *start, uint64_t *end)
+ {
+- uint64_t start, end;
++ int i, idx = -1;
++ unsigned long sz_max = 0, sz;
+
+- if (parse_iomem_single("Crash kernel\n", &start, &end) || start == end)
+- return 0;
++ if (!crash_reserved_mem_nr)
++ return -1;
+
+- crash_reserved_mem.start = start;
+- crash_reserved_mem.end = end;
+- crash_reserved_mem.type = RANGE_RAM;
++ 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;
++
++ return 0;
++}
+
+- /* If there is no Crash low kernel, still can go on */
+- if (parse_iomem_single("Crash kernel low\n", &start, &end) ||
+- start == end)
++static int crashkernel_mem_callback(void *UNUSED(data), int nr,
++ char *UNUSED(str),
++ unsigned long base,
++ unsigned long length)
++{
++ if (nr >= CRASH_RESERVED_MEM_NR)
+ return 1;
+
+- crash_reserved_low_mem.start = start;
+- crash_reserved_low_mem.end = end;
+- crash_reserved_low_mem.type = RANGE_RAM;
++ crash_reserved_mem[nr].start = base;
++ crash_reserved_mem[nr].end = base + length - 1;
++ crash_reserved_mem[nr].type = RANGE_RAM;
++ return 0;
++}
++
++int is_crashkernel_mem_reserved(void)
++{
++ crash_reserved_mem_nr = kexec_iomem_for_each_line("Crash kernel\n",
++ crashkernel_mem_callback, NULL);
+
+- return 1;
++ return !!crash_reserved_mem_nr;
+ }
+diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
+index 234823c..ed6c950 100644
+--- a/kexec/arch/i386/kexec-x86-common.c
++++ b/kexec/arch/i386/kexec-x86-common.c
+@@ -465,9 +465,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
+ !(kexec_flags & KEXEC_PRESERVE_CONTEXT)) {
+ uint64_t start, end;
+
+- ret = parse_iomem_single("Crash kernel\n", &start, &end);
++ ret = get_max_crash_kernel_limit(&start, &end);
+ if (ret != 0) {
+- fprintf(stderr, "parse_iomem_single failed.\n");
++ fprintf(stderr, "get_max_crash_kernel_limit failed.\n");
+ return -1;
+ }
+
+diff --git a/kexec/kexec.h b/kexec/kexec.h
+index 916a24b..5ded390 100644
+--- a/kexec/kexec.h
++++ b/kexec/kexec.h
+@@ -272,6 +272,7 @@ int arch_process_options(int argc, char **argv);
+ 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);
+ char *get_command_line(void);
+
+ int kexec_iomem_for_each_line(char *match,
+--
+1.8.3.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index a37444c..e3e6cc8 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -56,6 +56,7 @@ Obsoletes: diskdumputils netdump
#
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
#
+Patch101: kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch
#
# Patches 201 through 300 are meant for ia64 kexec-tools enablement
@@ -107,6 +108,7 @@ tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
+%patch101 -p1
%patch301 -p1
%patch601 -p1
%patch604 -p1
--
1.8.3.1
10 years, 1 month
[PATCH] autotest framework
by Arthur Zou
From: zzou <zzou(a)redhat.com>
In order to test the different kdump.config options and different test cases ,so we
create a autotest framework.By runing test.sh ,the test cases can run one by one automatically.
For more infomation ,please refer to the readme.
Signed-off-by: arthur <zzou(a)redhat.com>
---
kdump_auto_test/TEST-01_BASIC/autokdump.service | 14 ++++++
kdump_auto_test/TEST-01_BASIC/autorun.sh | 33 ++++++++++++++
kdump_auto_test/TEST-01_BASIC/inst.sh | 16 +++++++
kdump_auto_test/TEST-01_BASIC/ks.cfg | 50 +++++++++++++++++++++
kdump_auto_test/TEST-01_BASIC/modify.sh | 10 +++++
kdump_auto_test/TEST-01_BASIC/prekdump.service | 14 ++++++
kdump_auto_test/TEST-01_BASIC/test.sh | 59 +++++++++++++++++++++++++
kdump_auto_test/readme | 18 ++++++++
kdump_auto_test/test.sh | 15 +++++++
9 files changed, 229 insertions(+)
create mode 100644 kdump_auto_test/TEST-01_BASIC/autokdump.service
create mode 100755 kdump_auto_test/TEST-01_BASIC/autorun.sh
create mode 100755 kdump_auto_test/TEST-01_BASIC/inst.sh
create mode 100755 kdump_auto_test/TEST-01_BASIC/ks.cfg
create mode 100755 kdump_auto_test/TEST-01_BASIC/modify.sh
create mode 100644 kdump_auto_test/TEST-01_BASIC/prekdump.service
create mode 100755 kdump_auto_test/TEST-01_BASIC/test.sh
create mode 100755 kdump_auto_test/readme
create mode 100755 kdump_auto_test/test.sh
diff --git a/kdump_auto_test/TEST-01_BASIC/autokdump.service b/kdump_auto_test/TEST-01_BASIC/autokdump.service
new file mode 100644
index 0000000..e6ff786
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/autokdump.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=auto crash after kdump
+After=kdump.service
+
+[Service]
+Type=oneshot
+ExecStart=/mnt/autorun.sh -autotest
+RemainAfterExit=yes
+StandardOutput=tty
+TTYPath=/dev/ttyS0
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/kdump_auto_test/TEST-01_BASIC/autorun.sh b/kdump_auto_test/TEST-01_BASIC/autorun.sh
new file mode 100755
index 0000000..7aedbe9
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/autorun.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+setup()
+{
+ systemctl | grep kdump
+ echo *********************************************autorun.sh
+}
+autotest()
+{
+ if [[ `ls -A /var/crash` = "" ]]
+ then
+ echo trigger >>/mnt/log
+ echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ sync
+ echo c > /proc/sysrq-trigger
+ else
+ mv -f /var/crash /mnt
+ #rm -rf /var/crash/*
+ echo successed>>/mnt/log
+ systemctl poweroff
+ fi
+}
+
+
+case $1 in
+ -setup)
+ setup
+ ;;
+ -autotest)
+ autotest
+ ;;
+esac
+
diff --git a/kdump_auto_test/TEST-01_BASIC/inst.sh b/kdump_auto_test/TEST-01_BASIC/inst.sh
new file mode 100755
index 0000000..dbaa038
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/inst.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+domname=Fedora
+dir=`dirname $0`
+virt-install \
+ --debug \
+ --extra-args="console=tty0 console=ttyS0,115200 ks=file:/ks.cfg" \
+ --name=$domname \
+ --disk path=$dir/Fedora-19.img,size=20,cache=none \
+ --disk path=$dir/Fedora-19-extra.img,size=1,cache=none \
+ --ram 2048 \
+ --vcpus=2 \
+ --hvm \
+ --location=http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora/x86_64/os/ \
+ --nographics \
+ --force \
+ --initrd-inject=$dir/ks.cfg
diff --git a/kdump_auto_test/TEST-01_BASIC/ks.cfg b/kdump_auto_test/TEST-01_BASIC/ks.cfg
new file mode 100755
index 0000000..c166b9f
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/ks.cfg
@@ -0,0 +1,50 @@
+#version=DEVEL
+# System authorization information
+auth --enableshadow --passalgo=sha512
+
+# Use network installation
+url --url="http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora..."
+# Run the Setup Agent on first boot
+firstboot --enable
+ignoredisk --only-use=vda
+# Keyboard layouts
+keyboard --vckeymap=us --xlayouts='us'
+# System language
+lang en_US.UTF-8
+
+# Network information
+network --hostname=localhost.localdomain
+# Root password
+rootpw --iscrypted $6$PmkDe6Zv0qko0zLL$zuXIvzy7g.hh7mX5weGyngpthVvpEXMr2sQEsaBF86ilmIsr.krTbqlozx1JowUxwf6LUPA9R1j3paUfygrqQ.
+# System timezone
+timezone Etc/GMT --isUtc
+# X Window System configuration information
+xconfig --startxonboot
+# System bootloader configuration
+bootloader --location=mbr --boot-drive=vda
+autopart --type=lvm
+# Partition clearing information
+clearpart --all --initlabel --drives=vda
+
+
+%post
+mount -t ext3 /dev/vdb /mnt
+/mnt/modify.sh
+echo 'helloooo' > /log.txt
+%end
+
+%packages
+@base-x
+@core
+@dial-up
+@firefox
+@fonts
+@gnome-desktop
+@guest-desktop-agents
+@hardware-support
+@input-methods
+@multimedia
+@printing
+@standard
+%end
+reboot
diff --git a/kdump_auto_test/TEST-01_BASIC/modify.sh b/kdump_auto_test/TEST-01_BASIC/modify.sh
new file mode 100755
index 0000000..dbb8de9
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/modify.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+echo "/dev/vdb /mnt ext3 defaults 1 2" >> /etc/fstab
+grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r`
+yum -y install kexec-tools
+cp /mnt/prekdump.service /lib/systemd/system
+cp /mnt/autokdump.service /lib/systemd/system
+
+systemctl enable kdump.service
+systemctl enable prekdump.service
+systemctl enable autokdump.service
diff --git a/kdump_auto_test/TEST-01_BASIC/prekdump.service b/kdump_auto_test/TEST-01_BASIC/prekdump.service
new file mode 100644
index 0000000..7fdc0cf
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/prekdump.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=set kdump enviroment
+Before=kdump.service
+After=network.target
+
+[Service]
+Type=oneshot
+ExecStart=/mnt/autorun.sh -setup
+RemainAfterExit=yes
+StandardOutput=tty
+TTYPath=/dev/ttyS0
+
+[Install]
+WantedBy=multi-user.target
diff --git a/kdump_auto_test/TEST-01_BASIC/test.sh b/kdump_auto_test/TEST-01_BASIC/test.sh
new file mode 100755
index 0000000..2d91f8d
--- /dev/null
+++ b/kdump_auto_test/TEST-01_BASIC/test.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+#!/bin/bash
+check_root() {
+ if (( $EUID != 0 )); then
+ echo "Tests must be run as root! Please use 'sudo'."
+ exit 1
+ fi
+}
+
+check_root
+
+dir=`dirname $0`
+echo this is test for basic kdump auto test!
+
+exec 1>$dir/log
+exec 2>$dir/log.error
+
+qemu-img create $dir/Fedora-19-extra.img 1G
+yes | mkfs.ext3 $dir/Fedora-19-extra.img
+chmod 777 $dir/Fedora-19-extra.img
+
+mount -o loop $dir/Fedora-19-extra.img /mnt
+cp $dir/modify.sh /mnt
+cp $dir/autokdump.service /mnt
+cp $dir/prekdump.service /mnt
+cp $dir/autorun.sh /mnt
+cp $dir/test.sh /mnt
+umount /mnt
+
+$dir/inst.sh
+
+mount -o loop $dir/Fedora-19-extra.img /mnt
+
+cat /mnt/log | grep successed
+if [[ $? = 0 ]]
+then
+result=ok
+rm -f $dir/Fedora-19.img
+rm -f $dir/Fedora-19-extra.img
+rm -f $dir/log
+rm -f $dir/log.error
+virsh shutdown Fedora
+virsh undefine Fedora
+else
+result=failure
+virsh shutdown Fedora
+virsh undefine Fedora
+fi
+umount /mnt
+
+exec 1>&0
+exec 2>&0
+if [[ $result = "ok" ]]
+then
+echo OK!
+else
+echo FAILURE
+fi
diff --git a/kdump_auto_test/readme b/kdump_auto_test/readme
new file mode 100755
index 0000000..87b2fa6
--- /dev/null
+++ b/kdump_auto_test/readme
@@ -0,0 +1,18 @@
+ Using kdump auto test by run test.sh. It will invoke every test.sh in subdiredtory.
+ For a typical test case. There must be a autotest.sh, a modify.sh ,a test.sh and two services,
+One is prekdump.service,anther is autokdmup.service
+ test.sh run in the host .It's the controller of a test case
+ modify.sh and autorun.sh and other essential file will be copy to vdb and mount at /mnt in guest.
+ modify.sh runs at the end of installation.It's role is to modify the original system
+to make that suitable for our test case. For example ,it will install kexec-tools in qemu ,append
+crashkernel=128M in the boot parameter for the qemu ,mount vdb at /mnt automatically ,enable prekdump.service
+and autokdump.service and so on.
+
+ autorun.sh runs at the system boot up .While the system has been installed and modified
+unattendly by kickstart,System will reboot automatically.Beacuse vdb has mounted at /mnt and prekdump.service
+and autokdump.service has enabled . prekdump.service will call /mnt/autorun.sh -setup,so the function in
+autorun.sh will be executed , we use this to do something before we start kdump.service. After prekdump.servece
+and kdump.service has started ,autokdump.service start ,it will call /mnt/autorun.sh -autotest,so the
+funtion in autorun.sh will be executed.What it must do is Crash running kernel by echo c > /proc/sysrq-trigger.
+
+
diff --git a/kdump_auto_test/test.sh b/kdump_auto_test/test.sh
new file mode 100755
index 0000000..005fb6d
--- /dev/null
+++ b/kdump_auto_test/test.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+check_root() {
+ if (( $EUID != 0 )); then
+ echo "Tests must be run as root! Please use 'sudo'."
+ exit 1
+ fi
+}
+
+
+check_root
+dir=`dirname $0`
+for i in $dir/TEST-*
+do
+ $i/test.sh;
+done
--
1.8.3.1
10 years, 1 month
[Fedora Patch] kdump-lib.sh: strip_comments is not implemented correcty
by Baoquan He
In mkdumprd, strip_comments is not implemented correctly. Since arguments
passed, strip_comments only take $1 and misses others. This caused
problems. Such as below line, current code will only get "makedumpfile"
and pass it to $config_val finally, then parameters for makedumpfile
are missed.
core_collector makedumpfile -c --message-level 1 -d 31
Now modify function strip_comments.
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
kdump-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 4df5315..e73ac09 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -20,5 +20,5 @@ is_raw_dump_target()
strip_comments()
{
- echo $1 | sed -e 's/\(.*\)#.*/\1/'
+ echo $@ | sed -e 's/\(.*\)#.*/\1/'
}
--
1.8.3.1
10 years, 1 month