diff --git a/.crash.metadata b/.crash.metadata index 1238fca..7381cdc 100644 --- a/.crash.metadata +++ b/.crash.metadata @@ -1,2 +1,2 @@ -35a06244e58606ebf2b5612fbfcb51301bd5877a SOURCES/crash-7.3.0.tar.gz +f230368e17058e61a0be4c22f0969bed76cd6c29 SOURCES/crash-7.3.1.tar.gz 026f4c9e1c8152a2773354551c523acd32d7f00e SOURCES/gdb-7.6.tar.gz diff --git a/.gitignore b/.gitignore index 169176a..d19e76b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/crash-7.3.0.tar.gz +SOURCES/crash-7.3.1.tar.gz SOURCES/gdb-7.6.tar.gz diff --git a/SOURCES/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch b/SOURCES/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch deleted file mode 100644 index fd8b759..0000000 --- a/SOURCES/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/SOURCES/0002-Fix-waitq-command-for-Linux-4.13-and-later-kernels.patch b/SOURCES/0002-Fix-waitq-command-for-Linux-4.13-and-later-kernels.patch deleted file mode 100644 index 70a9a22..0000000 --- a/SOURCES/0002-Fix-waitq-command-for-Linux-4.13-and-later-kernels.patch +++ /dev/null @@ -1,132 +0,0 @@ -From eaf14f852ae79f7745934e213661f1c6abac711e Mon Sep 17 00:00:00 2001 -From: Greg Edwards -Date: Wed, 23 Jun 2021 13:50:47 -0600 -Subject: [PATCH] Fix 'waitq' command for Linux 4.13 and later kernels - -The wait queue structs and members were renamed in 4.13 in commits: - - ac6424b981bc ("sched/wait: Rename wait_queue_t => wait_queue_entry_t") - 9d9d676f595b ("sched/wait: Standardize internal naming of wait-queue heads") - 2055da97389a ("sched/wait: Disambiguate wq_entry->task_list and wq_head->task_list naming") - -Add support to the 'waitq' command for these more recent kernels. - -[ kh: suppressed compilation warnings ] - -Signed-off-by: Greg Edwards -Signed-off-by: Kazuhito Hagio -Signed-off-by: Lianbo Jiang ---- - defs.h | 4 ++++ - kernel.c | 27 +++++++++++++++++++++++---- - symbols.c | 10 +++++++++- - 3 files changed, 36 insertions(+), 5 deletions(-) - -diff --git a/defs.h b/defs.h -index 42c8074e6ac6..6bb00e29d811 100644 ---- a/defs.h -+++ b/defs.h -@@ -2138,6 +2138,9 @@ struct offset_table { /* stash of commonly-used offsets */ - long atomic_long_t_counter; - long block_device_bd_device; - long block_device_bd_stats; -+ long wait_queue_entry_private; -+ long wait_queue_head_head; -+ long wait_queue_entry_entry; - }; - - struct size_table { /* stash of commonly-used sizes */ -@@ -2300,6 +2303,7 @@ struct size_table { /* stash of commonly-used sizes */ - long printk_info; - long printk_ringbuffer; - long prb_desc; -+ long wait_queue_entry; - }; - - struct array_table { -diff --git a/kernel.c b/kernel.c -index 528f6ee524f6..e123f760e036 100644 ---- a/kernel.c -+++ b/kernel.c -@@ -615,7 +615,15 @@ kernel_init() - kt->flags |= TVEC_BASES_V1; - - STRUCT_SIZE_INIT(__wait_queue, "__wait_queue"); -- if (VALID_STRUCT(__wait_queue)) { -+ STRUCT_SIZE_INIT(wait_queue_entry, "wait_queue_entry"); -+ if (VALID_STRUCT(wait_queue_entry)) { -+ MEMBER_OFFSET_INIT(wait_queue_entry_private, -+ "wait_queue_entry", "private"); -+ MEMBER_OFFSET_INIT(wait_queue_head_head, -+ "wait_queue_head", "head"); -+ MEMBER_OFFSET_INIT(wait_queue_entry_entry, -+ "wait_queue_entry", "entry"); -+ } else if (VALID_STRUCT(__wait_queue)) { - if (MEMBER_EXISTS("__wait_queue", "task")) - MEMBER_OFFSET_INIT(__wait_queue_task, - "__wait_queue", "task"); -@@ -9367,9 +9375,9 @@ dump_waitq(ulong wq, char *wq_name) - struct list_data list_data, *ld; - ulong *wq_list; /* addr of wait queue element */ - ulong next_offset; /* next pointer of wq element */ -- ulong task_offset; /* offset of task in wq element */ -+ ulong task_offset = 0; /* offset of task in wq element */ - int cnt; /* # elems on Queue */ -- int start_index; /* where to start in wq array */ -+ int start_index = -1; /* where to start in wq array */ - int i; - - ld = &list_data; -@@ -9397,9 +9405,20 @@ dump_waitq(ulong wq, char *wq_name) - ld->list_head_offset = OFFSET(__wait_queue_task_list); - ld->member_offset = next_offset; - -+ start_index = 1; -+ } else if (VALID_STRUCT(wait_queue_entry)) { -+ ulong head_offset; -+ -+ next_offset = OFFSET(list_head_next); -+ task_offset = OFFSET(wait_queue_entry_private); -+ head_offset = OFFSET(wait_queue_head_head); -+ ld->end = ld->start = wq + head_offset + next_offset; -+ ld->list_head_offset = OFFSET(wait_queue_entry_entry); -+ ld->member_offset = next_offset; -+ - start_index = 1; - } else { -- return; -+ error(FATAL, "cannot determine wait queue structures\n"); - } - - hq_open(); -diff --git a/symbols.c b/symbols.c -index 370d4c3e8ac0..67c135f12984 100644 ---- a/symbols.c -+++ b/symbols.c -@@ -9817,7 +9817,13 @@ dump_offset_table(char *spec, ulong makestruct) - OFFSET(__wait_queue_head_task_list)); - fprintf(fp, " __wait_queue_task_list: %ld\n", - OFFSET(__wait_queue_task_list)); -- -+ fprintf(fp, " wait_queue_entry_private: %ld\n", -+ OFFSET(wait_queue_entry_private)); -+ fprintf(fp, " wait_queue_head_head: %ld\n", -+ OFFSET(wait_queue_head_head)); -+ fprintf(fp, " wait_queue_entry_entry: %ld\n", -+ OFFSET(wait_queue_entry_entry)); -+ - fprintf(fp, " pglist_data_node_zones: %ld\n", - OFFSET(pglist_data_node_zones)); - fprintf(fp, " pglist_data_node_mem_map: %ld\n", -@@ -10717,6 +10723,8 @@ dump_offset_table(char *spec, ulong makestruct) - fprintf(fp, " wait_queue: %ld\n", SIZE(wait_queue)); - fprintf(fp, " __wait_queue: %ld\n", - SIZE(__wait_queue)); -+ fprintf(fp, " wait_queue_entry: %ld\n", -+ SIZE(wait_queue_entry)); - fprintf(fp, " device: %ld\n", SIZE(device)); - fprintf(fp, " net_device: %ld\n", SIZE(net_device)); - --- -2.30.2 - diff --git a/SOURCES/0003-Handle-task_struct-state-member-changes-for-kernels-.patch b/SOURCES/0003-Handle-task_struct-state-member-changes-for-kernels-.patch deleted file mode 100644 index 4ccbfe3..0000000 --- a/SOURCES/0003-Handle-task_struct-state-member-changes-for-kernels-.patch +++ /dev/null @@ -1,76 +0,0 @@ -From d6b4f36d6b22b70fb14e692f36d20910ef5563c1 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 6bb00e29d811..5d32954905c2 100644 ---- a/defs.h -+++ b/defs.h -@@ -2304,6 +2304,7 @@ struct size_table { /* stash of commonly-used sizes */ - long printk_ringbuffer; - long prb_desc; - long wait_queue_entry; -+ long task_struct_state; - }; - - struct array_table { -diff --git a/symbols.c b/symbols.c -index 67c135f12984..bf6d94db84af 100644 ---- a/symbols.c -+++ b/symbols.c -@@ -10678,6 +10678,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/SOURCES/0004-Handle-task_struct-cpu-member-changes-for-kernels-5..patch b/SOURCES/0004-Handle-task_struct-cpu-member-changes-for-kernels-5..patch deleted file mode 100644 index 2c41306..0000000 --- a/SOURCES/0004-Handle-task_struct-cpu-member-changes-for-kernels-5..patch +++ /dev/null @@ -1,56 +0,0 @@ -From 488a59f85a57961fb0527aac40ae30fc7a17a24c Mon Sep 17 00:00:00 2001 -From: Alexander Egorenkov -Date: Wed, 13 Oct 2021 10:56:39 +0200 -Subject: [PATCH] Handle task_struct cpu member changes for kernels >= 5.16-rc1 - -Kernel commit bcf9033e5449bdcaa9bed46467a7141a8049dadb -("sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y") -moved the member cpu of task_struct back into thread_info. -Without the patch, crash fails with the following error message -during session initialization: - - crash: invalid structure member offset: task_struct_cpu - FILE: task.c LINE: 2904 FUNCTION: add_context() - -Signed-off-by: Alexander Egorenkov -Signed-off-by: Kazuhito Hagio ---- - task.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/task.c b/task.c -index 672b41697e75..bb6a5da8ad33 100644 ---- a/task.c -+++ b/task.c -@@ -278,8 +278,10 @@ task_init(void) - } else if (VALID_MEMBER(task_struct_stack)) - MEMBER_OFFSET_INIT(task_struct_thread_info, "task_struct", "stack"); - -+ MEMBER_OFFSET_INIT(task_struct_cpu, "task_struct", "cpu"); -+ - if (VALID_MEMBER(task_struct_thread_info)) { -- if (tt->flags & THREAD_INFO_IN_TASK) { -+ if (tt->flags & THREAD_INFO_IN_TASK && VALID_MEMBER(task_struct_cpu)) { - MEMBER_OFFSET_INIT(thread_info_flags, "thread_info", "flags"); - /* (unnecessary) reminders */ - ASSIGN_OFFSET(thread_info_task) = INVALID_OFFSET; -@@ -315,7 +317,6 @@ task_init(void) - MEMBER_OFFSET_INIT(task_struct_has_cpu, "task_struct", "has_cpu"); - MEMBER_OFFSET_INIT(task_struct_cpus_runnable, - "task_struct", "cpus_runnable"); -- MEMBER_OFFSET_INIT(task_struct_cpu, "task_struct", "cpu"); - MEMBER_OFFSET_INIT(task_struct_active_mm, "task_struct", "active_mm"); - MEMBER_OFFSET_INIT(task_struct_next_run, "task_struct", "next_run"); - MEMBER_OFFSET_INIT(task_struct_flags, "task_struct", "flags"); -@@ -2900,7 +2901,7 @@ add_context(ulong task, char *tp) - else - tc->thread_info = ULONG(tp + OFFSET(task_struct_thread_info)); - fill_thread_info(tc->thread_info); -- if (tt->flags & THREAD_INFO_IN_TASK) -+ if (tt->flags & THREAD_INFO_IN_TASK && VALID_MEMBER(task_struct_cpu)) - processor_addr = (int *) (tp + OFFSET(task_struct_cpu)); - else - processor_addr = (int *) (tt->thread_info + --- -2.30.2 - diff --git a/SOURCES/0005-Fix-live-debugging-with-lockdown-integrity.patch b/SOURCES/0005-Fix-live-debugging-with-lockdown-integrity.patch deleted file mode 100644 index f9bfe8a..0000000 --- a/SOURCES/0005-Fix-live-debugging-with-lockdown-integrity.patch +++ /dev/null @@ -1,57 +0,0 @@ -From e90c0011d6e9476104c4c43aa76d2d0830a15946 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 9 Nov 2021 14:52:22 +0100 -Subject: [PATCH] Fix live debugging with lockdown=integrity - -With kernel lockdown the access to kernel interfaces that allow to -extract confidential information (lockdown=confidentiality) or modify a -running kernel (lockdown=integrity) can be restricted. Two of the -interfaces that can be restricted are /dev/mem (integrity & -confidentiality) and /proc/kcore (confidentiality). With -lockdown=integrity this leads to a situation where /dev/mem exists but -is not readable while /proc/kcore exists and is readable. This breaks -crash's live debugging when it is invoked without argument, i.e. - -$ crash -[...] -crash: /dev/mem: Operation not permitted - -while passing /proc/kcore as image succeeds. The reason for this is that -crash always picks /dev/mem as source when it exits but doesn't check if -it is readable. Fix this by only selecting /dev/mem when it is readable. - -Signed-off-by: Philipp Rudo ---- - filesys.c | 2 +- - main.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/filesys.c b/filesys.c -index 3361b6c12ed3..43cbe826fc79 100644 ---- a/filesys.c -+++ b/filesys.c -@@ -3666,7 +3666,7 @@ get_live_memory_source(void) - if (pc->live_memsrc) - goto live_report; - -- if (file_exists("/dev/mem", NULL)) -+ if (file_readable("/dev/mem")) - pc->live_memsrc = "/dev/mem"; - else if (file_exists("/proc/kcore", NULL)) { - pc->flags &= ~DEVMEM; -diff --git a/main.c b/main.c -index 388ac46c3834..dfd343cd9dd4 100644 ---- a/main.c -+++ b/main.c -@@ -1119,7 +1119,7 @@ setup_environment(int argc, char **argv) - pc->flags2 |= REDZONE; - pc->confd = -2; - pc->machine_type = MACHINE_TYPE; -- if (file_exists("/dev/mem", NULL)) { /* defaults until argv[] is parsed */ -+ if (file_readable("/dev/mem")) { /* defaults until argv[] is parsed */ - pc->readmem = read_dev_mem; - pc->writemem = write_dev_mem; - } else if (file_exists("/proc/kcore", NULL)) { --- -2.30.2 - diff --git a/SOURCES/lzo_snappy.patch b/SOURCES/lzo_snappy.patch index 1ae83e6..336f9cb 100644 --- a/SOURCES/lzo_snappy.patch +++ b/SOURCES/lzo_snappy.patch @@ -1,7 +1,7 @@ -diff --git crash-7.3.0/Makefile crash-7.3.0/Makefile +diff --git crash-7.3.1/Makefile crash-7.3.1/Makefile index 745541012f43..d0574d8f07d3 100644 ---- crash-7.3.0/Makefile -+++ crash-7.3.0/Makefile +--- crash-7.3.1/Makefile ++++ crash-7.3.1/Makefile @@ -228,7 +228,7 @@ all: make_configure gdb_merge: force @if [ ! -f ${GDB}/README ]; then \ @@ -11,10 +11,10 @@ index 745541012f43..d0574d8f07d3 100644 @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj @rm -f ${PROGRAM} @if [ ! -f ${GDB}/config.status ]; then \ -diff --git crash-7.3.0/diskdump.c crash-7.3.0/diskdump.c +diff --git crash-7.3.1/diskdump.c crash-7.3.1/diskdump.c index e88243e616cc..9ccf7039231b 100644 ---- crash-7.3.0/diskdump.c -+++ crash-7.3.0/diskdump.c +--- crash-7.3.1/diskdump.c ++++ crash-7.3.1/diskdump.c @@ -23,6 +23,8 @@ * GNU General Public License for more details. */ diff --git a/SOURCES/rhel8_arm64_52_bit_fix.patch b/SOURCES/rhel8_arm64_52_bit_fix.patch deleted file mode 100644 index c37ea03..0000000 --- a/SOURCES/rhel8_arm64_52_bit_fix.patch +++ /dev/null @@ -1,1043 +0,0 @@ -From 1bc151ee1304318ecb36d6158afe40852bc4b7f4 Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Tue, 1 Dec 2020 02:23:53 +0530 -Subject: [PATCH] arm64 crash fix for older kernels - -Signed-off-by: Bhupesh Sharma ---- - arm64.c | 512 +++++++++++--------------------------------------------- - defs.h | 18 +- - 2 files changed, 102 insertions(+), 428 deletions(-) - -diff --git a/arm64.c b/arm64.c -index 4787fa61e3e5..68347b131aef 100644 ---- a/arm64.c -+++ b/arm64.c -@@ -27,13 +27,9 @@ - static struct machine_specific arm64_machine_specific = { 0 }; - static int arm64_verify_symbol(const char *, ulong, char); - static void arm64_parse_cmdline_args(void); --static int arm64_search_for_kimage_voffset(ulong); --static int verify_kimage_voffset(void); - static void arm64_calc_kimage_voffset(void); - static void arm64_calc_phys_offset(void); --static void arm64_calc_physvirt_offset(void); - static void arm64_calc_virtual_memory_ranges(void); --static void arm64_get_section_size_bits(void); - static int arm64_kdump_phys_base(ulong *); - static ulong arm64_processor_speed(void); - static void arm64_init_kernel_pgd(void); -@@ -82,10 +78,9 @@ static int arm64_on_irq_stack(int, ulong); - static void arm64_set_irq_stack(struct bt_info *); - static void arm64_set_process_stack(struct bt_info *); - static int arm64_get_kvaddr_ranges(struct vaddr_range *); --static void arm64_get_crash_notes(void); -+static int arm64_get_crash_notes(void); - static void arm64_calc_VA_BITS(void); - static int arm64_is_uvaddr(ulong, struct task_context *); --static void arm64_calc_KERNELPACMASK(void); - - - /* -@@ -149,12 +144,6 @@ arm64_init(int when) - if (kernel_symbol_exists("kimage_voffset")) - machdep->flags |= NEW_VMEMMAP; - -- if (!machdep->pagesize && -- (string = pc->read_vmcoreinfo("PAGESIZE"))) { -- machdep->pagesize = atoi(string); -- free(string); -- } -- - if (!machdep->pagesize) { - /* - * Kerneldoc Documentation/arm64/booting.txt describes -@@ -181,16 +170,17 @@ arm64_init(int when) - - } - -- /* -- * This code section will only be executed if the kernel is -- * earlier than Linux 4.4 (if there is no vmcoreinfo) -- */ - if (!machdep->pagesize && - kernel_symbol_exists("swapper_pg_dir") && - kernel_symbol_exists("idmap_pg_dir")) { -- value = symbol_value("swapper_pg_dir") - -- symbol_value("idmap_pg_dir"); -+ if (kernel_symbol_exists("tramp_pg_dir")) -+ value = symbol_value("tramp_pg_dir"); -+ else if (kernel_symbol_exists("reserved_ttbr0")) -+ value = symbol_value("reserved_ttbr0"); -+ else -+ value = symbol_value("swapper_pg_dir"); - -+ value -= symbol_value("idmap_pg_dir"); - /* - * idmap_pg_dir is 2 pages prior to 4.1, - * and 3 pages thereafter. Only 4K and 64K -@@ -215,21 +205,13 @@ arm64_init(int when) - machdep->pagemask = ~((ulonglong)machdep->pageoffset); - - arm64_calc_VA_BITS(); -- arm64_calc_KERNELPACMASK(); - ms = machdep->machspec; -- 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->userspace_top = ARM64_USERSPACE_TOP_ACTUAL; -- } else { -- ms->page_offset = ARM64_PAGE_OFFSET; -- machdep->identity_map_base = ARM64_PAGE_OFFSET; -- machdep->kvbase = ARM64_VA_START; -- ms->userspace_top = ARM64_USERSPACE_TOP; -- } -+ ms->page_offset = ARM64_PAGE_OFFSET; -+ machdep->identity_map_base = ARM64_PAGE_OFFSET; -+ machdep->kvbase = ARM64_VA_START; - machdep->is_kvaddr = generic_is_kvaddr; - machdep->kvtop = arm64_kvtop; -+ ms->userspace_top = ARM64_USERSPACE_TOP; - if (machdep->flags & NEW_VMEMMAP) { - struct syment *sp; - -@@ -238,15 +220,11 @@ arm64_init(int when) - sp = kernel_symbol_search("_end"); - ms->kimage_end = (sp ? sp->value : 0); - -- if (ms->VA_BITS_ACTUAL) { -- ms->modules_vaddr = (st->_stext_vmlinux & TEXT_OFFSET_MASK) - ARM64_MODULES_VSIZE; -- ms->modules_end = ms->modules_vaddr + ARM64_MODULES_VSIZE -1; -- } else { -- ms->modules_vaddr = ARM64_VA_START; -- if (kernel_symbol_exists("kasan_init")) -- ms->modules_vaddr += ARM64_KASAN_SHADOW_SIZE; -- ms->modules_end = ms->modules_vaddr + ARM64_MODULES_VSIZE -1; -- } -+ ms->modules_vaddr = ARM64_VA_START; -+ if (kernel_symbol_exists("kasan_init")) -+ ms->modules_vaddr += ARM64_KASAN_SHADOW_SIZE; -+ ms->modules_end = ms->modules_vaddr -+ + ARM64_MODULES_VSIZE -1; - - ms->vmalloc_start_addr = ms->modules_end + 1; - -@@ -338,6 +316,10 @@ arm64_init(int when) - - machdep->uvtop = arm64_uvtop; - machdep->is_uvaddr = arm64_is_uvaddr; -+ if (kernel_symbol_exists("vabits_user") && -+ readmem(symbol_value("vabits_user"), KVADDR, -+ &value, sizeof(ulong), "vabits_user", RETURN_ON_ERROR)) -+ machdep->machspec->vabits_user = value; - machdep->eframe_search = arm64_eframe_search; - machdep->back_trace = arm64_back_trace_cmd; - machdep->in_alternate_stack = arm64_in_alternate_stack; -@@ -365,7 +347,6 @@ arm64_init(int when) - - /* use machdep parameters */ - arm64_calc_phys_offset(); -- arm64_calc_physvirt_offset(); - - if (CRASHDEBUG(1)) { - if (machdep->flags & NEW_VMEMMAP) -@@ -373,15 +354,13 @@ arm64_init(int when) - machdep->machspec->kimage_voffset); - fprintf(fp, "phys_offset: %lx\n", - machdep->machspec->phys_offset); -- fprintf(fp, "physvirt_offset: %lx\n", machdep->machspec->physvirt_offset); - } - - break; - - case POST_GDB: - arm64_calc_virtual_memory_ranges(); -- arm64_get_section_size_bits(); -- -+ machdep->section_size_bits = _SECTION_SIZE_BITS; - if (!machdep->max_physmem_bits) { - if ((string = pc->read_vmcoreinfo("NUMBER(MAX_PHYSMEM_BITS)"))) { - machdep->max_physmem_bits = atol(string); -@@ -393,24 +372,8 @@ arm64_init(int when) - else - machdep->max_physmem_bits = _MAX_PHYSMEM_BITS; - } -- - ms = machdep->machspec; - -- if (CRASHDEBUG(1)) { -- if (ms->VA_BITS_ACTUAL) { -- 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, " 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); -- fprintf(fp, "kernel image: %lx - %lx\n", ms->kimage_text, ms->kimage_end); -- fprintf(fp, " vmemmap: %lx - %lx\n\n", ms->vmemmap_vaddr, ms->vmemmap_end); -- } -- } -- -- - if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) { - ms->__SWP_TYPE_BITS = 6; - ms->__SWP_TYPE_SHIFT = 2; -@@ -470,17 +433,18 @@ arm64_init(int when) - * of the crash. We need this information to extract correct - * backtraces from the panic task. - */ -- if (!LIVE()) -- arm64_get_crash_notes(); -+ if (!LIVE() && !arm64_get_crash_notes()) -+ error(WARNING, -+ "cannot retrieve registers for active task%s\n\n", -+ kt->cpus > 1 ? "s" : ""); -+ - break; - - case LOG_ONLY: - machdep->machspec = &arm64_machine_specific; - arm64_calc_VA_BITS(); -- arm64_calc_KERNELPACMASK(); - arm64_calc_phys_offset(); - machdep->machspec->page_offset = ARM64_PAGE_OFFSET; -- arm64_calc_physvirt_offset(); - break; - } - } -@@ -657,20 +621,9 @@ arm64_dump_machdep_table(ulong arg) - - fprintf(fp, " machspec: %lx\n", (ulong)ms); - fprintf(fp, " VA_BITS: %ld\n", ms->VA_BITS); -- fprintf(fp, " CONFIG_ARM64_VA_BITS: %ld\n", ms->CONFIG_ARM64_VA_BITS); -- fprintf(fp, " VA_START: "); -- if (ms->VA_START) -- fprintf(fp, "%lx\n", ms->VA_START); -- else -- fprintf(fp, "(unused)\n"); -- fprintf(fp, " VA_BITS_ACTUAL: "); -- if (ms->VA_BITS_ACTUAL) -- fprintf(fp, "%ld\n", ms->VA_BITS_ACTUAL); -- else -- fprintf(fp, "(unused)\n"); -- fprintf(fp, "CONFIG_ARM64_KERNELPACMASK: "); -- if (ms->CONFIG_ARM64_KERNELPACMASK) -- fprintf(fp, "%lx\n", ms->CONFIG_ARM64_KERNELPACMASK); -+ fprintf(fp, " vabits_user: "); -+ if (ms->vabits_user) -+ fprintf(fp, "%ld\n", ms->vabits_user); - else - fprintf(fp, "(unused)\n"); - fprintf(fp, " userspace_top: %016lx\n", ms->userspace_top); -@@ -759,14 +712,12 @@ arm64_parse_machdep_arg_l(char *argstring, char *param, ulong *value) - int flags = RETURN_ON_ERROR | QUIET; - int err = 0; - -- if (STRNEQ(argstring, "max_physmem_bits")) { -- *value = dtol(p, flags, &err); -- } else if (STRNEQ(argstring, "vabits_actual")) { -- *value = dtol(p, flags, &err); -- } else if (megabytes) { -+ if (megabytes) { - *value = dtol(p, flags, &err); - if (!err) - *value = MEGABYTES(*value); -+ } else if (STRNEQ(argstring, "max_physmem_bits")) { -+ *value = dtol(p, flags, &err); - } else { - *value = htol(p, flags, &err); - } -@@ -832,12 +783,6 @@ arm64_parse_cmdline_args(void) - "setting max_physmem_bits to: %ld\n\n", - machdep->max_physmem_bits); - continue; -- } else if (arm64_parse_machdep_arg_l(arglist[i], "vabits_actual", -- &machdep->machspec->VA_BITS_ACTUAL)) { -- error(NOTE, -- "setting vabits_actual to: %ld\n\n", -- machdep->machspec->VA_BITS_ACTUAL); -- continue; - } - - error(WARNING, "ignoring --machdep option: %s\n", -@@ -846,60 +791,11 @@ arm64_parse_cmdline_args(void) - } - } - --#define MIN_KIMG_ALIGN (0x00200000) /* kimage load address must be aligned 2M */ --/* -- * Traverse the entire dumpfile to find/verify kimage_voffset. -- */ --static int --arm64_search_for_kimage_voffset(ulong phys_base) --{ -- ulong kimage_load_addr; -- ulong phys_end; -- struct machine_specific *ms = machdep->machspec; -- -- if (!arm_kdump_phys_end(&phys_end)) -- return FALSE; -- -- for (kimage_load_addr = phys_base; -- kimage_load_addr <= phys_end; kimage_load_addr += MIN_KIMG_ALIGN) { -- ms->kimage_voffset = ms->vmalloc_start_addr - kimage_load_addr; -- -- if ((kt->flags2 & KASLR) && (kt->flags & RELOC_SET)) -- ms->kimage_voffset += (kt->relocate * - 1); -- -- if (verify_kimage_voffset()) { -- if (CRASHDEBUG(1)) -- error(INFO, -- "dumpfile searched for kimage_voffset: %lx\n\n", -- ms->kimage_voffset); -- break; -- } -- } -- -- if (kimage_load_addr > phys_end) -- return FALSE; -- -- return TRUE; --} -- --static int --verify_kimage_voffset(void) --{ -- ulong kimage_voffset; -- -- if (!readmem(symbol_value("kimage_voffset"), KVADDR, &kimage_voffset, -- sizeof(kimage_voffset), "verify kimage_voffset", QUIET|RETURN_ON_ERROR)) -- return FALSE; -- -- return (machdep->machspec->kimage_voffset == kimage_voffset); --} -- - static void - arm64_calc_kimage_voffset(void) - { - struct machine_specific *ms = machdep->machspec; -- ulong phys_addr = 0; -- int errflag; -+ ulong phys_addr; - - if (ms->kimage_voffset) /* vmcoreinfo, ioctl, or --machdep override */ - return; -@@ -907,6 +803,7 @@ arm64_calc_kimage_voffset(void) - if (ACTIVE()) { - char buf[BUFSIZE]; - char *p1; -+ int errflag; - FILE *iomem; - ulong kimage_voffset, vaddr; - -@@ -947,24 +844,9 @@ arm64_calc_kimage_voffset(void) - if (errflag) - return; - -- } else if (KDUMP_DUMPFILE()) { -- errflag = 1; -- if (arm_kdump_phys_base(&phys_addr)) { /* Get start address of first memory block */ -- ms->kimage_voffset = ms->vmalloc_start_addr - phys_addr; -- if ((kt->flags2 & KASLR) && (kt->flags & RELOC_SET)) -- ms->kimage_voffset += (kt->relocate * -1); -- if (verify_kimage_voffset() || arm64_search_for_kimage_voffset(phys_addr)) -- errflag = 0; -- } -- -- if (errflag) { -- error(WARNING, -- "kimage_voffset cannot be determined from the dumpfile.\n"); -- error(CONT, -- "Try using the command line option: --machdep kimage_voffset=\n"); -- } -- return; -- } else { -+ } else if (KDUMP_DUMPFILE()) -+ arm_kdump_phys_base(&phys_addr); /* Get start address of first memory block */ -+ else { - error(WARNING, - "kimage_voffset cannot be determined from the dumpfile.\n"); - error(CONT, -@@ -980,25 +862,6 @@ arm64_calc_kimage_voffset(void) - ms->kimage_voffset += (kt->relocate * -1); - } - --static void --arm64_calc_physvirt_offset(void) --{ -- struct machine_specific *ms = machdep->machspec; -- 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), -- sp->value, sp->value - -- machdep->machspec->kimage_voffset) > 0) { -- ms->physvirt_offset = physvirt_offset; -- } -- } --} -- - static void - arm64_calc_phys_offset(void) - { -@@ -1022,16 +885,10 @@ arm64_calc_phys_offset(void) - physaddr_t paddr; - ulong vaddr; - struct syment *sp; -- char *string; - - if ((machdep->flags & NEW_VMEMMAP) && - ms->kimage_voffset && (sp = kernel_symbol_search("memstart_addr"))) { - if (pc->flags & PROC_KCORE) { -- if ((string = pc->read_vmcoreinfo("NUMBER(PHYS_OFFSET)"))) { -- ms->phys_offset = htol(string, QUIET, NULL); -- free(string); -- return; -- } - vaddr = symbol_value_from_proc_kallsyms("memstart_addr"); - if (vaddr == BADVAL) - vaddr = sp->value; -@@ -1094,31 +951,6 @@ arm64_calc_phys_offset(void) - fprintf(fp, "using %lx as phys_offset\n", ms->phys_offset); - } - --/* -- * Determine SECTION_SIZE_BITS either by reading VMCOREINFO or the kernel -- * config, otherwise use the 64-bit ARM default definiton. -- */ --static void --arm64_get_section_size_bits(void) --{ -- int ret; -- char *string; -- -- machdep->section_size_bits = _SECTION_SIZE_BITS; -- -- if ((string = pc->read_vmcoreinfo("NUMBER(SECTION_SIZE_BITS)"))) { -- machdep->section_size_bits = atol(string); -- free(string); -- } else if (kt->ikconfig_flags & IKCONFIG_AVAIL) { -- if ((ret = get_kernel_config("CONFIG_MEMORY_HOTPLUG", NULL)) == IKCONFIG_Y) { -- if ((ret = get_kernel_config("CONFIG_HOTPLUG_SIZE_BITS", &string)) == IKCONFIG_STR) -- machdep->section_size_bits = atol(string); -- } -- } -- -- if (CRASHDEBUG(1)) -- fprintf(fp, "SECTION_SIZE_BITS: %ld\n", machdep->section_size_bits); --} - - /* - * Determine PHYS_OFFSET either by reading VMCOREINFO or the kernel -@@ -1174,14 +1006,9 @@ ulong - arm64_VTOP(ulong addr) - { - if (machdep->flags & NEW_VMEMMAP) { -- if (machdep->machspec->VA_START && -- (addr >= machdep->machspec->kimage_text) && -- (addr <= machdep->machspec->kimage_end)) { -- return addr - machdep->machspec->kimage_voffset; -- } -- - if (addr >= machdep->machspec->page_offset) -- return addr + machdep->machspec->physvirt_offset; -+ return machdep->machspec->phys_offset -+ + (addr - machdep->machspec->page_offset); - else if (machdep->machspec->kimage_voffset) - return addr - machdep->machspec->kimage_voffset; - else /* no randomness */ -@@ -1255,11 +1082,6 @@ arm64_uvtop(struct task_context *tc, ulong uvaddr, physaddr_t *paddr, int verbos - } - } - --#define PTE_ADDR_LOW ((((1UL) << (48 - machdep->pageshift)) - 1) << machdep->pageshift) --#define PTE_ADDR_HIGH ((0xfUL) << 12) --#define PTE_TO_PHYS(pteval) (machdep->max_physmem_bits == 52 ? \ -- (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) << 36))) : (pteval & PTE_ADDR_LOW)) -- - #define PUD_TYPE_MASK 3 - #define PUD_TYPE_SECT 1 - #define PMD_TYPE_MASK 3 -@@ -1355,7 +1177,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose) - * #define __PAGETABLE_PUD_FOLDED - */ - -- pmd_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val)); -+ pmd_base = (ulong *)PTOV(pgd_val & PHYS_MASK & (s32)machdep->pagemask); - FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L3_64K * sizeof(ulong)); - pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L3_64K) & (PTRS_PER_PMD_L3_64K - 1)); - pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr)); -@@ -1365,7 +1187,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose) - goto no_page; - - if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) { -- ulong sectionbase = PTE_TO_PHYS(pmd_val) & SECTION_PAGE_MASK_512MB; -+ ulong sectionbase = (pmd_val & SECTION_PAGE_MASK_512MB) & PHYS_MASK; - if (verbose) { - fprintf(fp, " PAGE: %lx (512MB)\n\n", sectionbase); - arm64_translate_pte(pmd_val, 0, 0); -@@ -1374,7 +1196,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose) - return TRUE; - } - -- pte_base = (ulong *)PTOV(PTE_TO_PHYS(pmd_val)); -+ pte_base = (ulong *)PTOV(pmd_val & PHYS_MASK & (s32)machdep->pagemask); - FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L3_64K * sizeof(ulong)); - pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) & (PTRS_PER_PTE_L3_64K - 1)); - pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr)); -@@ -1384,7 +1206,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose) - goto no_page; - - if (pte_val & PTE_VALID) { -- *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr); -+ *paddr = (PAGEBASE(pte_val) & PHYS_MASK) + PAGEOFFSET(vaddr); - if (verbose) { - fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr)); - arm64_translate_pte(pte_val, 0, 0); -@@ -1696,11 +1518,10 @@ arm64_stackframe_init(void) - machdep->machspec->kern_eframe_offset = SIZE(pt_regs); - } - -- if ((sp1 = kernel_symbol_search("__exception_text_start")) && -- (sp2 = kernel_symbol_search("__exception_text_end"))) { -- machdep->machspec->__exception_text_start = sp1->value; -- machdep->machspec->__exception_text_end = sp2->value; -- } -+ machdep->machspec->__exception_text_start = -+ symbol_value("__exception_text_start"); -+ machdep->machspec->__exception_text_end = -+ symbol_value("__exception_text_end"); - if ((sp1 = kernel_symbol_search("__irqentry_text_start")) && - (sp2 = kernel_symbol_search("__irqentry_text_end"))) { - machdep->machspec->__irqentry_text_start = sp1->value; -@@ -1826,14 +1647,13 @@ static int - arm64_is_kernel_exception_frame(struct bt_info *bt, ulong stkptr) - { - struct arm64_pt_regs *regs; -- struct machine_specific *ms = machdep->machspec; - - regs = (struct arm64_pt_regs *)&bt->stackbuf[(ulong)(STACK_OFFSET_TYPE(stkptr))]; - - if (INSTACK(regs->sp, bt) && INSTACK(regs->regs[29], bt) && - !(regs->pstate & (0xffffffff00000000ULL | PSR_MODE32_BIT)) && - is_kernel_text(regs->pc) && -- is_kernel_text(regs->regs[30] | ms->CONFIG_ARM64_KERNELPACMASK)) { -+ is_kernel_text(regs->regs[30])) { - switch (regs->pstate & PSR_MODE_MASK) - { - case PSR_MODE_EL1t: -@@ -1910,38 +1730,20 @@ arm64_eframe_search(struct bt_info *bt) - return count; - } - --static char *arm64_exception_functions[] = { -- "do_undefinstr", -- "do_sysinstr", -- "do_debug_exception", -- "do_mem_abort", -- "do_el0_irq_bp_hardening", -- "do_sp_pc_abort", -- NULL --}; -- - static int - arm64_in_exception_text(ulong ptr) - { - struct machine_specific *ms = machdep->machspec; -- char *name, **func; -+ -+ if ((ptr >= ms->__exception_text_start) && -+ (ptr < ms->__exception_text_end)) -+ return TRUE; - - if (ms->__irqentry_text_start && ms->__irqentry_text_end && - ((ptr >= ms->__irqentry_text_start) && - (ptr < ms->__irqentry_text_end))) - return TRUE; - -- if (ms->__exception_text_start && ms->__exception_text_end) { -- if ((ptr >= ms->__exception_text_start) && -- (ptr < ms->__exception_text_end)) -- return TRUE; -- } else if ((name = closest_symbol(ptr))) { /* Linux 5.5 and later */ -- for (func = &arm64_exception_functions[0]; *func; func++) { -- if (STREQ(name, *func)) -- return TRUE; -- } -- } -- - return FALSE; - } - -@@ -1977,7 +1779,6 @@ arm64_print_stackframe_entry(struct bt_info *bt, int level, struct arm64_stackfr - * See, for example, "bl schedule" before ret_to_user(). - */ - branch_pc = frame->pc - 4; -- - name = closest_symbol(branch_pc); - name_plus_offset = NULL; - -@@ -2189,7 +1990,7 @@ arm64_unwind_frame(struct bt_info *bt, struct arm64_stackframe *frame) - unsigned long stack_mask; - unsigned long irq_stack_ptr, orig_sp; - struct arm64_pt_regs *ptregs; -- struct machine_specific *ms = machdep->machspec; -+ struct machine_specific *ms; - - stack_mask = (unsigned long)(ARM64_STACK_SIZE) - 1; - fp = frame->fp; -@@ -2203,8 +2004,6 @@ arm64_unwind_frame(struct bt_info *bt, struct arm64_stackframe *frame) - frame->sp = fp + 0x10; - frame->fp = GET_STACK_ULONG(fp); - frame->pc = GET_STACK_ULONG(fp + 8); -- if (is_kernel_text(frame->pc | ms->CONFIG_ARM64_KERNELPACMASK)) -- frame->pc |= ms->CONFIG_ARM64_KERNELPACMASK; - - if ((frame->fp == 0) && (frame->pc == 0)) - return FALSE; -@@ -2256,6 +2055,7 @@ arm64_unwind_frame(struct bt_info *bt, struct arm64_stackframe *frame) - * irq_stack_ptr = IRQ_STACK_PTR(raw_smp_processor_id()); - * orig_sp = IRQ_STACK_TO_TASK_STACK(irq_stack_ptr); (pt_regs pointer on process stack) - */ -+ ms = machdep->machspec; - irq_stack_ptr = ms->irq_stacks[bt->tc->processor] + ms->irq_stack_size - 16; - - if (frame->sp == irq_stack_ptr) { -@@ -2857,8 +2657,6 @@ arm64_print_text_symbols(struct bt_info *bt, struct arm64_stackframe *frame, FIL - char buf2[BUFSIZE]; - char *name; - ulong start; -- ulong val; -- struct machine_specific *ms = machdep->machspec; - - if (bt->flags & BT_TEXT_SYMBOLS_ALL) - start = bt->stackbase; -@@ -2873,10 +2671,8 @@ arm64_print_text_symbols(struct bt_info *bt, struct arm64_stackframe *frame, FIL - - for (i = (start - bt->stackbase)/sizeof(ulong); i < LONGS_PER_STACK; i++) { - up = (ulong *)(&bt->stackbuf[i*sizeof(ulong)]); -- val = *up; -- if (is_kernel_text(val | ms->CONFIG_ARM64_KERNELPACMASK)) { -- val |= ms->CONFIG_ARM64_KERNELPACMASK; -- name = closest_symbol(val); -+ if (is_kernel_text(*up)) { -+ name = closest_symbol(*up); - fprintf(ofp, " %s[%s] %s at %lx", - bt->flags & BT_ERROR_MASK ? - " " : "", -@@ -2885,13 +2681,13 @@ arm64_print_text_symbols(struct bt_info *bt, struct arm64_stackframe *frame, FIL - MKSTR(bt->stackbase + - (i * sizeof(long)))), - bt->flags & BT_SYMBOL_OFFSET ? -- value_to_symstr(val, buf2, bt->radix) : -- name, val); -- if (module_symbol(val, NULL, &lm, NULL, 0)) -+ value_to_symstr(*up, buf2, bt->radix) : -+ name, *up); -+ if (module_symbol(*up, NULL, &lm, NULL, 0)) - fprintf(ofp, " [%s]", lm->mod_name); - fprintf(ofp, "\n"); - if (BT_REFERENCE_CHECK(bt)) -- arm64_do_bt_reference_check(bt, val, name); -+ arm64_do_bt_reference_check(bt, *up, name); - } - } - } -@@ -3194,7 +2990,6 @@ arm64_print_exception_frame(struct bt_info *bt, ulong pt_regs, int mode, FILE *o - struct syment *sp; - ulong LR, SP, offset; - char buf[BUFSIZE]; -- struct machine_specific *ms = machdep->machspec; - - if (CRASHDEBUG(1)) - fprintf(ofp, "pt_regs: %lx\n", pt_regs); -@@ -3210,8 +3005,6 @@ arm64_print_exception_frame(struct bt_info *bt, ulong pt_regs, int mode, FILE *o - rows = 4; - } else { - LR = regs->regs[30]; -- if (is_kernel_text (LR | ms->CONFIG_ARM64_KERNELPACMASK)) -- LR |= ms->CONFIG_ARM64_KERNELPACMASK; - SP = regs->sp; - top_reg = 29; - is_64_bit = TRUE; -@@ -3359,7 +3152,7 @@ arm64_translate_pte(ulong pte, void *physaddr, ulonglong unused) - char *arglist[MAXARGS]; - int page_present; - -- paddr = PTE_TO_PHYS(pte); -+ paddr = pte & PHYS_MASK & (s32)machdep->pagemask; - page_present = pte & (PTE_VALID | machdep->machspec->PTE_PROT_NONE); - - if (physaddr) { -@@ -3625,8 +3418,8 @@ arm64_display_machine_stats(void) - fprintf(fp, " HZ: %d\n", machdep->hz); - fprintf(fp, " PAGE SIZE: %d\n", PAGESIZE()); - fprintf(fp, "KERNEL VIRTUAL BASE: %lx\n", machdep->machspec->page_offset); -- fprintf(fp, "KERNEL MODULES BASE: %lx\n", machdep->machspec->modules_vaddr); - fprintf(fp, "KERNEL VMALLOC BASE: %lx\n", machdep->machspec->vmalloc_start_addr); -+ fprintf(fp, "KERNEL MODULES BASE: %lx\n", machdep->machspec->modules_vaddr); - fprintf(fp, "KERNEL VMEMMAP BASE: %lx\n", machdep->machspec->vmemmap_vaddr); - fprintf(fp, " KERNEL STACK SIZE: %ld\n", STACKSIZE()); - if (machdep->machspec->irq_stack_size) { -@@ -3656,7 +3449,7 @@ arm64_get_smp_cpus(void) - /* - * Retrieve task registers for the time of the crash. - */ --static void -+static int - arm64_get_crash_notes(void) - { - struct machine_specific *ms = machdep->machspec; -@@ -3665,10 +3458,10 @@ arm64_get_crash_notes(void) - ulong offset; - char *buf, *p; - ulong *notes_ptrs; -- ulong i, found; -+ ulong i; - - if (!symbol_exists("crash_notes")) -- return; -+ return FALSE; - - crash_notes = symbol_value("crash_notes"); - -@@ -3680,9 +3473,9 @@ arm64_get_crash_notes(void) - */ - if (!readmem(crash_notes, KVADDR, ¬es_ptrs[kt->cpus-1], - sizeof(notes_ptrs[kt->cpus-1]), "crash_notes", RETURN_ON_ERROR)) { -- error(WARNING, "cannot read \"crash_notes\"\n"); -+ error(WARNING, "cannot read crash_notes\n"); - FREEBUF(notes_ptrs); -- return; -+ return FALSE; - } - - if (symbol_exists("__per_cpu_offset")) { -@@ -3698,11 +3491,12 @@ arm64_get_crash_notes(void) - if (!(ms->panic_task_regs = calloc((size_t)kt->cpus, sizeof(struct arm64_pt_regs)))) - error(FATAL, "cannot calloc panic_task_regs space\n"); - -- for (i = found = 0; i < kt->cpus; i++) { -+ for (i = 0; i < kt->cpus; i++) { -+ - if (!readmem(notes_ptrs[i], KVADDR, buf, SIZE(note_buf), - "note_buf_t", RETURN_ON_ERROR)) { -- error(WARNING, "cpu %d: cannot read NT_PRSTATUS note\n", i); -- continue; -+ error(WARNING, "failed to read note_buf_t\n"); -+ goto fail; - } - - /* -@@ -3732,24 +3526,19 @@ arm64_get_crash_notes(void) - note->n_descsz == notesz) - BCOPY((char *)note, buf, notesz); - } else { -- error(WARNING, "cpu %d: cannot find NT_PRSTATUS note\n", i); -+ error(WARNING, -+ "cannot find NT_PRSTATUS note for cpu: %d\n", i); - continue; - } - } - -- /* -- * Check the sanity of NT_PRSTATUS note only for each online cpu. -- * If this cpu has invalid note, continue to find the crash notes -- * for other online cpus. -- */ - if (note->n_type != NT_PRSTATUS) { -- error(WARNING, "cpu %d: invalid NT_PRSTATUS note (n_type != NT_PRSTATUS)\n", i); -- continue; -+ error(WARNING, "invalid note (n_type != NT_PRSTATUS)\n"); -+ goto fail; - } -- -- if (!STRNEQ(p, "CORE")) { -- error(WARNING, "cpu %d: invalid NT_PRSTATUS note (name != \"CORE\")\n", i); -- continue; -+ if (p[0] != 'C' || p[1] != 'O' || p[2] != 'R' || p[3] != 'E') { -+ error(WARNING, "invalid note (name != \"CORE\"\n"); -+ goto fail; - } - - /* -@@ -3762,17 +3551,18 @@ arm64_get_crash_notes(void) - - BCOPY(p + OFFSET(elf_prstatus_pr_reg), &ms->panic_task_regs[i], - sizeof(struct arm64_pt_regs)); -- -- found++; - } - - FREEBUF(buf); - FREEBUF(notes_ptrs); -+ return TRUE; - -- if (!found) { -- free(ms->panic_task_regs); -- ms->panic_task_regs = NULL; -- } -+fail: -+ FREEBUF(buf); -+ FREEBUF(notes_ptrs); -+ free(ms->panic_task_regs); -+ ms->panic_task_regs = NULL; -+ return FALSE; - } - - static void -@@ -3896,13 +3686,9 @@ arm64_IS_VMALLOC_ADDR(ulong vaddr) - (vaddr <= machdep->machspec->kimage_end)) - return FALSE; - -- if (ms->VA_START && (vaddr >= ms->VA_START)) -- return TRUE; -- - return ((vaddr >= ms->vmalloc_start_addr && vaddr <= ms->vmalloc_end) || - ((machdep->flags & VMEMMAP) && -- ((vaddr >= ms->vmemmap_vaddr && vaddr <= ms->vmemmap_end) || -- (vaddr >= ms->vmalloc_end && vaddr <= ms->vmemmap_vaddr))) || -+ (vaddr >= ms->vmemmap_vaddr && vaddr <= ms->vmemmap_end)) || - (vaddr >= ms->modules_vaddr && vaddr <= ms->modules_end)); - } - -@@ -3911,57 +3697,9 @@ arm64_calc_VA_BITS(void) - { - int bitval; - struct syment *sp; -- ulong vabits_actual, value; -+ ulong value; - char *string; - -- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) { -- value = atol(string); -- free(string); -- machdep->machspec->CONFIG_ARM64_VA_BITS = value; -- } -- -- if (kernel_symbol_exists("vabits_actual")) { -- if (pc->flags & PROC_KCORE) { -- vabits_actual = symbol_value_from_proc_kallsyms("vabits_actual"); -- if ((vabits_actual != BADVAL) && (READMEM(pc->mfd, &value, sizeof(ulong), -- vabits_actual, KCORE_USE_VADDR) > 0)) { -- if (CRASHDEBUG(1)) -- fprintf(fp, -- "/proc/kcore: vabits_actual: %ld\n", value); -- machdep->machspec->VA_BITS_ACTUAL = value; -- machdep->machspec->VA_BITS = value; -- machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL); -- } else -- error(FATAL, "/proc/kcore: cannot read vabits_actual\n"); -- } else if (ACTIVE()) -- error(FATAL, "cannot determine VA_BITS_ACTUAL: please use /proc/kcore\n"); -- else { -- if ((string = pc->read_vmcoreinfo("NUMBER(TCR_EL1_T1SZ)"))) { -- /* See ARMv8 ARM for the description of -- * TCR_EL1.T1SZ and how it can be used -- * to calculate the vabits_actual -- * supported by underlying kernel. -- * -- * Basically: -- * vabits_actual = 64 - T1SZ; -- */ -- value = 64 - strtoll(string, NULL, 0); -- if (CRASHDEBUG(1)) -- fprintf(fp, "vmcoreinfo : vabits_actual: %ld\n", value); -- free(string); -- machdep->machspec->VA_BITS_ACTUAL = value; -- machdep->machspec->VA_BITS = value; -- machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL); -- } else if (machdep->machspec->VA_BITS_ACTUAL) { -- machdep->machspec->VA_BITS = machdep->machspec->VA_BITS_ACTUAL; -- machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL); -- } else -- error(FATAL, "cannot determine VA_BITS_ACTUAL\n"); -- } -- -- return; -- } -- - if (!(sp = symbol_search("swapper_pg_dir")) && - !(sp = symbol_search("idmap_pg_dir")) && - !(sp = symbol_search("_text")) && -@@ -3990,12 +3728,14 @@ arm64_calc_VA_BITS(void) - /* - * Verify against dumpfiles that export VA_BITS in vmcoreinfo - */ -- if (machdep->machspec->CONFIG_ARM64_VA_BITS && -- (machdep->machspec->VA_BITS != machdep->machspec->CONFIG_ARM64_VA_BITS)) { -- error(WARNING, "VA_BITS: calculated: %ld vmcoreinfo: %ld\n", -- machdep->machspec->VA_BITS, machdep->machspec->CONFIG_ARM64_VA_BITS); -- machdep->machspec->VA_BITS = machdep->machspec->CONFIG_ARM64_VA_BITS; -- } -+ if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) { -+ value = atol(string); -+ free(string); -+ if (machdep->machspec->VA_BITS != value) -+ error(WARNING, "VA_BITS: calculated: %ld vmcoreinfo: %ld\n", -+ machdep->machspec->VA_BITS, value); -+ } -+ - - if (CRASHDEBUG(1)) - fprintf(fp, "VA_BITS: %ld\n", machdep->machspec->VA_BITS); -@@ -4013,15 +3753,6 @@ arm64_calc_VA_BITS(void) - * - * Since VMEMMAP_SIZE is dependent upon the size of a struct page, - * the two ranges cannot be determined until POST_GDB. -- * -- * Since 52-bit VA was introduced: -- * -- * #define STRUCT_PAGE_MAX_SHIFT 6 -- * #define VMEMMAP_SIZE (UL(1) << (VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)) -- * #define VMEMMAP_START (-VMEMMAP_SIZE) -- * #define VMALLOC_START (MODULES_END) -- * #define VMALLOC_END (- PUD_SIZE - VMEMMAP_SIZE - SZ_64K) -- * #define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) - */ - - #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) -@@ -4033,23 +3764,10 @@ static void - arm64_calc_virtual_memory_ranges(void) - { - struct machine_specific *ms = machdep->machspec; -- ulong value, vmemmap_start, vmemmap_end, vmemmap_size, vmalloc_end; -- char *string; -- int ret; -+ ulong vmemmap_start, vmemmap_end, vmemmap_size; -+ ulong vmalloc_end; - ulong PUD_SIZE = UNINITIALIZED; - -- if (!machdep->machspec->CONFIG_ARM64_VA_BITS) { -- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) { -- value = atol(string); -- free(string); -- machdep->machspec->CONFIG_ARM64_VA_BITS = value; -- } else if (kt->ikconfig_flags & IKCONFIG_AVAIL) { -- if ((ret = get_kernel_config("CONFIG_ARM64_VA_BITS", -- &string)) == IKCONFIG_STR) -- machdep->machspec->CONFIG_ARM64_VA_BITS = atol(string); -- } -- } -- - if (THIS_KERNEL_VERSION < LINUX(3,17,0)) /* use original hardwired values */ - return; - -@@ -4068,24 +3786,8 @@ arm64_calc_virtual_memory_ranges(void) - break; - } - --#define STRUCT_PAGE_MAX_SHIFT 6 -- -- if (ms->VA_BITS_ACTUAL) { -- ulong va_bits_min = 48; -- -- if (machdep->machspec->CONFIG_ARM64_VA_BITS < 48) -- va_bits_min = ms->CONFIG_ARM64_VA_BITS; -- -- vmemmap_size = (1UL) << (va_bits_min - machdep->pageshift - 1 + STRUCT_PAGE_MAX_SHIFT); -- vmalloc_end = (- PUD_SIZE - vmemmap_size - KILOBYTES(64)); -- vmemmap_start = (-vmemmap_size - MEGABYTES(2)); -- ms->vmalloc_end = vmalloc_end - 1; -- ms->vmemmap_vaddr = vmemmap_start; -- ms->vmemmap_end = -1; -- return; -- } -- - if (machdep->flags & NEW_VMEMMAP) -+#define STRUCT_PAGE_MAX_SHIFT 6 - vmemmap_size = 1UL << (ms->VA_BITS - machdep->pageshift - 1 - + STRUCT_PAGE_MAX_SHIFT); - else -@@ -4109,7 +3811,7 @@ arm64_calc_virtual_memory_ranges(void) - static int - arm64_is_uvaddr(ulong addr, struct task_context *tc) - { -- return (addr < machdep->machspec->userspace_top); -+ return (addr < ARM64_USERSPACE_TOP); - } - - -@@ -4134,20 +3836,6 @@ arm64_swp_offset(ulong pte) - return pte; - } - --static void arm64_calc_KERNELPACMASK(void) --{ -- ulong value; -- char *string; -- -- if ((string = pc->read_vmcoreinfo("NUMBER(KERNELPACMASK)"))) { -- value = htol(string, QUIET, NULL); -- free(string); -- machdep->machspec->CONFIG_ARM64_KERNELPACMASK = value; -- if (CRASHDEBUG(1)) -- fprintf(fp, "CONFIG_ARM64_KERNELPACMASK: %lx\n", value); -- } --} -- - #endif /* ARM64 */ - - -diff --git a/defs.h b/defs.h -index 396d61aaf532..897386160abd 100644 ---- a/defs.h -+++ b/defs.h -@@ -3087,7 +3087,7 @@ typedef u64 pte_t; - #define MACHINE_TYPE "ARM64" - - #define PTOV(X) \ -- ((unsigned long)(X) - (machdep->machspec->physvirt_offset)) -+ ((unsigned long)(X)-(machdep->machspec->phys_offset)+(machdep->machspec->page_offset)) - - #define VTOP(X) arm64_VTOP((ulong)(X)) - -@@ -3221,17 +3221,9 @@ typedef signed int s32; - */ - #define ARM64_VA_START ((0xffffffffffffffffUL) \ - << machdep->machspec->VA_BITS) --#define _VA_START(va) ((0xffffffffffffffffUL) - \ -- ((1UL) << ((va) - 1)) + 1) --#define TEXT_OFFSET_MASK (~((MEGABYTES(2UL))-1)) -- - #define ARM64_PAGE_OFFSET ((0xffffffffffffffffUL) \ - << (machdep->machspec->VA_BITS - 1)) --#define ARM64_PAGE_OFFSET_ACTUAL ((0xffffffffffffffffUL) \ -- - ((1UL) << machdep->machspec->VA_BITS_ACTUAL) + 1) -- - #define ARM64_USERSPACE_TOP ((1UL) << machdep->machspec->VA_BITS) --#define ARM64_USERSPACE_TOP_ACTUAL ((1UL) << machdep->machspec->VA_BITS_ACTUAL) - - /* only used for v4.6 or later */ - #define ARM64_MODULES_VSIZE MEGABYTES(128) -@@ -3334,11 +3326,7 @@ struct machine_specific { - ulong kern_eframe_offset; - ulong machine_kexec_start; - ulong machine_kexec_end; -- ulong VA_BITS_ACTUAL; -- ulong CONFIG_ARM64_VA_BITS; -- ulong VA_START; -- ulong CONFIG_ARM64_KERNELPACMASK; -- ulong physvirt_offset; -+ ulong vabits_user; - }; - - struct arm64_stackframe { -@@ -3626,8 +3614,6 @@ struct arm64_stackframe { - machdep->machspec->last_p4d_read = (ulong)(P4D); \ - } - --#define MAX_POSSIBLE_PHYSMEM_BITS 52 -- - /* - * PHYSICAL_PAGE_MASK changed (enlarged) between 2.4 and 2.6, so - * for safety, use the 2.6 values to generate it. --- -2.17.1 - diff --git a/SOURCES/rhel8_build.patch b/SOURCES/rhel8_build.patch index b1c9eae..c7e4587 100644 --- a/SOURCES/rhel8_build.patch +++ b/SOURCES/rhel8_build.patch @@ -1,7 +1,7 @@ -diff --git crash-7.3.0/Makefile crash-7.3.0/Makefile +diff --git crash-7.3.1/Makefile crash-7.3.1/Makefile index d0574d8f07d3..9dbb61d0dbc8 100644 ---- crash-7.3.0/Makefile -+++ crash-7.3.0/Makefile +--- crash-7.3.1/Makefile ++++ crash-7.3.1/Makefile @@ -198,7 +198,7 @@ GDB_FLAGS= # TARGET_CFLAGS will be configured automatically by configure TARGET_CFLAGS= @@ -20,10 +20,10 @@ index d0574d8f07d3..9dbb61d0dbc8 100644 @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj @rm -f ${PROGRAM} @if [ ! -f ${GDB}/config.status ]; then \ -diff --git crash-7.3.0/configure.c crash-7.3.0/configure.c +diff --git crash-7.3.1/configure.c crash-7.3.1/configure.c index 75006e881f5a..06c94d58c56c 100644 ---- crash-7.3.0/configure.c -+++ crash-7.3.0/configure.c +--- crash-7.3.1/configure.c ++++ crash-7.3.1/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]); diff --git a/SPECS/crash.spec b/SPECS/crash.spec index 2ebe779..752684a 100644 --- a/SPECS/crash.spec +++ b/SPECS/crash.spec @@ -3,8 +3,8 @@ # Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash -Version: 7.3.0 -Release: 3%{?dist} +Version: 7.3.1 +Release: 1%{?dist} License: GPLv3 Group: Development/Debuggers Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz @@ -13,18 +13,12 @@ URL: https://crash-utility.github.io ExclusiveOS: Linux ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x %{arm} aarch64 ppc64le Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot-%(%{__id_u} -n) -BuildRequires: ncurses-devel zlib-devel lzo-devel bison snappy-devel +BuildRequires: ncurses-devel zlib-devel lzo-devel bison snappy-devel libzstd-devel Requires: binutils Provides: bundled(gdb) = 7.6 Patch0: lzo_snappy.patch Patch1: rhel8_build.patch -Patch2: rhel8_arm64_52_bit_fix.patch -Patch3: 0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch -Patch4: 0002-Fix-waitq-command-for-Linux-4.13-and-later-kernels.patch -Patch5: 0003-Handle-task_struct-state-member-changes-for-kernels-.patch -Patch6: 0004-Handle-task_struct-cpu-member-changes-for-kernels-5..patch -Patch7: 0005-Fix-live-debugging-with-lockdown-integrity.patch -Patch8: rhel8_freepointer.patch +Patch2: rhel8_freepointer.patch %description The core analysis suite is a self-contained tool that can be used to @@ -47,13 +41,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %setup -n %{name}-%{version} -q %patch0 -p1 -b lzo_snappy.patch %patch1 -p1 -b rhel8_build.patch -%patch2 -p1 -b rhel8_arm64_52_bit_fix.patch -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 +%patch2 -p1 -b rhel8_freepointer.patch %build cp %{SOURCE1} . @@ -84,6 +72,9 @@ rm -rf %{buildroot} %{_includedir}/* %changelog +* Fri Nov 26 2021 Lianbo Jiang - 7.3.1-1 +- Rebase to the latest crash-7.3.1 + * Thu Nov 18 2021 Lianbo Jiang - 7.3.0-3 - Fix for "sched: Change task_struct::state" - Fix for "sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y" @@ -109,7 +100,7 @@ rm -rf %{buildroot} - Also minimize the rhel-only patches to the bare minimum. Resolves: rhbz#1881854 -* Wed Nov 5 2020 Bhupesh Sharma - 7.2.8-8 +* Thu Nov 5 2020 Bhupesh Sharma - 7.2.8-8 - crash/arm64: Fix arm64 read error with 'idmap_ptrs_per_pgd' symbol with debug kernel Resolves: rhbz#1876039