From 0e884997e7db280b5ebb4348ce4d198d272f372c Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 25 Nov 2021 12:50:21 +0800 Subject: [PATCH] Update to latest upstream release(crash-8.0.0) Release: crash-8.0.0-1 Resolves: rhbz#1896647 Signed-off-by: Lianbo Jiang --- .gitignore | 2 + ...-option-on-Linux-5.7-and-later-kerne.patch | 58 ------ ...ct-state-member-changes-for-kernels-.patch | 76 -------- ...64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch | 61 ------- ...rt-for-SECTION_TAINT_ZONE_DEVICE-fla.patch | 101 ----------- ...e_offset-with-VA_BITS-kernel-configu.patch | 56 ------ ...mem-n-option-to-display-NID-correctl.patch | 48 ----- ...ted-bits-to-record-the-VA-space-layo.patch | 83 --------- ...switchable-PTOV-VTOP-for-kernels-5.1.patch | 165 ------------------ crash-8.0.0_build.patch | 35 ++++ crash.spec | 39 ++--- lzo_snappy.patch | 8 +- sources | 4 +- 13 files changed, 54 insertions(+), 682 deletions(-) delete mode 100644 0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch delete mode 100644 0001-Handle-task_struct-state-member-changes-for-kernels-.patch delete mode 100644 0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch delete mode 100644 0001-memory-Add-support-for-SECTION_TAINT_ZONE_DEVICE-fla.patch delete mode 100644 0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch delete mode 100644 0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch delete mode 100644 0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch delete mode 100644 0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch create mode 100644 crash-8.0.0_build.patch diff --git a/.gitignore b/.gitignore index b1cc9ae..6822ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,6 @@ crash-5.0.6.tar.gz /crash-7.2.8.tar.gz /crash-7.2.9.tar.gz /crash-7.3.0.tar.gz +/crash-8.0.0.tar.gz /gdb-7.6.tar.gz +/gdb-10.2.tar.gz diff --git a/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch b/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch deleted file mode 100644 index fd8b759..0000000 --- a/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 647a5c33e1c94054d7b63168cd6c12901591cb77 Mon Sep 17 00:00:00 2001 -From: Lianbo Jiang -Date: Thu, 27 May 2021 18:02:11 +0800 -Subject: [PATCH] Fix for "kmem -s|-S" option on Linux 5.7 and later kernels - -Linux 5.7 and later kernels that contain kernel commit 1ad53d9fa3f6 -("slub: improve bit diffusion for freelist ptr obfuscation") changed -the calculation formula in the freelist_ptr(), which added a swab() -call to mix bits a little more. When kernel is configured with the -"CONFIG_SLAB_FREELIST_HARDENED=y", without the patch, the "kmem -s|-S" -options display wrong statistics and state whether slab objects are -in use or free and can print the following errors: - - crash> kmem -s - CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME - 87201e00 528 0 0 0 8k xfs_dqtrx - 87201f00 496 0 0 0 8k xfs_dquot - kmem: xfs_buf: slab: 37202e6e900 invalid freepointer: b844bab900001d70 - kmem: xfs_buf: slab: 3720250fd80 invalid freepointer: b8603f9400001370 - ... - -Signed-off-by: Lianbo Jiang ---- - memory.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/memory.c b/memory.c -index 8c6bbe409922..a3cf8a86728d 100644 ---- a/memory.c -+++ b/memory.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - - struct meminfo { /* general purpose memory information structure */ - ulong cache; /* used by the various memory searching/dumping */ -@@ -19336,10 +19337,14 @@ count_free_objects(struct meminfo *si, ulong freelist) - static ulong - freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr) - { -- if (VALID_MEMBER(kmem_cache_random)) -+ if (VALID_MEMBER(kmem_cache_random)) { - /* CONFIG_SLAB_FREELIST_HARDENED */ -+ -+ if (THIS_KERNEL_VERSION >= LINUX(5,7,0)) -+ ptr_addr = (sizeof(long) == 8) ? bswap_64(ptr_addr) -+ : bswap_32(ptr_addr); - return (ptr ^ si->random ^ ptr_addr); -- else -+ } else - return ptr; - } - --- -2.30.2 - diff --git a/0001-Handle-task_struct-state-member-changes-for-kernels-.patch b/0001-Handle-task_struct-state-member-changes-for-kernels-.patch deleted file mode 100644 index ef66c25..0000000 --- a/0001-Handle-task_struct-state-member-changes-for-kernels-.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 8f8314dcaad34983d1d7b8f828a9dad65ae4073d Mon Sep 17 00:00:00 2001 -From: Alexander Egorenkov -Date: Tue, 29 Jun 2021 08:39:00 +0200 -Subject: [PATCH] Handle task_struct state member changes for kernels >= - 5.14-rc1 - -Kernel commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34 ("sched: Change -task_struct::state") renamed the member state of task_struct to __state -and its type changed from long to unsigned int. Without the patch, -crash fails to start up with the following error: - - crash: invalid structure member offset: task_struct_state - FILE: task.c LINE: 5929 FUNCTION: task_state() - -Signed-off-by: Alexander Egorenkov ---- - defs.h | 1 + - symbols.c | 1 + - task.c | 10 +++++++++- - 3 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/defs.h b/defs.h -index 68d29bd28719..a3f6aa3a7ad5 100644 ---- a/defs.h -+++ b/defs.h -@@ -2300,6 +2300,7 @@ struct size_table { /* stash of commonly-used sizes */ - long printk_info; - long printk_ringbuffer; - long prb_desc; -+ long task_struct_state; - }; - - struct array_table { -diff --git a/symbols.c b/symbols.c -index 370d4c3e8ac0..af1741f44777 100644 ---- a/symbols.c -+++ b/symbols.c -@@ -10672,6 +10672,7 @@ dump_offset_table(char *spec, ulong makestruct) - SIZE(page_cache_bucket)); - fprintf(fp, " pt_regs: %ld\n", SIZE(pt_regs)); - fprintf(fp, " task_struct: %ld\n", SIZE(task_struct)); -+ fprintf(fp, " task_struct_state: %ld\n", SIZE(task_struct_state)); - fprintf(fp, " task_struct_flags: %ld\n", SIZE(task_struct_flags)); - fprintf(fp, " task_struct_policy: %ld\n", SIZE(task_struct_policy)); - fprintf(fp, " thread_info: %ld\n", SIZE(thread_info)); -diff --git a/task.c b/task.c -index 36cf259e5d7b..672b41697e75 100644 ---- a/task.c -+++ b/task.c -@@ -297,6 +297,11 @@ task_init(void) - } - - MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "state"); -+ MEMBER_SIZE_INIT(task_struct_state, "task_struct", "state"); -+ if (INVALID_MEMBER(task_struct_state)) { -+ MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "__state"); -+ MEMBER_SIZE_INIT(task_struct_state, "task_struct", "__state"); -+ } - MEMBER_OFFSET_INIT(task_struct_exit_state, "task_struct", "exit_state"); - MEMBER_OFFSET_INIT(task_struct_pid, "task_struct", "pid"); - MEMBER_OFFSET_INIT(task_struct_comm, "task_struct", "comm"); -@@ -5926,7 +5931,10 @@ task_state(ulong task) - if (!tt->last_task_read) - return 0; - -- state = ULONG(tt->task_struct + OFFSET(task_struct_state)); -+ if (SIZE(task_struct_state) == sizeof(ulong)) -+ state = ULONG(tt->task_struct + OFFSET(task_struct_state)); -+ else -+ state = UINT(tt->task_struct + OFFSET(task_struct_state)); - exit_state = VALID_MEMBER(task_struct_exit_state) ? - ULONG(tt->task_struct + OFFSET(task_struct_exit_state)) : 0; - --- -2.30.2 - diff --git a/0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch b/0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch deleted file mode 100644 index 6d91794..0000000 --- a/0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 5719afc7a40868418405a87a2711088556e68a3b Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Fri, 2 Jul 2021 10:14:21 +0800 -Subject: [PATCH 1/4] arm64: rename ARM64_PAGE_OFFSET_ACTUAL to - ARM64_FLIP_PAGE_OFFSET_ACTUAL - -Reflect the flipped layout of kernel VA, which is introduced by -kernel commit 14c127c957c1 ("arm64: mm: Flip kernel VA space"). - -Signed-off-by: Pingfan Liu ---- - arm64.c | 10 ++++++---- - defs.h | 3 ++- - 2 files changed, 8 insertions(+), 5 deletions(-) - -diff --git a/arm64.c b/arm64.c -index 8934961..9fe1a4a 100644 ---- a/arm64.c -+++ b/arm64.c -@@ -217,10 +217,12 @@ arm64_init(int when) - arm64_calc_VA_BITS(); - arm64_calc_KERNELPACMASK(); - ms = machdep->machspec; -+ -+ /* vabits_actual introduced after mm flip, so it should be flipped layout */ - if (ms->VA_BITS_ACTUAL) { -- ms->page_offset = ARM64_PAGE_OFFSET_ACTUAL; -- machdep->identity_map_base = ARM64_PAGE_OFFSET_ACTUAL; -- machdep->kvbase = ARM64_PAGE_OFFSET_ACTUAL; -+ ms->page_offset = ARM64_FLIP_PAGE_OFFSET_ACTUAL; -+ machdep->identity_map_base = ARM64_FLIP_PAGE_OFFSET_ACTUAL; -+ machdep->kvbase = ARM64_FLIP_PAGE_OFFSET_ACTUAL; - ms->userspace_top = ARM64_USERSPACE_TOP_ACTUAL; - } else { - ms->page_offset = ARM64_PAGE_OFFSET; -@@ -401,7 +403,7 @@ arm64_init(int when) - fprintf(fp, "CONFIG_ARM64_VA_BITS: %ld\n", ms->CONFIG_ARM64_VA_BITS); - fprintf(fp, " VA_BITS_ACTUAL: %ld\n", ms->VA_BITS_ACTUAL); - fprintf(fp, "(calculated) VA_BITS: %ld\n", ms->VA_BITS); -- fprintf(fp, " PAGE_OFFSET: %lx\n", ARM64_PAGE_OFFSET_ACTUAL); -+ fprintf(fp, " PAGE_OFFSET: %lx\n", ARM64_FLIP_PAGE_OFFSET_ACTUAL); - fprintf(fp, " VA_START: %lx\n", ms->VA_START); - fprintf(fp, " modules: %lx - %lx\n", ms->modules_vaddr, ms->modules_end); - fprintf(fp, " vmalloc: %lx - %lx\n", ms->vmalloc_start_addr, ms->vmalloc_end); -diff --git a/defs.h b/defs.h -index 5d32954..eb7ce6a 100644 ---- a/defs.h -+++ b/defs.h -@@ -3233,7 +3233,8 @@ typedef signed int s32; - - #define ARM64_PAGE_OFFSET ((0xffffffffffffffffUL) \ - << (machdep->machspec->VA_BITS - 1)) --#define ARM64_PAGE_OFFSET_ACTUAL ((0xffffffffffffffffUL) \ -+/* kernels >= v5.4 the kernel VA space is flipped */ -+#define ARM64_FLIP_PAGE_OFFSET_ACTUAL ((0xffffffffffffffffUL) \ - - ((1UL) << machdep->machspec->VA_BITS_ACTUAL) + 1) - - #define ARM64_USERSPACE_TOP ((1UL) << machdep->machspec->VA_BITS) --- -2.29.2 - diff --git a/0001-memory-Add-support-for-SECTION_TAINT_ZONE_DEVICE-fla.patch b/0001-memory-Add-support-for-SECTION_TAINT_ZONE_DEVICE-fla.patch deleted file mode 100644 index fe76553..0000000 --- a/0001-memory-Add-support-for-SECTION_TAINT_ZONE_DEVICE-fla.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 0b5435e10161345cf713ed447a155a611a1b408b Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Wed, 26 May 2021 17:33:13 +0900 -Subject: [PATCH 1/2] memory: Add support for SECTION_TAINT_ZONE_DEVICE flag - -Fix for "kmem -n|-p" options on Linux 5.12-rc1 and later kernels -that contain commit 1f90a3477df3f ("mm: teach pfn_to_online_page() -about ZONE_DEVICE section collisions"). Without the patch, the -"kmem -n" option incorrectly shows mem_map addresses containing the -flag in bit 5 as part of the virtual address, and also the "kmem -p" -option shows page structures at wrong position. With the patch, -the "kmem -n" option displays the new "D" state flag. - -Without the patch: - crash> kmem -n - ... - NR SECTION CODED_MEM_MAP MEM_MAP STATE PFN - 1040 ffff9edf3ffd4100 ffffe2bcc0000010 ffffe2bd42000010 PMOE 34078720 - ^ ^ - crash> kmem -p - PAGE PHYSICAL MAPPING INDEX CNT FLAGS - ffffe2bd42000010 2080000000 400040 1ffffffff 9961471 dead000000000122 referenced,active,error - ffffe2bd42000050 2080001000 800080 1ffffffff 9961471 dead000000000122 referenced,active,error - ffffe2bd42000090 2080002000 0 1ffffffff 9961471 dead000000000122 referenced,active,error - ^^ -With the patch: - crash> kmem -n - ... - NR SECTION CODED_MEM_MAP MEM_MAP STATE PFN - 1040 ffff9edf3ffd4100 ffffe2bcc0000000 ffffe2bd42000000 PMOED 34078720 - - crash> kmem -p - PAGE PHYSICAL MAPPING INDEX CNT FLAGS - ffffe2bd42000000 2080000000 ffff9ebfc0044100 0 1 97ffffc0000200 slab - ffffe2bd42000040 2080001000 ffff9ebfc0044400 0 1 97ffffc0000200 slab - ffffe2bd42000080 2080002000 0 0 1 97ffffc0000000 - -Signed-off-by: Kazuhito Hagio ---- - help.c | 11 +++++++---- - memory.c | 15 +++++++++------ - 2 files changed, 16 insertions(+), 10 deletions(-) - -diff --git a/help.c b/help.c -index e0c84087add3..9649cc81fa36 100644 ---- a/help.c -+++ b/help.c -@@ -6584,10 +6584,13 @@ char *help_kmem[] = { - " kernels, the vm_zone_stat, vm_node_stat and vm_numa_stat tables,", - " the cumulative page_states counter values if they exist, and/or ", - " the cumulative, vm_event_states counter values if they exist.", --" -n display memory node, memory section, and memory block data", --" and state; the state of each memory section state is encoded", --" as \"P\", \"M\", \"O\" and/or \"E\", meaning SECTION_MARKED_PRESENT,", --" SECTION_HAS_MEM_MAP, SECTION_IS_ONLINE and SECTION_IS_EARLY.", -+" -n display memory node, memory section, memory block data and state;", -+" the state of each memory section is shown as the following flags:", -+" \"P\": SECTION_MARKED_PRESENT", -+" \"M\": SECTION_HAS_MEM_MAP", -+" \"O\": SECTION_IS_ONLINE", -+" \"E\": SECTION_IS_EARLY", -+" \"D\": SECTION_TAINT_ZONE_DEVICE", - " -z displays per-zone memory statistics.", - " -o displays each cpu's offset value that is added to per-cpu symbol", - " values to translate them into kernel virtual addresses.", -diff --git a/memory.c b/memory.c -index a3cf8a86728d..2c4f9790f498 100644 ---- a/memory.c -+++ b/memory.c -@@ -17270,12 +17270,13 @@ nr_to_section(ulong nr) - * which results in PFN_SECTION_SHIFT equal 6. - * To sum it up, at least 6 bits are available. - */ --#define SECTION_MARKED_PRESENT (1UL<<0) --#define SECTION_HAS_MEM_MAP (1UL<<1) --#define SECTION_IS_ONLINE (1UL<<2) --#define SECTION_IS_EARLY (1UL<<3) --#define SECTION_MAP_LAST_BIT (1UL<<4) --#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) -+#define SECTION_MARKED_PRESENT (1UL<<0) -+#define SECTION_HAS_MEM_MAP (1UL<<1) -+#define SECTION_IS_ONLINE (1UL<<2) -+#define SECTION_IS_EARLY (1UL<<3) -+#define SECTION_TAINT_ZONE_DEVICE (1UL<<4) -+#define SECTION_MAP_LAST_BIT (1UL<<5) -+#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) - - - int -@@ -17373,6 +17374,8 @@ fill_mem_section_state(ulong state, char *buf) - bufidx += sprintf(buf + bufidx, "%s", "O"); - if (state & SECTION_IS_EARLY) - bufidx += sprintf(buf + bufidx, "%s", "E"); -+ if (state & SECTION_TAINT_ZONE_DEVICE) -+ bufidx += sprintf(buf + bufidx, "%s", "D"); - } - - void --- -2.30.2 - diff --git a/0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch b/0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch deleted file mode 100644 index 70af173..0000000 --- a/0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 167d37e347fe35c6f7db826e8539e192c4375564 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Fri, 2 Jul 2021 10:14:22 +0800 -Subject: [PATCH 2/4] arm64: assign page_offset with VA_BITS kernel - configuration value - -On RHEL9, crash hits a bug when executing "crash /proc/kcore": -seek error: kernel virtual address: ffff6a0f3fff0000 type: "pmd page" - -The kernel virtual address does not vary with vabits_actual, instead, -is determined by configuration value. But crash does not observe this -fact. - -Since vabits_actual related kernel commit is introduced after arm64 -mm layout flip commit, so changes are safe under the condition if -(ms->VA_BITS_ACTUAL), and keep the else branch untouched. - -Signed-off-by: Pingfan Liu ---- - arm64.c | 7 ++++--- - defs.h | 1 + - 2 files changed, 5 insertions(+), 3 deletions(-) - -diff --git a/arm64.c b/arm64.c -index 9fe1a4a..149db36 100644 ---- a/arm64.c -+++ b/arm64.c -@@ -220,9 +220,10 @@ arm64_init(int when) - - /* vabits_actual introduced after mm flip, so it should be flipped layout */ - if (ms->VA_BITS_ACTUAL) { -- ms->page_offset = ARM64_FLIP_PAGE_OFFSET_ACTUAL; -- machdep->identity_map_base = ARM64_FLIP_PAGE_OFFSET_ACTUAL; -- machdep->kvbase = ARM64_FLIP_PAGE_OFFSET_ACTUAL; -+ ms->page_offset = ARM64_FLIP_PAGE_OFFSET; -+ /* useless on arm64 */ -+ machdep->identity_map_base = ARM64_FLIP_PAGE_OFFSET; -+ machdep->kvbase = ARM64_FLIP_PAGE_OFFSET; - ms->userspace_top = ARM64_USERSPACE_TOP_ACTUAL; - } else { - ms->page_offset = ARM64_PAGE_OFFSET; -diff --git a/defs.h b/defs.h -index eb7ce6a..b7b20af 100644 ---- a/defs.h -+++ b/defs.h -@@ -3234,6 +3234,7 @@ typedef signed int s32; - #define ARM64_PAGE_OFFSET ((0xffffffffffffffffUL) \ - << (machdep->machspec->VA_BITS - 1)) - /* kernels >= v5.4 the kernel VA space is flipped */ -+#define ARM64_FLIP_PAGE_OFFSET (-(1UL) << machdep->machspec->CONFIG_ARM64_VA_BITS) - #define ARM64_FLIP_PAGE_OFFSET_ACTUAL ((0xffffffffffffffffUL) \ - - ((1UL) << machdep->machspec->VA_BITS_ACTUAL) + 1) - --- -2.29.2 - diff --git a/0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch b/0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch deleted file mode 100644 index 6ac3c71..0000000 --- a/0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch +++ /dev/null @@ -1,48 +0,0 @@ -From ec44b902d3467e7b86ee39e2d7d472b9cb202148 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Mon, 31 May 2021 14:08:28 +0900 -Subject: [PATCH 2/2] memory: Fix for "kmem -n" option to display NID correctly - -The nid member of struct memory_block is a 4-byte integer, but read -and printed as a 8-byte integer on 64-bit machines. Without the -patch, the option displays wrong NIDs. - - crash> kmem -n - ... - MEM_BLOCK NAME PHYSICAL RANGE NODE STATE START_SECTION_NO - ffff9edeff2b9400 memory0 0 - 7fffffff 14195095130662240256 ONLINE 0 - ffff9edeff2bb400 memory2 100000000 - 17fffffff 14195094718345379840 ONLINE 32 - -The issue seems to appear on Linux 5.12 and later kernels that contain -commit e9a2e48e8704c ("drivers/base/memory: don't store phys_device -in memory blocks"), which changed the arrangement of the members of -struct memory_block. - -Signed-off-by: Kazuhito Hagio ---- - memory.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/memory.c b/memory.c -index 2c4f9790f498..cbe90eebe748 100644 ---- a/memory.c -+++ b/memory.c -@@ -17568,13 +17568,13 @@ print_memory_block(ulong memory_block) - - if (MEMBER_EXISTS("memory_block", "nid")) { - readmem(memory_block + OFFSET(memory_block_nid), KVADDR, &nid, -- sizeof(void *), "memory_block nid", FAULT_ON_ERROR); -+ sizeof(int), "memory_block nid", FAULT_ON_ERROR); - fprintf(fp, " %s %s %s %s %s %s\n", - mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, - MKSTR(memory_block)), - mkstring(buf2, 12, CENTER, name), - parangebuf, -- mkstring(buf5, strlen("NODE"), CENTER|LONG_DEC, -+ mkstring(buf5, strlen("NODE"), CENTER|INT_DEC, - MKSTR(nid)), - mkstring(buf6, strlen("OFFLINE"), LJUST, - statebuf), --- -2.30.2 - diff --git a/0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch b/0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch deleted file mode 100644 index dfb3067..0000000 --- a/0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch +++ /dev/null @@ -1,83 +0,0 @@ -From bf1379a8b6ff8d6a8fa12978f7194f15f85c4380 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Fri, 2 Jul 2021 10:14:23 +0800 -Subject: [PATCH 3/4] arm64: use dedicated bits to record the VA space layout - changes - -arm64 memory layout experiences big changes due to the following kernel -commits in date descending order: - 5. 7bc1a0f9e176 arm64: mm: use single quantity to represent the PA to VA translation - 4. b6d00d47e81a arm64: mm: Introduce 52-bit Kernel VAs - 3. 5383cc6efed1 arm64: mm: Introduce vabits_actual - 2. 14c127c957c1 arm64: mm: Flip kernel VA space - 1. f80fb3a3d508 arm64: add support for kernel ASLR - -For 1, crash has already used NEW_VMEMMAP to trace it. -For 2, crash lacks a flag to tag it and handle it differently. -For 3, two important kernel variables vabits_actual and physvirt_offset -are introduced. -For 4, since it comes immediately after 3, crash-utility does not need -to distinguish it. -For 5, kernel variable phyvirt_offset is removed - -These changes have effects on PTOV()/VTOP() formula. So introducing -two bits HAS_PHYSVIRT_OFFSET and FLIPPED_VM as hint to apply different -formula. - -Signed-off-by: Pingfan Liu ---- - arm64.c | 10 ++++++++++ - defs.h | 2 ++ - 2 files changed, 12 insertions(+) - -diff --git a/arm64.c b/arm64.c -index 149db36..b04369f 100644 ---- a/arm64.c -+++ b/arm64.c -@@ -563,6 +563,10 @@ arm64_dump_machdep_table(ulong arg) - fprintf(fp, "%sMACHDEP_BT_TEXT", others++ ? "|" : ""); - if (machdep->flags & NEW_VMEMMAP) - fprintf(fp, "%sNEW_VMEMMAP", others++ ? "|" : ""); -+ if (machdep->flags & FLIPPED_VM) -+ fprintf(fp, "%sFLIPPED_VM", others++ ? "|" : ""); -+ if (machdep->flags & HAS_PHYSVIRT_OFFSET) -+ fprintf(fp, "%sHAS_PHYSVIRT_OFFSET", others++ ? "|" : ""); - fprintf(fp, ")\n"); - - fprintf(fp, " kvbase: %lx\n", machdep->kvbase); -@@ -997,6 +1001,7 @@ arm64_calc_physvirt_offset(void) - if (READMEM(pc->mfd, &physvirt_offset, sizeof(physvirt_offset), - sp->value, sp->value - - machdep->machspec->kimage_voffset) > 0) { -+ machdep->flags |= HAS_PHYSVIRT_OFFSET; - ms->physvirt_offset = physvirt_offset; - } - } -@@ -3963,6 +3968,11 @@ arm64_calc_VA_BITS(void) - error(FATAL, "cannot determine VA_BITS_ACTUAL\n"); - } - -+ /* -+ * The mm flip commit is introduced before 52-bits VA, which is before the -+ * commit to export NUMBER(TCR_EL1_T1SZ) -+ */ -+ machdep->flags |= FLIPPED_VM; - return; - } - -diff --git a/defs.h b/defs.h -index b7b20af..eca145c 100644 ---- a/defs.h -+++ b/defs.h -@@ -3214,6 +3214,8 @@ typedef signed int s32; - #define NEW_VMEMMAP (0x80) - #define VM_L4_4K (0x100) - #define UNW_4_14 (0x200) -+#define FLIPPED_VM (0x400) -+#define HAS_PHYSVIRT_OFFSET (0x800) - - /* - * Get kimage_voffset from /dev/crash --- -2.29.2 - diff --git a/0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch b/0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch deleted file mode 100644 index 8370c09..0000000 --- a/0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch +++ /dev/null @@ -1,165 +0,0 @@ -From f53b73e8380bca054cebd2b61ff118c46609429b Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Fri, 2 Jul 2021 10:14:24 +0800 -Subject: [PATCH 4/4] arm64: implement switchable PTOV()/VTOP() for kernels >= - 5.10 - -Crash encounters a bug like the following: - ... - SECTION_SIZE_BITS: 30 - CONFIG_ARM64_VA_BITS: 52 - VA_BITS_ACTUAL: 48 - (calculated) VA_BITS: 48 - PAGE_OFFSET: ffff000000000000 - VA_START: ffff800000000000 - modules: ffff800008000000 - ffff80000fffffff - vmalloc: ffff800010000000 - ffffffdfdffeffff - kernel image: ffff800010000000 - ffff800012750000 - vmemmap: ffffffdfffe00000 - ffffffffffffffff - - - - read_netdump: addr: ffff800011c53bc8 paddr: eb453bc8 cnt: 4 offset: 1c73bc8 - irq_stack_ptr: - type: 1, TYPE_CODE_PTR - target_typecode: 8, TYPE_CODE_INT - target_length: 8 - length: 8 - GNU_GET_DATATYPE[thread_union]: returned via gdb_error_hook - - - read_netdump: READ_ERROR: offset not found for paddr: fff1000bf79c0050 - crash: read error: kernel virtual address: ffff000b779c0050 type: "IRQ stack pointer" - ... - -Apparently, for a normal system, the 'paddr: fff1000bf79c0050' is -unreasonable. - -This bug connects with kernel commit 7bc1a0f9e176 ("arm64: mm: use -single quantity to represent the PA to VA translation"), which removed -physvirt_offset kernel variable and changed the PTOV()/VTOP() formulas. - -Implement switchable PTOV()/VTOP() to cope with different kernel -version. - -Signed-off-by: Pingfan Liu ---- - arm64.c | 37 +++++++++++++++++++++++++++++++++---- - defs.h | 9 ++++----- - 2 files changed, 37 insertions(+), 9 deletions(-) - -diff --git a/arm64.c b/arm64.c -index b04369f..d73d5c5 100644 ---- a/arm64.c -+++ b/arm64.c -@@ -994,8 +994,6 @@ arm64_calc_physvirt_offset(void) - ulong physvirt_offset; - struct syment *sp; - -- ms->physvirt_offset = ms->phys_offset - ms->page_offset; -- - if ((sp = kernel_symbol_search("physvirt_offset")) && - machdep->machspec->kimage_voffset) { - if (READMEM(pc->mfd, &physvirt_offset, sizeof(physvirt_offset), -@@ -1003,8 +1001,13 @@ arm64_calc_physvirt_offset(void) - machdep->machspec->kimage_voffset) > 0) { - machdep->flags |= HAS_PHYSVIRT_OFFSET; - ms->physvirt_offset = physvirt_offset; -+ return; - } - } -+ -+ /* Useless if no symbol 'physvirt_offset', just keep semantics */ -+ ms->physvirt_offset = ms->phys_offset - ms->page_offset; -+ - } - - static void -@@ -1051,6 +1054,7 @@ arm64_calc_phys_offset(void) - if (READMEM(pc->mfd, &phys_offset, sizeof(phys_offset), - vaddr, paddr) > 0) { - ms->phys_offset = phys_offset; -+ - return; - } - } -@@ -1178,6 +1182,21 @@ arm64_init_kernel_pgd(void) - vt->kernel_pgd[i] = value; - } - -+ulong arm64_PTOV(ulong paddr) -+{ -+ struct machine_specific *ms = machdep->machspec; -+ -+ /* -+ * Either older kernel before kernel has 'physvirt_offset' or newer -+ * kernel which removes 'physvirt_offset' has the same formula: -+ * #define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET) -+ */ -+ if (!(machdep->flags & HAS_PHYSVIRT_OFFSET)) -+ return (paddr - ms->phys_offset) | PAGE_OFFSET; -+ else -+ return paddr - ms->physvirt_offset; -+} -+ - ulong - arm64_VTOP(ulong addr) - { -@@ -1188,8 +1207,18 @@ arm64_VTOP(ulong addr) - return addr - machdep->machspec->kimage_voffset; - } - -- if (addr >= machdep->machspec->page_offset) -- return addr + machdep->machspec->physvirt_offset; -+ if (addr >= machdep->machspec->page_offset) { -+ if (machdep->flags & HAS_PHYSVIRT_OFFSET) { -+ return addr + machdep->machspec->physvirt_offset; -+ } else { -+ /* -+ * Either older kernel before kernel has 'physvirt_offset' or newer -+ * kernel which removes 'physvirt_offset' has the same formula: -+ * #define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET) -+ */ -+ return (addr & ~PAGE_OFFSET) + machdep->machspec->phys_offset; -+ } -+ } - else if (machdep->machspec->kimage_voffset) - return addr - machdep->machspec->kimage_voffset; - else /* no randomness */ -diff --git a/defs.h b/defs.h -index eca145c..c91177a 100644 ---- a/defs.h -+++ b/defs.h -@@ -3092,11 +3092,6 @@ typedef u64 pte_t; - #define _64BIT_ - #define MACHINE_TYPE "ARM64" - --#define PTOV(X) \ -- ((unsigned long)(X) - (machdep->machspec->physvirt_offset)) -- --#define VTOP(X) arm64_VTOP((ulong)(X)) -- - #define USERSPACE_TOP (machdep->machspec->userspace_top) - #define PAGE_OFFSET (machdep->machspec->page_offset) - #define VMALLOC_START (machdep->machspec->vmalloc_start_addr) -@@ -3106,6 +3101,9 @@ typedef u64 pte_t; - #define MODULES_VADDR (machdep->machspec->modules_vaddr) - #define MODULES_END (machdep->machspec->modules_end) - -+#define PTOV(X) arm64_PTOV((ulong)(X)) -+#define VTOP(X) arm64_VTOP((ulong)(X)) -+ - #define IS_VMALLOC_ADDR(X) arm64_IS_VMALLOC_ADDR((ulong)(X)) - - #define PAGEBASE(X) (((ulong)(X)) & (ulong)machdep->pagemask) -@@ -5910,6 +5908,7 @@ void unwind_backtrace(struct bt_info *); - void arm64_init(int); - void arm64_dump_machdep_table(ulong); - ulong arm64_VTOP(ulong); -+ulong arm64_PTOV(ulong); - int arm64_IS_VMALLOC_ADDR(ulong); - ulong arm64_swp_type(ulong); - ulong arm64_swp_offset(ulong); --- -2.29.2 - diff --git a/crash-8.0.0_build.patch b/crash-8.0.0_build.patch new file mode 100644 index 0000000..12cb747 --- /dev/null +++ b/crash-8.0.0_build.patch @@ -0,0 +1,35 @@ +diff --git crash-8.0.0/Makefile crash-8.0.0/Makefile +index d0574d8f07d3..9dbb61d0dbc8 100644 +--- crash-8.0.0/Makefile ++++ crash-8.0.0/Makefile +@@ -198,7 +198,7 @@ GDB_FLAGS= + # TARGET_CFLAGS will be configured automatically by configure + TARGET_CFLAGS= + +-CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ++CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ${CPPFLAGS} -fPIE + + GPL_FILES= + TAR_FILES=${SOURCE_FILES} Makefile ${GPL_FILES} README .rh_rpm_package crash.8 \ +@@ -228,7 +228,7 @@ all: make_configure + gdb_merge: force + @if [ ! -f ${GDB}/README ]; then \ + make --no-print-directory gdb_unzip; fi +- @echo "${LDFLAGS} -lz -llzo2 -lsnappy -ldl -rdynamic" > ${GDB}/gdb/mergelibs ++ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -ldl -rdynamic -Wl,-z,now -fPIE" > ${GDB}/gdb/mergelibs + @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj + @rm -f ${PROGRAM} + @if [ ! -f ${GDB}/config.status ]; then \ +diff --git crash-8.0.0/configure.c crash-8.0.0/configure.c +index 75006e881f5a..06c94d58c56c 100644 +--- crash-8.0.0/configure.c ++++ crash-8.0.0/configure.c +@@ -780,7 +780,8 @@ build_configure(struct supported_gdb_version *sp) + fprintf(fp2, "%s\n", sp->GDB); + sprintf(target_data.gdb_version, "%s", &sp->GDB[4]); + } else if (strncmp(buf, "LDFLAGS=", strlen("LDFLAGS=")) == 0) { +- fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); ++ if (ldflags) ++ fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); + } else + fprintf(fp2, "%s", buf); diff --git a/crash.spec b/crash.spec index f7dec71..34c9210 100644 --- a/crash.spec +++ b/crash.spec @@ -3,29 +3,22 @@ # Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash -Version: 7.3.0 -Release: 6%{?dist} +Version: 8.0.0 +Release: 1%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz -Source1: http://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz +Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz URL: https://crash-utility.github.io ExclusiveOS: Linux ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x %{arm} aarch64 ppc64le -BuildRequires: ncurses-devel zlib-devel lzo-devel snappy-devel bison +BuildRequires: ncurses-devel zlib-devel lzo-devel snappy-devel bison texinfo libzstd-devel BuildRequires: gcc gcc-c++ BuildRequires: make Requires: binutils Provides: bundled(libiberty) -Provides: bundled(gdb) = 7.6 +Provides: bundled(gdb) = 10.2 Patch0: lzo_snappy.patch -Patch1: 0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch -Patch2: 0001-memory-Add-support-for-SECTION_TAINT_ZONE_DEVICE-fla.patch -Patch3: 0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch -Patch4: 0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch -Patch5: 0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch -Patch6: 0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch -Patch7: 0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch -Patch8: 0001-Handle-task_struct-state-member-changes-for-kernels-.patch +Patch1: crash-8.0.0_build.patch %description The core analysis suite is a self-contained tool that can be used to @@ -46,25 +39,12 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %prep %setup -n %{name}-%{version} -q %patch0 -p1 -b lzo_snappy.patch -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 +%patch1 -p1 -b crash-8.0.0_build.patch %build -# This package has an internal copy of GDB which has broken configure code for -# INTDIV0_RAISES_SIGFPE and MUST_REINSTALL_SIGHANDLERS -# Updating that code properly seems nontrivial and best left to the package -# maintainer. -# Disable LTO -%define _lto_cflags %{nil} cp %{SOURCE1} . -make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" +make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" %install rm -rf %{buildroot} @@ -85,6 +65,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Thu Nov 25 2021 Lianbo Jiang - 8.0.0-1 +- Rebase to upstream 8.0.0 + * Mon Aug 09 2021 Mohan Boddu - 7.3.0-6 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688 diff --git a/lzo_snappy.patch b/lzo_snappy.patch index 4075b06..8bc57a9 100644 --- a/lzo_snappy.patch +++ b/lzo_snappy.patch @@ -1,5 +1,5 @@ ---- crash-7.3.0/diskdump.c.orig -+++ crash-7.3.0/diskdump.c +--- crash-8.0.0/diskdump.c.orig ++++ crash-8.0.0/diskdump.c @@ -23,6 +23,8 @@ * GNU General Public License for more details. */ @@ -9,8 +9,8 @@ #include "defs.h" #include "diskdump.h" #include "xen_dom0.h" ---- crash-7.3.0/Makefile.orig -+++ crash-7.3.0/Makefile +--- crash-8.0.0/Makefile.orig ++++ crash-8.0.0/Makefile @@ -228,7 +228,7 @@ all: make_configure gdb_merge: force @if [ ! -f ${GDB}/README ]; then \ diff --git a/sources b/sources index f169968..62b50d3 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (crash-7.3.0.tar.gz) = bc288821892c3d7ecbf192d9fe6ea9e73216f8074a24d12a00fbcaf967a1faa38ee69c4a5a97aa93bf75426293f5b275f5ab496c154b4e7be265ba0e263b2bc8 -SHA512 (gdb-7.6.tar.gz) = 02d9c62fa73bcb79138d14c7fc182443f0ca82d4545b4d260b67d3f0074ed75f899a657814a56727e601032a668b0ddd7b48aabd49215fc012eeea6077bca368 +SHA512 (crash-8.0.0.tar.gz) = c52afab6c8187dc0c44a13b2a5b33bd7df33d9ee12bcecc6b7e94e8bc98d9470c134cb0fbe941b750f36a66028aad718bfd6f1a00524ad38ce43d1f278048a3b +SHA512 (gdb-10.2.tar.gz) = aa89caf47c1c84366020377d47e7c51ddbc48e5b7686f244e38797c8eb88411cf57fcdc37eb669961efb41ceeac4181747f429625fd1acce7712cb9a1fea9c41