[RFC][PATCH 0/1] add loongarch64 platform support.
by Ming Wang
This patch are for Crash-utility tool, it make crash tool support on
loongarch64 architecture and the common commands(bt, p, rd, mod, log, set,
dis, and so on).
The upstream GDB code supports the loongarch64 architecture from version 13.1.
See: https://sourceware.org/gdb/download/ANNOUNCEMENT
But Crash-utility depends on gdb-10.2, gdb-10.2 do NOT supported loongarch64.
So we need a patch(gdb-10.2-loongarch.patch) to support it. I don't have a better
way to deal with this problem at the moment.
I test this patch on Loongson 3C50000 processor platform.
...
KERNEL: /usr/lib/debug/lib/modules/5.10.0-60.102.0.128.oe2203.loongarch64/vmlinux
DUMPFILE: /proc/kcore
CPUS: 16
DATE: Thu Jul 27 19:51:21 CST 2023
UPTIME: 06:35:11
LOAD AVERAGE: 0.15, 0.03, 0.01
TASKS: 257
NODENAME: localhost.localdomain
RELEASE: 5.10.0-60.102.0.128.oe2203.loongarch64
VERSION: #1 SMP Fri Jul 14 04:17:09 UTC 2023
MACHINE: loongarch64 (2200 Mhz)
MEMORY: 64 GB
PID: 2964
COMMAND: "crash"
TASK: 9000000098805500 [THREAD_INFO: 9000000094d48000]
CPU: 6
STATE: TASK_RUNNING (ACTIVE)
crash>
crash> dis -l start_kernel
/linux-5.10.0-60.102.0.128.oe2203.loongarch64/init/main.c: 883
0x9000000001030818 <start_kernel>: 0x0141ee40
/linux-5.10.0-60.102.0.128.oe2203.loongarch64/init/main.c: 879
0x900000000103081c <start_kernel+4>: 0x90000000
/linux-5.10.0-60.102.0.128.oe2203.loongarch64/init/main.c: 883
0x9000000001030820 <start_kernel+8>: addu16i.d $zero, $t8, 8179(0x1ff3)
/linux-5.10.0-60.102.0.128.oe2203.loongarch64/init/main.c: 879
...
About the LoongArch64 Architecture:
https://www.kernel.org/doc/html/latest/loongarch/index.html
After this RFC, I will split this big patch to many small patchs by function,
like RISCV64 patch sets.
Ming Wang (1):
loongarch64: Support loongarch64 architecture and common commands
Makefile | 9 +-
README | 4 +-
configure.c | 27 +-
crash.8 | 2 +-
defs.h | 161 +-
diskdump.c | 24 +-
gdb-10.2-loongarch.patch | 15207 +++++++++++++++++++++++++++++++++++++
gdb_interface.c | 1 -
help.c | 9 +-
lkcd_vmdump_v1.h | 2 +-
lkcd_vmdump_v2_v3.h | 5 +-
loongarch64.c | 1347 ++++
main.c | 3 +-
netdump.c | 26 +-
ramdump.c | 2 +
symbols.c | 26 +-
16 files changed, 16832 insertions(+), 23 deletions(-)
create mode 100644 gdb-10.2-loongarch.patch
create mode 100644 loongarch64.c
base-commit: c74f375e0ef7cd9b593fa1d73c47505822c8f2a0
--
2.39.2
1 year, 4 months
[PATCH] Fix the "foreach DE" task identifier displays incorrect state tasks.
by Lianbo Jiang
Currently, the "foreach DE ps -m" command may display "DE" as well as
"ZO" state tasks as below:
crash> foreach DE ps -m
...
[0 00:00:00.040] [ZO] PID: 11458 TASK: ffff91c75680d280 CPU: 7 COMMAND: "ora_w01o_p01mci"
[0 00:00:00.044] [ZO] PID: 49118 TASK: ffff91c7bf3e8000 CPU: 19 COMMAND: "oracle_49118_p0"
[0 00:00:00.050] [ZO] PID: 28748 TASK: ffff91a7cbde3180 CPU: 2 COMMAND: "ora_imr0_p01sci"
[0 00:00:00.050] [DE] PID: 28405 TASK: ffff91a7c8eb0000 CPU: 27 COMMAND: "ora_vktm_p01sci"
[0 00:00:00.051] [ZO] PID: 31716 TASK: ffff91a7f7192100 CPU: 6 COMMAND: "ora_p001_p01sci"
...
That is not expected behavior, the "foreach" command needs to handle
such cases. Let's add a check to determine if the task state identifier
is specified and the task state identifier is equal to the "DE", so that
it can filter out the non-"DE" state tasks.
With the patch:
crash> foreach DE ps -m
[0 00:00:00.050] [DE] PID: 28405 TASK: ffff91a7c8eb0000 CPU: 27 COMMAND: "ora_vktm_p01sci"
crash>
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
task.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/task.c b/task.c
index b9076da35565..4f40c396b195 100644
--- a/task.c
+++ b/task.c
@@ -7043,6 +7043,9 @@ foreach(struct foreach_data *fd)
if (fd->state == _RUNNING_) {
if (task_state(tc->task) != _RUNNING_)
continue;
+ } else if (fd->state == _DEAD_) {
+ if (task_state(tc->task) != _DEAD_)
+ continue;
} else if (fd->state & _UNINTERRUPTIBLE_) {
if (!(task_state(tc->task) & _UNINTERRUPTIBLE_))
continue;
--
2.37.1
1 year, 4 months
[PATCH] Fix get_linux_banner_from_vmlinux() for vmlinux without ".rodata" symbol
by HAGIO KAZUHITO(萩尾 一仁)
From: Kazuhito Hagio <k-hagio-ab(a)nec.com>
As written in the previous patch, some recent kernels do not have the
".rodata" symbol. As a result, the get_linux_banner_from_vmlinux()
returns FALSE and the slower fallback routine is used.
Use "__start_rodata" symbol if the ".rodata" symbol is not available.
Reported-by: Lianbo Jiang <lijiang(a)redhat.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
Note that I chose to use ".rodata" first to not change the current
stable behavior for old vmcores, in this case.
kernel.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel.c b/kernel.c
index 9801812387bd..2114700eecc8 100644
--- a/kernel.c
+++ b/kernel.c
@@ -11891,8 +11891,13 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size)
{
struct bfd_section *sect;
long offset;
+ ulong start_rodata;
- if (!kernel_symbol_exists(".rodata"))
+ if (kernel_symbol_exists(".rodata"))
+ start_rodata = symbol_value(".rodata");
+ else if (kernel_symbol_exists("__start_rodata"))
+ start_rodata = symbol_value("__start_rodata");
+ else
return FALSE;
sect = bfd_get_section_by_name(st->bfd, ".rodata");
@@ -11905,7 +11910,7 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size)
* value in vmlinux file, but relative offset to linux_banner
* object in .rodata section is idential.
*/
- offset = symbol_value("linux_banner") - symbol_value(".rodata");
+ offset = symbol_value("linux_banner") - start_rodata;
if (!bfd_get_section_contents(st->bfd,
sect,
--
2.31.1
1 year, 5 months
[PATCH] Fix warning about kernel version inconsistency during crash startup
by Lianbo Jiang
Currently, the symbol ".rodata" may not be found in some vmlinux, and
the strings command will still be used to get the linux banner string,
but this gets two strings as below:
# strings /usr/lib/debug/usr/lib/modules/6.5.0-0.rc2.17.fc39.x86_64/vmlinux |grep "Linux version"
Linux version 6.5.0-0.rc2.17.fc39.x86_64 (mockbuild@23a79bad375e4c2c8c60f2d40df7df49) (gcc (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4), GNU ld version 2.40-9.fc39) # SMP PREEMPT_DYNAMIC
Linux version 6.5.0-0.rc2.17.fc39.x86_64 (mockbuild@23a79bad375e4c2c8c60f2d40df7df49) (gcc (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4), GNU ld version 2.40-9.fc39) #1 SMP PREEMPT_DYNAMIC Mon Jul 17 14:57:35 UTC 2023
In the verify_namelist(), the while-loop will only determine if the
above first string(linux banner) matches and break the loop. But
actually the above second string is correct one. Eventually, crash
startup with the following warning:
# ./crash -s /usr/lib/debug/usr/lib/modules/6.5.0-0.rc2.17.fc39.x86_64/vmlinux /var/crash/127.0.0.1-2023-07-20-20\:50\:50/vmcore
WARNING: kernel version inconsistency between vmlinux and dumpfile
# ./crash -s
WARNING: kernel version inconsistency between vmlinux and live memory
Let's always try to match the correct one, otherwise still prints a
warning as before.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
kernel.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/kernel.c b/kernel.c
index 546eed95eebd..9801812387bd 100644
--- a/kernel.c
+++ b/kernel.c
@@ -1375,8 +1375,6 @@ verify_namelist()
buffer3[i++] = *p1++;
buffer3[i] = NULLCHAR;
}
-
- break;
}
pclose(pipe);
--
2.37.1
1 year, 5 months
[PATCH] Fix segmentation fault by "tree -s" option with Maple Tree
by HAGIO KAZUHITO(萩尾 一仁)
Without the patch, do_mt_entry() can call dump_struct_members_for_tree()
with a NULL entry, and parse_for_member_extended() will cause a
segmentation fault during strncpy().
This is caused by "tree -t maple -s struct.member.member" style multiple
level member access:
crash> tree -t maple -s irq_desc.irq_data.irq sparse_irqs
ffff936980188400
irq_data.irq = 0,
ffff93698018be00
irq_data.irq = 1,
...
ffff936980f38e00
irq_data.irq = 19,
Segmentation fault (core dumped)
(gdb) bt
#0 0x00007faaf8e51635 in __strncpy_avx2 () from /lib64/libc.so.6
#1 0x00000000005e5927 in parse_for_member_extended (dm=dm@entry=0x7ffcb9e6d860, ...
#2 0x0000000000603c45 in dump_struct_member (s=s@entry=0x128cde0 <shared_bufs+1024> ...
#3 0x0000000000513cf5 in dump_struct_members_for_tree (td=td@entry=0x7ffcb9e6eeb0, ...
#4 0x0000000000651f15 in do_mt_entry (entry=0, min=min@entry=20, max=max@entry=119, ...
...
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maple_tree.c b/maple_tree.c
index eccd273105a6..8c804d0cb80d 100644
--- a/maple_tree.c
+++ b/maple_tree.c
@@ -313,7 +313,7 @@ static void do_mt_entry(ulong entry, ulong min, ulong max, uint depth,
fprintf(fp, " index: %ld position: %s/%u\n",
++(*global_index), path, index);
- if (td->structname) {
+ if (td->structname && entry) {
if (td->flags & TREE_STRUCT_RADIX_10)
print_radix = 10;
else if (td->flags & TREE_STRUCT_RADIX_16)
--
2.31.1
1 year, 5 months
Re: [Crash-utility] [PATCH v2 2/2] Fix "irq [-a|-s]" options on Linux 6.5-rc1 and later
by lijiang
Thank you for the update, Kazu.
On Wed, Jul 12, 2023 at 4:55 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Wed, 12 Jul 2023 08:55:29 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Cc: "lijiang(a)redhat.com" <lijiang(a)redhat.com>
> Subject: [Crash-utility] [PATCH v2 2/2] Fix "irq [-a|-s]" options on
> Linux 6.5-rc1 and later
> Message-ID: <1689152127-28057-1-git-send-email-k-hagio-ab(a)nec.com>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> From: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> Kernel commit 721255b982 ("genirq: Use a maple tree for interrupt
> descriptor management"), which is contained in Linux 6.5-rc1 and later
> kernels, replaced irq_desc_tree with a maple tree sparse_irqs.
>
> Without the patch, "irq [-a|-s]" options fail with an error, e.g. the
> following on x86_64, on kernels configured with CONFIG_SPARSE_IRQ=y.
>
> crash> irq
> irq: x86_64_dump_irq: irq_desc[] or irq_desc_tree do not exist?
>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> v1 -> v2
> - Fixed a typo in the commit log: s/SPARSE_IRQS/SPARSE_IRQ/
> - Reverted the unintendedly removed line in x86_64_show_interrupts()
> - Added sparse_irqs support to ia64_dump_irq()
>
>
The v2 looks good to me. For the patches: Ack
[1] [PATCH 1/2] Exclude NULL entries from do_maple_tree() return value
<https://listman.redhat.com/archives/crash-utility/2023-July/010832.html>
[2] [PATCH v2 2/2] Fix "irq [-a|-s]" options on Linux 6.5-rc1 and later
<https://listman.redhat.com/archives/crash-utility/2023-July/010847.html>
Thanks.
Lianbo
defs.h | 2 ++
> ia64.c | 3 ++-
> kernel.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++---
> symbols.c | 1 +
> x86_64.c | 9 ++++++---
> 5 files changed, 59 insertions(+), 7 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 26afe232cc3e..358f365585cf 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -676,6 +676,7 @@ struct new_utsname {
> #define IRQ_DESC_TREE_XARRAY (0x80ULL)
> #define KMOD_PAX (0x100ULL)
> #define KMOD_MEMORY (0x200ULL)
> +#define IRQ_DESC_TREE_MAPLE (0x400ULL)
>
> #define XEN() (kt->flags & ARCH_XEN)
> #define OPENVZ() (kt->flags & ARCH_OPENVZ)
> @@ -2222,6 +2223,7 @@ struct offset_table { /* stash of
> commonly-used offsets */
> long module_mem;
> long module_memory_base;
> long module_memory_size;
> + long irq_data_irq;
> };
>
> struct size_table { /* stash of commonly-used sizes */
> diff --git a/ia64.c b/ia64.c
> index 2e1d15fe6042..d3e0a3b01869 100644
> --- a/ia64.c
> +++ b/ia64.c
> @@ -791,7 +791,8 @@ ia64_back_trace_cmd(struct bt_info *bt)
> static void
> ia64_dump_irq(int irq)
> {
> - if (symbol_exists("irq_desc") || symbol_exists("_irq_desc") ||
> + if (kernel_symbol_exists("sparse_irqs") ||
> + symbol_exists("irq_desc") || symbol_exists("_irq_desc") ||
> kernel_symbol_exists("irq_desc_ptrs")) {
> machdep->dump_irq = generic_dump_irq;
> return(generic_dump_irq(irq));
> diff --git a/kernel.c b/kernel.c
> index 0fc77c19f12a..546eed95eebd 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -541,7 +541,10 @@ kernel_init()
> MEMBER_OFFSET_INIT(irqaction_dev_id, "irqaction", "dev_id");
> MEMBER_OFFSET_INIT(irqaction_next, "irqaction", "next");
>
> - if (kernel_symbol_exists("irq_desc_tree")) {
> + /* 6.5 and later: CONFIG_SPARSE_IRQ */
> + if (kernel_symbol_exists("sparse_irqs"))
> + kt->flags2 |= IRQ_DESC_TREE_MAPLE;
> + else if (kernel_symbol_exists("irq_desc_tree")) {
> get_symbol_type("irq_desc_tree", NULL, &req);
> if (STREQ(req.type_tag_name, "xarray")) {
> kt->flags2 |= IRQ_DESC_TREE_XARRAY;
> @@ -554,6 +557,7 @@ kernel_init()
> }
> STRUCT_SIZE_INIT(irq_data, "irq_data");
> if (VALID_STRUCT(irq_data)) {
> + MEMBER_OFFSET_INIT(irq_data_irq, "irq_data", "irq");
> MEMBER_OFFSET_INIT(irq_data_chip, "irq_data", "chip");
> MEMBER_OFFSET_INIT(irq_data_affinity, "irq_data",
> "affinity");
> MEMBER_OFFSET_INIT(irq_desc_irq_data, "irq_desc",
> "irq_data");
> @@ -6180,6 +6184,8 @@ dump_kernel_table(int verbose)
> fprintf(fp, "%sIRQ_DESC_TREE_RADIX", others++ ? "|" : "");
> if (kt->flags2 & IRQ_DESC_TREE_XARRAY)
> fprintf(fp, "%sIRQ_DESC_TREE_XARRAY", others++ ? "|" : "");
> + if (kt->flags2 & IRQ_DESC_TREE_MAPLE)
> + fprintf(fp, "%sIRQ_DESC_TREE_MAPLE", others++ ? "|" : "");
> if (kt->flags2 & KMOD_PAX)
> fprintf(fp, "%sKMOD_PAX", others++ ? "|" : "");
> if (kt->flags2 & KMOD_MEMORY)
> @@ -6652,6 +6658,45 @@ get_irq_desc_addr(int irq)
> readmem(ptr, KVADDR, &addr,
> sizeof(void *), "irq_desc_ptrs entry",
> FAULT_ON_ERROR);
> + } else if (kt->flags2 & IRQ_DESC_TREE_MAPLE) {
> + unsigned int i;
> +
> + if (kt->highest_irq && (irq > kt->highest_irq))
> + return addr;
> +
> + cnt = do_maple_tree(symbol_value("sparse_irqs"),
> MAPLE_TREE_COUNT, NULL);
> +
> + len = sizeof(struct list_pair) * (cnt+1);
> + lp = (struct list_pair *)GETBUF(len);
> + lp[0].index = cnt; /* maxcount */
> +
> + cnt = do_maple_tree(symbol_value("sparse_irqs"),
> MAPLE_TREE_GATHER, lp);
> +
> + /*
> + * NOTE: We cannot use lp.index like Radix Tree or XArray
> because
> + * it's not an absolute index and just counter in Maple
> Tree.
> + */
> + if (kt->highest_irq == 0) {
> + readmem((ulong)lp[cnt-1].value +
> + OFFSET(irq_desc_irq_data) +
> OFFSET(irq_data_irq),
> + KVADDR, &kt->highest_irq, sizeof(int),
> "irq_data.irq",
> + FAULT_ON_ERROR);
> + }
> +
> + for (c = 0; c < cnt; c++) {
> + readmem((ulong)lp[c].value +
> + OFFSET(irq_desc_irq_data) +
> OFFSET(irq_data_irq),
> + KVADDR, &i, sizeof(int), "irq_data.irq",
> FAULT_ON_ERROR);
> + if (i == irq) {
> + if (CRASHDEBUG(1))
> + fprintf(fp, "index: %d value:
> %lx\n",
> + i, (ulong)lp[c].value);
> + addr = (ulong)lp[c].value;
> + break;
> + }
> + }
> + FREEBUF(lp);
> +
> } else if (kt->flags2 &
> (IRQ_DESC_TREE_RADIX|IRQ_DESC_TREE_XARRAY)) {
> if (kt->highest_irq && (irq > kt->highest_irq))
> return addr;
> @@ -6700,8 +6745,8 @@ get_irq_desc_addr(int irq)
> FREEBUF(lp);
> } else {
> error(FATAL,
> - "neither irq_desc, _irq_desc, irq_desc_ptrs "
> - "or irq_desc_tree symbols exist\n");
> + "neither irq_desc, _irq_desc, irq_desc_ptrs, "
> + "irq_desc_tree or sparse_irqs symbols exist\n");
> }
>
> return addr;
> diff --git a/symbols.c b/symbols.c
> index 82529a6785c9..876be7aea90e 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -10375,6 +10375,7 @@ dump_offset_table(char *spec, ulong makestruct)
> OFFSET(irq_desc_t_kstat_irqs));
> fprintf(fp, " irq_desc_t_affinity: %ld\n",
> OFFSET(irq_desc_t_affinity));
> + fprintf(fp, " irq_data_irq: %ld\n",
> OFFSET(irq_data_irq));
> fprintf(fp, " irq_data_chip: %ld\n",
> OFFSET(irq_data_chip));
> fprintf(fp, " irq_data_affinity: %ld\n",
> diff --git a/x86_64.c b/x86_64.c
> index 87e87ae6e1e8..42ade4817ad9 100644
> --- a/x86_64.c
> +++ b/x86_64.c
> @@ -5391,7 +5391,8 @@ get_x86_64_frame(struct bt_info *bt, ulong *getpc,
> ulong *getsp)
> static void
> x86_64_dump_irq(int irq)
> {
> - if (symbol_exists("irq_desc") ||
> + if (kernel_symbol_exists("sparse_irqs") ||
> + symbol_exists("irq_desc") ||
> kernel_symbol_exists("irq_desc_ptrs") ||
> kernel_symbol_exists("irq_desc_tree")) {
> machdep->dump_irq = generic_dump_irq;
> @@ -5405,7 +5406,8 @@ x86_64_dump_irq(int irq)
> static void
> x86_64_get_irq_affinity(int irq)
> {
> - if (symbol_exists("irq_desc") ||
> + if (kernel_symbol_exists("sparse_irqs") ||
> + symbol_exists("irq_desc") ||
> kernel_symbol_exists("irq_desc_ptrs") ||
> kernel_symbol_exists("irq_desc_tree")) {
> machdep->get_irq_affinity = generic_get_irq_affinity;
> @@ -5419,7 +5421,8 @@ x86_64_get_irq_affinity(int irq)
> static void
> x86_64_show_interrupts(int irq, ulong *cpus)
> {
> - if (symbol_exists("irq_desc") ||
> + if (kernel_symbol_exists("sparse_irqs") ||
> + symbol_exists("irq_desc") ||
> kernel_symbol_exists("irq_desc_ptrs") ||
> kernel_symbol_exists("irq_desc_tree")) {
> machdep->show_interrupts = generic_show_interrupts;
> --
> 2.31.1
>
1 year, 5 months
[PATCH 1/2] Exclude NULL entries from do_maple_tree() return value
by HAGIO KAZUHITO(萩尾 一仁)
From: Kazuhito Hagio <k-hagio-ab(a)nec.com>
While the return value of do_radix_tree() and do_xarray() does not
contain NULL entries, do_maple_tree()'s one contains NULL entries.
Make this behavior consistent with the previous tree functions to make
replacement easier, especially for the following patch.
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maple_tree.c b/maple_tree.c
index 807c17f7dfa0..eccd273105a6 100644
--- a/maple_tree.c
+++ b/maple_tree.c
@@ -287,7 +287,7 @@ static void do_mt_entry(ulong entry, ulong min, ulong max, uint depth,
static struct req_entry **e = NULL;
struct tree_data *td = ops->is_td ? (struct tree_data *)ops->private : NULL;
- if (ops->entry)
+ if (ops->entry && entry)
ops->entry(entry, entry, path, max, ops->private);
if (!td)
--
2.31.1
1 year, 5 months
Re: [Crash-utility] [PATCH] vmware: Improve output when we fail to read vmware 'vmsn' file
by lijiang
Hi, Dave
Thanks for your improvement.
On Fri, Jul 7, 2023 at 2:17 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Thu, 6 Jul 2023 10:53:18 -0400
> From: Dave Wysochanski <dwysocha(a)redhat.com>
> To: crash-utility(a)redhat.com
> Cc: dwysocha(a)redhat.com, amakhalov(a)vmware.com, soakley(a)redhat.com
> Subject: [Crash-utility] [PATCH] vmware: Improve output when we fail
> to read vmware 'vmsn' file
> Message-ID: <20230706145318.731449-1-dwysocha(a)redhat.com>
>
> Today if crash fails to read some structure in a vmware 'vmsn' file,
> it will throw an "No such file or directory" message. Such a generic
> message does not give any clue as to the problem, but instead sounds
> like the file may not exist when it does, for example:
> $ crash ./vmcore.vmsn ./vmlinux
>
> crash 8.0.3
> ...
>
> crash: vmw: Failed to read './vmcore.vmsn': [Error 2] No such file or
> directory
>
> crash: ./vmcore.vmsn: initialization failed
>
> $ ls -l ./vmcore.vmsn
> -rwxrwxrwx. 7 myuser mygroup 12128999 Jul 4 07:21 ./vmcore.vmsn
>
> Improve the above error message so we at least know which portion
> of the file crash had difficulty reading. After this patch, the
> above error looks like:
> crash: vmw: Failed to read 'cptgroupdesc' from file './vmcore.vmsn':
> [Error 2] No such file or directory
>
> Signed-off-by: Dave Wysochanski <dwysocha(a)redhat.com>
> ---
> vmware_guestdump.c | 8 ++++----
> vmware_vmss.c | 24 ++++++++++++------------
> 2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/vmware_guestdump.c b/vmware_guestdump.c
> index cf818e588a60..5be26c8e2e90 100644
> --- a/vmware_guestdump.c
> +++ b/vmware_guestdump.c
> @@ -117,8 +117,8 @@ is_vmware_guestdump(char *filename)
> }
>
> if (fread(&hdr, sizeof(struct guestdumpheader), 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> - filename, errno, strerror(errno));
> + error(INFO, LOGPRX"Failed to read '%s' from file '%s':
> [Error %d] %s\n",
> + "guestdumpheader", filename, errno, strerror(errno));
> fclose(fp);
> return FALSE;
> }
> @@ -204,8 +204,8 @@ vmware_guestdump_init(char *filename, FILE *ofp)
>
> for (i = 0; i < vmss.num_vcpus; i++) {
> if (fread(&vs, sizeof(struct vcpu_state), 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed to read '%s': [Error %d]
> %s\n",
> - filename, errno, strerror(errno));
> + error(INFO, LOGPRX"Failed to read '%s' from file
> '%s': [Error %d] %s\n",
> + "vcpu_state", filename, errno,
> strerror(errno));
> result = FALSE;
> goto exit;
> }
> diff --git a/vmware_vmss.c b/vmware_vmss.c
> index f6c5f32ea4c0..8121ab64a99a 100644
> --- a/vmware_vmss.c
> +++ b/vmware_vmss.c
> @@ -39,8 +39,8 @@ is_vmware_vmss(char *filename)
> }
>
> if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> - filename, errno, strerror(errno));
> + error(INFO, LOGPRX"Failed to read '%s' from file '%s':
> [Error %d] %s\n",
> + "cptdumpheader", filename, errno, strerror(errno));
> fclose(fp);
> return FALSE;
> }
> @@ -86,8 +86,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
> }
>
> if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed to read '%s': %s [Error %d]
> %s\n",
> - filename, errno, strerror(errno));
> + error(INFO, LOGPRX"Failed to read '%s' from file '%s':
> [Error %d] %s\n",
> + "cptdumpheader", filename, errno, strerror(errno));
> result = FALSE;
> goto exit;
> }
> @@ -112,8 +112,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
> }
>
> if (fread(grps, sizeof(cptgroupdesc), grpsize, fp) != grpsize) {
> - error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> - filename, errno, strerror(errno));
> + error(INFO, LOGPRX"Failed to read '%s' from file '%s':
> [Error %d] %s\n",
> + "cptgroupdesc", filename, errno, strerror(errno));
>
^^^^^^^^^^^^
Although the above code is good, I tend to output constant strings directly
rather than using the '%s' to print.
Anyway, the other changes still look fine to me. So: Ack.
Thanks
Lianbo
result = FALSE;
> goto exit;
> }
> @@ -225,8 +225,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
> idx[0] < vmss.num_vcpus) {
> int cpu = idx[0];
> if (fread(vmss.regs64[cpu],
> VMW_GPREGS_SIZE, 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed
> to read '%s': [Error %d] %s\n",
> - filename, errno,
> strerror(errno));
> + error(INFO, LOGPRX"Failed
> to read '%s' from file '%s': [Error %d] %s\n",
> + name, filename,
> errno, strerror(errno));
> break;
> }
> DEBUG_PARSE_PRINT((ofp, "\n"));
> @@ -237,8 +237,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
> int cpu = idx[0];
> DEBUG_PARSE_PRINT((ofp, "\t=> "));
> if
> (fread(&vmss.regs64[cpu]->cr[0], VMW_CR64_SIZE, 1, fp) != 1) {
> - error(INFO, LOGPRX"Failed
> to read '%s': [Error %d] %s\n",
> - filename, errno,
> strerror(errno));
> + error(INFO, LOGPRX"Failed
> to read '%s' from file '%s': [Error %d] %s\n",
> + name, filename,
> errno, strerror(errno));
> break;
> }
> for (j = 0; j < VMW_CR64_SIZE / 8;
> j++)
> @@ -257,8 +257,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
> break;
> }
> if (fread(&idtr, sizeof(idtr), 1,
> fp) != 1) {
> - error(INFO, LOGPRX"Failed
> to read '%s': [Error %d] %s\n",
> - filename, errno,
> strerror(errno));
> + error(INFO, LOGPRX"Failed
> to read '%s' from file '%s': [Error %d] %s\n",
> + name, filename,
> errno, strerror(errno));
> break;
> }
> DEBUG_PARSE_PRINT((ofp, "\n"));
> --
> 2.39.3
>
>
1 year, 5 months
[PATCH] Fix "irq -a" option on Linux 6.0 and later
by HAGIO KAZUHITO(萩尾 一仁)
From: Kazuhito Hagio <k-hagio-ab(a)nec.com>
Kernel commit f0dd891dd5a1d ("lib/cpumask: move some one-line wrappers
to header file"), which is contained in Linux 6.0 and later kernels,
inlined alloc_cpumask_var() function. As a result, the "irq -a" option
fails to determine whether cpumask_var_t is a pointer, and displays
wrong CPU affinity for IRQs:
crash> irq -a
IRQ NAME AFFINITY
1 i8042 3
4 ttyS0
8 rtc0
9 acpi 3
12 i8042 3
...
Use alloc_cpumask_var_node() function symbol instead to fix it.
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
kernel.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel.c b/kernel.c
index 0d72eaeeb79b..546eed95eebd 100644
--- a/kernel.c
+++ b/kernel.c
@@ -7343,7 +7343,8 @@ generic_get_irq_affinity(int irq)
tmp_addr = irq_desc_addr + \
OFFSET(irq_desc_t_affinity);
- if (symbol_exists("alloc_cpumask_var")) /* pointer member */
+ if (symbol_exists("alloc_cpumask_var_node") ||
+ symbol_exists("alloc_cpumask_var")) /* pointer member */
readmem(tmp_addr,KVADDR, &affinity_ptr, sizeof(ulong),
"irq_desc affinity", FAULT_ON_ERROR);
else /* array member */
--
2.31.1
1 year, 5 months
[PATCH] vmware: Improve output when we fail to read vmware 'vmsn' file
by Dave Wysochanski
Today if crash fails to read some structure in a vmware 'vmsn' file,
it will throw an "No such file or directory" message. Such a generic
message does not give any clue as to the problem, but instead sounds
like the file may not exist when it does, for example:
$ crash ./vmcore.vmsn ./vmlinux
crash 8.0.3
...
crash: vmw: Failed to read './vmcore.vmsn': [Error 2] No such file or directory
crash: ./vmcore.vmsn: initialization failed
$ ls -l ./vmcore.vmsn
-rwxrwxrwx. 7 myuser mygroup 12128999 Jul 4 07:21 ./vmcore.vmsn
Improve the above error message so we at least know which portion
of the file crash had difficulty reading. After this patch, the
above error looks like:
crash: vmw: Failed to read 'cptgroupdesc' from file './vmcore.vmsn': [Error 2] No such file or directory
Signed-off-by: Dave Wysochanski <dwysocha(a)redhat.com>
---
vmware_guestdump.c | 8 ++++----
vmware_vmss.c | 24 ++++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/vmware_guestdump.c b/vmware_guestdump.c
index cf818e588a60..5be26c8e2e90 100644
--- a/vmware_guestdump.c
+++ b/vmware_guestdump.c
@@ -117,8 +117,8 @@ is_vmware_guestdump(char *filename)
}
if (fread(&hdr, sizeof(struct guestdumpheader), 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ "guestdumpheader", filename, errno, strerror(errno));
fclose(fp);
return FALSE;
}
@@ -204,8 +204,8 @@ vmware_guestdump_init(char *filename, FILE *ofp)
for (i = 0; i < vmss.num_vcpus; i++) {
if (fread(&vs, sizeof(struct vcpu_state), 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ "vcpu_state", filename, errno, strerror(errno));
result = FALSE;
goto exit;
}
diff --git a/vmware_vmss.c b/vmware_vmss.c
index f6c5f32ea4c0..8121ab64a99a 100644
--- a/vmware_vmss.c
+++ b/vmware_vmss.c
@@ -39,8 +39,8 @@ is_vmware_vmss(char *filename)
}
if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ "cptdumpheader", filename, errno, strerror(errno));
fclose(fp);
return FALSE;
}
@@ -86,8 +86,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
}
if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': %s [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ "cptdumpheader", filename, errno, strerror(errno));
result = FALSE;
goto exit;
}
@@ -112,8 +112,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
}
if (fread(grps, sizeof(cptgroupdesc), grpsize, fp) != grpsize) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ "cptgroupdesc", filename, errno, strerror(errno));
result = FALSE;
goto exit;
}
@@ -225,8 +225,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
idx[0] < vmss.num_vcpus) {
int cpu = idx[0];
if (fread(vmss.regs64[cpu], VMW_GPREGS_SIZE, 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ name, filename, errno, strerror(errno));
break;
}
DEBUG_PARSE_PRINT((ofp, "\n"));
@@ -237,8 +237,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
int cpu = idx[0];
DEBUG_PARSE_PRINT((ofp, "\t=> "));
if (fread(&vmss.regs64[cpu]->cr[0], VMW_CR64_SIZE, 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ name, filename, errno, strerror(errno));
break;
}
for (j = 0; j < VMW_CR64_SIZE / 8; j++)
@@ -257,8 +257,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
break;
}
if (fread(&idtr, sizeof(idtr), 1, fp) != 1) {
- error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
- filename, errno, strerror(errno));
+ error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
+ name, filename, errno, strerror(errno));
break;
}
DEBUG_PARSE_PRINT((ofp, "\n"));
--
2.39.3
1 year, 5 months