Commit Graph

595 Commits

Author SHA1 Message Date
Dave Anderson
3b05002917 First phase of support for the XArray facility. The added support is
similar to that of radix trees, but introduces completely separate
functions, structures and #defines.  None of the applicable radix
tree users in the crash utility have been switched over, so this
phase does not introduce any functional changes.
(asmadeus@codewreck.org, anderson@redhat.com)
2018-11-12 15:59:30 -05:00
Dave Anderson
f701ecad0f Implemented the functionality for a new MEMBER_TYPE_NAME() macro,
which will return a pointer to the type name string of a structure
member.  It is being put in place for the support of Linux 4.20
radix tree to xarray replacements, where structure member types may
be changed from radix_tree_root structures to xarray structures.
(anderson@redhat.com)
2018-11-07 12:02:51 -05:00
Dave Anderson
1798302ed8 Fix for Linux 4.20-rc1 and later kernels that contain kernel commit
5c83511bdb9832c86be20fb86b783356e2f58062, titled "x86/paravirt: Use
a single ops structure".  Without the patch, the kernel may be
misidentified as an ARCH_XEN kernel, with the most noticable result
being the inability to read vmemmap'd page structures.
(anderson@redhat.com)
2018-11-05 15:22:22 -05:00
Dave Anderson
60a42d7092 Second phase of support for the VMCOREINFO PT_NOTE added to the ELF
header of /proc/kcore in Linux 4.19 and later kernels.  This patch
introduces support for live session /proc/kcore VMCOREINFO access by
the crash utility's internal pc->read_vmcoreinfo() function.  New
usage include the initialization of the x86_64 phys_base value, and
the arm64 phys_offset, page size, and VA bits count.
(anderson@redhat.com)
2018-10-31 11:29:39 -04:00
Dave Anderson
4a8e523cd3 Account for the /proc/kcore VMCOREINFO PT_NOTE in Linux 4.19 and
later kernels having commit 23c85094fe1895caefdd19ef624ee687ec5f4507,
titled "proc/kcore: add vmcoreinfo note to /proc/kcore".  The PT_NOTE
information is stored during session initialization for later display
by "help -[n|D]"; a subsequent commit will make it available for use
by the crash utility's internal pc->read_vmcoreinfo() function.
(anderson@redhat.com)
2018-10-25 16:29:00 -04:00
Dave Anderson
f3a5305947 Modify the x86_64 "bt" behavior when a legitimate exception RIP value
cannot be referenced symbolically, such as when the exception occurs
while running in seccomp BPF filter code.  Without the patch, the
exception frame register dump is preceded by "[exception RIP: unknown
or invalid address]", and then followed by "bt: WARNING: possibly
bogus exception frame".  With the patch applied, the translation of
the exception RIP will show "[exception RIP: no symbolic reference]",
and there will be no warning message.
(anderson@redhat.com)
2018-10-24 16:25:43 -04:00
Dave Anderson
c5f45d6cdb Address several Coverity Scan "RESOURCE_LEAK" issues in the following
top-level source files: cmdline.c, kvmdump.c, lkcd_v8.c, xendump.c,
symbols.c, unwind_x86_32_64.c, va_server.c and va_server_v1.c.
(anderson@redhat.com)
2018-10-11 13:28:39 -04:00
Dave Anderson
3141bba98a Fix the calculation of the vmalloc memory region size to account for
Linux 4.17 commit a7412546d8cb5ad578805060b4006f2a021b5868, titled
"x86/mm: Adjust vmalloc base and size at boot-time", which increases
the region's size from 32TB to 1280TB when 5-level pagetables are
enabled.  Also presume that virtual addresses above the end of the
vmalloc space up to the beginning of vmemmap space are translatable
via 5-level page tables.  Without the patch, mapped virtual addresses
may fail translation in whatever command accesses them, with errors
indicating "seek error: kernel virtual address: <mapped-address>
type: <type-string>"
(anderson@redhat.com)
2018-10-10 09:15:42 -04:00
Dave Anderson
bcbbd24924 Addendum to the previous "kmem -n" patch to fix a FTBFS issue.
Without the patch, certain architectures fail to compile with the
error "memory.c:17315:16: error: ‘PAGE_SHIFT’ undeclared (first
use in this function)"
(m.mizuma@jp.fujitsu.com)
2018-10-05 11:12:00 -04:00
Dave Anderson
e342618cb4 Enhancement to the "kmem -n" option to dump memory block information
if the kernel supports it.  In addition, the memory section data
block has a new "STATE" column added to it.
(m.mizuma@jp.fujitsu.com)
2018-10-04 16:52:22 -04:00
Dave Anderson
ced5255233 As an addendum to the "dev -p" patch above, add the new structure
member offsets for display by the "help -o" option.
(anderson@redhat.com)
2018-10-02 11:18:09 -04:00
Dave Anderson
72cc0cba8a Fix for the PPC64 "bt" command to recognize when a thread is running
in OPAL firmware.  Without the patch, the "bt" command indicates
<task-address>: Invalid Stack Pointer <OPAL-firmware-address>"
(hbathini@linux.ibm.com)
2018-10-02 10:56:28 -04:00
Dave Anderson
ac8738376f Fix to allow piping command output to a shell script beginning with
a shebang (#!) character sequence if the script pathname is specified
with a preceding "./" or "/".  Without the patch, the piped command
fails with the message "crash: pipe operation failed".
(k-hagio@ab.jp.nec.com)
2018-09-27 15:23:19 -04:00
Dave Anderson
599a6579aa With Linux 4.19-rc1 commit 7d4340bb92a9df78e6e28152f3dd89d9bd82146b,
titled "powerpc/mm: Increase MAX_PHYSMEM_BITS to 128TB with
SPARSEMEM_VMEMMAP config", the PPC64 MAX_PHYSMEM_BITS value has
been bumped up to 47.  The appropriate update has been made in
this patch.
(hbathini@linux.ibm.com)
2018-09-27 14:14:31 -04:00
Dave Anderson
27a6ebd0cd Resurrection of the the "dev -p" option for displaying PCI device
data on Linux 2.6.26 and later kernels.  The option was deprecated
as of Linux 2.6.26, and without the patch, the option would indicate
"dev: -p option not supported or applicable on this architecture
or kernel" when running against the newer kernel versions.  PCI Bus
information will also be displayed with this patch.
(m.mizuma@jp.fujitsu.com)
2018-09-24 16:33:57 -04:00
Dave Anderson
56a4f28175 Mark start of 7.2.5 development phase with version 7.2.4++ 2018-09-24 14:26:55 -04:00
Dave Anderson
66881fb1ba crash-7.2.3 -> crash-7.2.4 2018-09-21 14:56:21 -04:00
Dave Anderson
7e39368953 An addendum to crash commit 5fe78861ea,
this patch for the PPC64 "bt" command prevents an invalid error
message from being displayed when an active non-panic task is
interrupted while running in user space.  Without the patch, the
command correctly indicates "Task is running in user space", dumps
the user-space exception frame, but then prints the invalid error
message "bt: invalid kernel virtual address: ffffffffffffff90 type:
Regs NIP value".
(anderson@redhat.com)
2018-09-17 14:33:08 -04:00
Dave Anderson
5fe78861ea Commit 3db3d3992d in crash-7.1.8 was
aimed at making the PPC64 "bt" command work for dumpfiles saved
with the FADUMP facility, but it introduced a bit of unwarranted
complexity in "bt" command processing.  Reworked the "bt" command
processing for PPC64 arch to make it a little less compilated and
also to print symbols for NIP and LR registers in exception frames.
Without the patch, "bt" on non-panic active tasks may fail with
the message "bt: invalid kernel virtual address: <address>
type: Regs NIP value".
(hbathini@linux.ibm.com)
2018-09-07 16:05:52 -04:00
Dave Anderson
b9df4d1568 Fix for the "files -p <inode>" option. Without the patch, the
command attempts to translate radix tree node slot entries that
are RADIX_TREE_EXCEPTIONAL_ENTRY types, and as a result may fail
prematurely with an error message of the sort "files: do_radix_tree:
callback operation failed: entry: 5  item: 44788c5000a".
(anderson@redhat.com)
2018-09-06 14:01:28 -04:00
Dave Anderson
2f57a96ce2 Fix for the "files" command in Linux 4.17 and later kernels that
contain commit b93b016313b3ba8003c3b8bb71f569af91f19fc7, titled
"page cache: use xa_lock".  Without the patch, the "files -c" option
fails with the message "files: -c option not supported or applicable
on this architecture or kernel", and the "files -p &lt;inode>" option
fails in a similar manner.
(k-hagio@ab.jp.nec.com)
2018-09-04 14:29:45 -04:00
Dave Anderson
55f9a294c8 Fix a cut-and-paste error in the previous patch application.
(anderson@redhat.com)
2018-08-30 09:01:57 -04:00
Dave Anderson
001f77a055 Fix for Linux 4.19-rc1 and later kernels that contain kernel commit
7290d58095712a89f845e1bca05334796dd49ed2, titled "module: use
relative references for __ksymtab entries".  Without the patch,
kernels configured with CONFIG_HAVE_ARCH_PREL32_RELOCATIONS fail
during session initialization, with a dump of the internel buffer
allocation stats followed by the message "crash: cannot allocate
any more memory!"
(asmadeus@codewreck.org)
2018-08-29 10:41:45 -04:00
Dave Anderson
d7eec45d4c Fix for Linux 4.19-rc1 and later kernels that contain kernel commit
2c4704756cab7cfa031ada4dab361562f0e357c0, titled "pids: Move the pgrp
and session pid pointers from task_struct to signal_struct".  Without
the patch, the crash session fails during initialization with the
message "crash: invalid structure member offset: task_struct_pids".
(anderson@redhat.com)
2018-08-29 09:09:47 -04:00
Dave Anderson
e541c5ca27 Introduction of a new "kmem -r" option. With the implementation of
per-cgroup kmem_cache slabs, the number of slab caches displayed by
"kmem -s" can number into the thousands.  Similar to /proc/slabinfo,
this new option displays the accumulated data of the root cache and
its children.  It is limited to Linux 4.11 and later kernels that
contain the "slab_root_caches" list.  Currently the command option
is restricted to kernels configured with CONFIG_SLUB.
(k-hagio@ab.jp.nec.com)
2018-08-24 15:17:12 -04:00
Dave Anderson
d2a164e5f1 Fix for the "kmem -V" option on Linux 4.14 and later kernels that are
configured without CONFIG_NUMA, and therefore do not contain the
"numa_stat_item" enumeration.  Without the patch, the command causes
the crash session to abort with the error messages "double free or
corruption (!prev)" followed by "Aborted (core dumped)".
(k-hagio@ab.jp.nec.com)
2018-08-22 13:24:52 -04:00
Dave Anderson
3fcb69b9ae Fix for the swap offset calculation in the x86_64 "vm -p", "pte", and
user-space "vtop" commands.  The swap offset bits in an x86_64 PTE
were changed in Linux 4.6, and then again in Linux 4.18.1 with the
new L1TF security patchset.  Without the patch, the offset value
in the later kernels, or in older kernels with an L1TF backport,
show an incorrect swap offset value.
(anderson@redhat.com)
2018-08-21 14:39:18 -04:00
Dave Anderson
4ae70cc811 Fix for the "vm -p", user-space "vtop", and "pte" commands in kernels
where the dimension of the static swap_info[] array is not contained
in the vmlinux file's debuginfo data.  Without the patch, the
translation of a swapped-out PTE entry fails to determine the swap
device, and the commands display "cannot determine swap location".
(anderson@redhat.com)
2018-08-21 10:56:13 -04:00
Dave Anderson
f6d451d64f Fix for the "trace.c" extension module for RHEL7.6, which moved the
ftrace_event_call.data member into a new structure contained within
an anonymous union.  Without the patch, the module fails to load,
indicating "no commands registered: shared object unloaded".
(xuhuan.fnst@cn.fujitsu.com)
2018-08-20 10:43:05 -04:00
Dave Anderson
c3b83dc611 Account for the addition of the new ORC unwinder "orc_entry.end"
member in kernel commit d31a580266eeb1f355df90fde8a71f480e30ad70,
titled "x86/unwind/orc: Detect the end of the stack".
(anderson@redhat.com)
2018-08-14 11:38:50 -04:00
Dave Anderson
e9532aea68 As an addendum to the new "kmem -[sS]" output format, align the slab
cache name string so that it is beneath the "NAME" header column when
the "kmem -I &lt;slab-cache>" option is used to ignore a slab cache,
or if the scan of the metadata of a slab cache enounters corruption.
Also remove a superfluous line from the "help kmem" description of
the "kmem -I" option.
(k-hagio@ab.jp.nec.com, anderson@redhat.com)
2018-08-09 11:20:26 -04:00
Dave Anderson
ba03b66cec Fix for the "files" and "net -s" commands when a task has an open
files count that exceeds 1024 (FD_SETSIZE) file descriptors.  Without
the patch, the commands may omit the display of open file descriptors.
(tan.hu@zte.com.cn)
2018-08-09 10:54:46 -04:00
Dave Anderson
455da1ae5c Modify the output of the "kmem -[sS]" header and contents such that
the slab cache name string is moved from the second column to the
the last column.  Since the slab cache name strings have become
increasingly longer over time, without the patch, the numerical
column contents may be skewed so far to the right that the output
becomes difficult to read.
(k-hagio@ab.jp.nec.com)
2018-08-08 14:20:21 -04:00
Dave Anderson
6c39a3d39b Fix for running live on ARM64 kernels against /proc/kcore on kernels
configured with CONFIG_RANDOMIZE_BASE.  Without the patch, depending
upon the hardware platform, the session may fail with the error message
"crash: vmlinux and /proc/kcore do not match!".
(anderson@redhat.com)
2018-08-08 11:31:17 -04:00
Dave Anderson
a10917ba32 Update for "ps" and "foreach" commands to display and recognize two
new process states, "ID" for the TASK_IDLE macro introduced in
Linux 4.2, and "NE" for the TASK_NEW bit introduced in Linux 4.8.
(k-hagio@ab.jp.nec.com)
2018-07-19 13:43:07 -04:00
Dave Anderson
eb823b7938 Fix to prevent an unnecessary "read error" message during session
initialization on live systems running a kernel that is configured
with CONFIG_X86_5LEVEL.  Without the patch, a message indicating
"crash: read error: kernel virtual address: &lt;address>  type:
__pgtable_l5_enabled" will be displayed if /proc/kcore gets
selected as the live memory source after /dev/mem is determined
to be unusable.
(anderson@redhat.com)
2018-07-16 10:50:19 -04:00
Dave Anderson
61fcad549f Fourth phase of support for x86_64 5-level page tables in Linux 4.17
and later kernels.  This patch adds support for user virtual address
translation when the kernel is configured with CONFIG_X86_5LEVEL.
(douly.fnst@cn.fujitsu.com)
2018-07-16 09:32:57 -04:00
Dave Anderson
528849c15a Fix for the "repeat" command when the argument consists of an input
file construct, for example, "repeat -1 < input_file".  Without the
patch, only the first command line in the input file is executed
each time.
(anderson@redhat.com)
2018-07-13 13:50:44 -04:00
Dave Anderson
582f8b1ea4 Fix for x86_64 "bt" command to prevent an in-kernel exception frame
from not being displayed.  Without the patch, if the RIP in a pt_regs
structure on the stack is not a kernel text address, such as a NULL
pointer, it is not recognized as an exception frame and the register
set is not displayed.
(anderson@redhat.com)
2018-07-12 14:06:22 -04:00
Dave Anderson
6596f1121b The existing "list" command uses a hash table to detect duplicate
items as it traverses the list.  The hash table approach has worked
well for many years.  However, with increasing memory sizes and list
sizes, the overhead of the hash table can be substantial, often
leading to commands running for a very long time.  For large lists,
we have found that the existing hash based approach may slow the
system to a crawl and possibly never complete.  You can turn off
the hash with "set hash off" but then there is no loop detection; in
that case, loop detection must be done manually after dumping the
list to disk or some other method.  This patch is an implementation
of the cycle detection algorithm from R. P. Brent as an alternative
algorithm for the "list" command.  The algorithm both avoids the
overhead of the hash table and yet is able to detect a loop.  In
addition, further loop characteristics are printed, such as the
distance to the start of the loop as well as the loop length.
An excellent description of the algorithm can be found here on
the crash-utility mailing list:

https://www.redhat.com/archives/crash-utility/2018-July/msg00019.html

A new "list -B" option has been added to the "list" command to
invoke this new algorithm rather than using the hash table.  In
addition to low memory usage, the output of the list command is
slightly different when a loop is detected.  In addition to printing
the first duplicate entry, the length of the loop, and the distance
to the loop is output.
(dwysocha@redhat.com)
2018-07-11 16:25:59 -04:00
Dave Anderson
b21633026a Third phase of support for x86_64 5-level page tables in Linux 4.17
and later kernels.  With this patch, the usage of 5-level page tables
is automatically detected on live systems and when running against
vmcores that contain the new "NUMBER(pgtable_l5_enabled)" VMCOREINFO
entry.  Without the patch, the "--machdep vm=5level" command line
option is required.
(douly.fnst@cn.fujitsu.com, anderson@redhat.com)
2018-07-10 15:24:38 -04:00
Dave Anderson
f294197b55 Support for the "bpf" command on RHEL 3.10.0-913.el7 and later
3.10-based RHEL7 kernels, which contain a backport of the upstream
eBPF code, but still use the older, pre-4.11, IDR facility that does
not use radix trees for linking the active bpf_prog and bpf_map
structures.  Without the patch, the command indicates "bpf: command
not supported or applicable on this architecture or kernel".
(anderson@redhat.com)
2018-07-06 10:57:50 -04:00
Dave Anderson
9b494b7006 Update for the "kmem -V" option to also dump the global entries that
are contained in the "vm_numa_stat" array that was introduced in
Linux 4.14.  Also, the command output separates the "vm_zone_stat",
"vm_node_stat" and "vm_numa_stat" entries into separate sections with
"VM_ZONE_STAT", "VM_NODE_STAT" and "VM_NUMA_STAT" headers.  Without
the patch, the "vm_zone_stat" and "vm_node_stat" entries are listed
together under a "VM_STAT" header.
(anderson@redhat.com)
2018-06-26 16:00:28 -04:00
Dave Anderson
02efd0838f Fix for the failure of several "kmem" command options, most notably
seen if the command is piped directly into a crash session, or if
the command is contained in an input file.  For examples:
  $ echo "kmem -i" | crash ...
  $ crash -i <input-file> ...
Without the patch, the kmem command may fail with the error message
"<segmentation violation in gdb>".  While the bug is due to a buffer
overflow that has always existed, it only is triggered by certain
kernel configurations.
(anderson@redhat.com)
2018-06-22 11:00:01 -04:00
Dave Anderson
a7e5b90757 Fix for the x86_64 "bt" command in Linux 4.16 and later kernels
containing commit 3aa99fc3e708b9cd9b4cfe2df0b7a66cf293e3cf, titled
"x86/entry/64: Remove 'interrupt' macro".  Without the patch, the
exception frame display generated by an interrupt exception will
show incorrect contents, and be followed by the message "bt: WARNING:
possibly bogus exception frame".
(anderson@redhat.com)
2018-06-20 16:33:43 -04:00
Dave Anderson
e5df29d54b Fix for the x86_64 "bt" command in which a legitimate exception
frame is appended with the message "bt: WARNING: possibly bogus
exception frame".  This only happens in KASLR-enabled kernels when
the text address that was executing when the exception occurred
is marked as a "weak" symbol (type "W") instead of a text symbol
(type "T" or "t").  As a result, the exception frame's RIP is not
recognized as a text symbol, and the warning message is displayed.
(anderson@redhat.com)
2018-06-20 11:15:38 -04:00
Dave Anderson
28fa7bd090 Fix for PPC64 kernel virtual address translation in Linux 4.17 and
later kernels with commit c2b4d8b7417a59b7f9a52d0d8402f5257cbbd398,
titled "powerpc/mm/hash64: Increase the VA range", in which the
maximum virtual address value has been increased to 4PB.  Without
the patch, the translation/access of high vmalloc space addresses
fails; for example, the "kmem -[sS]" option fails the translation
of per-cpu kmem_cache_cpu addresses located in vmalloc space, with
the error messages "kmem: invalid kernel virtual address: <address>
type: kmem_cache_cpu.freelist" and "kmem: invalid kernel virtual
address: <address>  type: kmem_cache_cpu.page", and the "vtop"
command shows the addresses as "(not mapped)".
(hbathini@linux.ibm.com)
2018-06-19 16:31:54 -04:00
Dave Anderson
1926150ee3 Fix for the ppc64/ppc64le "bt" command on Linux 4.7 and later kernels
that contain commit d8bff643d81a58181356c0aa3ab771ac10da6894,
titled "[x86] asm: Make sure verify_cpu() has a good stack", which
inadvertently breaks the ppc64/ppc64le kernel stack size calculation
when running with crash-7.2.2 or later.  Without the patch, "bt" may
fail with a filtered kdump dumpfile with the two error messages
"bt: page excluded: kernel virtual address: <address> type: stack
contents" and "bt: read of stack at <address> failed".
(anderson@redhat.com)
2018-06-11 13:46:41 -04:00
Dave Anderson
c79a11fa10 If the default live memory source /dev/mem is determined to be
unusable because the kernel was configured with CONFIG_STRICT_DEVMEM,
the first memory read during session initialization will fail.  The
current behavior results in a readmem() error message, followed by two
notification messages that indicate that /dev/mem is restricted and
a switch to using /proc/kcore will be attempted; the readmem is
reattempted from /proc/kcore, and if successful, the session will
continue initialization.  With this patch, the behavior will change
such that if the switch to /proc/kcore and the reattempted readmem()
are successful, no messages will be displayed unless the crash
session is invoked with "crash -d&lt;number>".
(anderson@redhat.com)
2018-06-08 14:31:08 -04:00
Dave Anderson
b9d7683837 If /proc/kcore gets selected for the live memory source because
/dev/mem was configured with CONFIG_STRICT_DEVMEM, its ELF header
contents are not displayed by "help -[dD]", and are not displayed
when the crash session is invoked with -d<number>".  Without the
patch, the ELF contents are only displayed in those two situations
if "/proc/kcore" is explicitly entered on the crash command line.
(anderson@redhat.com)
2018-06-07 13:20:16 -04:00