[PATCH] Fix memory driver module build with kernel 5.8+
by Petr Tesarik
Kernel commit fe557319aa06c23cffc9346000f119547e0f289a renamed
probe_kernel_{read,write} to copy_{from,to}_kernel_nofault.
Additionally, commit 0493cb086353e786be56010780a0b7025b5db34c
unexported probe_kernel_write(), so writing kernel memory is
no longer possible from a module.
I have renamed the functions in source, but I'm also adding wrappers to
allow building the module with older kernel versions.
Without this patch, build with kernel 5.8 and later fails:
kbuild/default/crash.c: In function 'crash_write':
kbuild/default/crash.c:189:12: error: implicit declaration of function 'probe_kernel_write'; did you mean 'kernel_write'? [-Werror=implicit-function-declaration]
189 | if (probe_kernel_write(vaddr, buffer, count)) {
| ^~~~~~~~~~~~~~~~~~
| kernel_write
kbuild/default/crash.c: In function 'crash_read':
kbuild/default/crash.c:225:13: error: implicit declaration of function 'probe_kernel_read'; did you mean 'kernel_read'? [-Werror=implicit-function-declaration]
225 | if (probe_kernel_read(buffer, vaddr, count)) {
| ^~~~~~~~~~~~~~~~~
| kernel_read
Signed-off-by: Petr Tesarik <ptesarik(a)suse.com>
---
memory_driver/crash.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
--- a/memory_driver/crash.c
+++ b/memory_driver/crash.c
@@ -25,6 +25,7 @@
*****************************************************************************/
#include <linux/module.h>
+#include <linux/version.h>
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/init.h>
@@ -37,6 +38,22 @@
extern int page_is_ram(unsigned long);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+
+#define CAN_WRITE_KERNEL 1
+
+static inline long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
+{
+ return probe_kernel_read(dst, src, size);
+}
+
+static inline long copy_to_kernel_nofault(void *dst, const void *src, size_t size)
+{
+ return probe_kernel_write(dst, src, size);
+}
+
+#endif
+
#ifdef CONFIG_S390
/*
* For swapped prefix pages get bounce buffer using xlate_dev_mem_ptr()
@@ -160,6 +177,8 @@ crash_llseek(struct file * file, loff_t
}
}
+#ifdef CAN_WRITE_KERNEL
+
static ssize_t
crash_write(struct file *file, const char *buf, size_t count, loff_t *poff)
{
@@ -186,7 +205,7 @@ crash_write(struct file *file, const cha
return -EFAULT;
}
- if (probe_kernel_write(vaddr, buffer, count)) {
+ if (copy_to_kernel_nofault(vaddr, buffer, count)) {
unmap_virtual(page);
return -EFAULT;
}
@@ -197,6 +216,8 @@ crash_write(struct file *file, const cha
return written;
}
+#endif
+
/*
* Determine the page address for an address offset value,
* get a virtual address for it, and copy it out.
@@ -222,7 +243,7 @@ crash_read(struct file *file, char *buf,
* Use bounce buffer to bypass the CONFIG_HARDENED_USERCOPY
* kernel text restriction.
*/
- if (probe_kernel_read(buffer, vaddr, count)) {
+ if (copy_from_kernel_nofault(buffer, vaddr, count)) {
unmap_virtual(page);
return -EFAULT;
}
@@ -294,7 +315,9 @@ static struct file_operations crash_fops
.owner = THIS_MODULE,
.llseek = crash_llseek,
.read = crash_read,
+#ifdef CAN_WRITE_KERNEL
.write = crash_write,
+#endif
.unlocked_ioctl = crash_ioctl,
.open = crash_open,
.release = crash_release,
4 years, 1 month
[PATCH] x86_64: Add support for new divide_error name
by Nikolay Borisov
Upstream kernel commit 9d06c4027f21 ("x86/entry: Convert Divide Error to IDTENTRY")
renamed divide_error handler to asm_exc_divide_error. This breaks kaslr
offser derivation when we crash tries to open a qemu image dump. Fix it
by also checking symbols for the presence of the new name.
Signed-off-by: Nikolay Borisov <nborisov(a)suse.com>
---
symbols.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/symbols.c b/symbols.c
index 70b1455750ee..e3594ce0ed48 100644
--- a/symbols.c
+++ b/symbols.c
@@ -12711,9 +12711,11 @@ numeric_forward(const void *P_x, const void *P_y)
if (SADUMP_DUMPFILE() || QEMU_MEM_DUMP_NO_VMCOREINFO() || VMSS_DUMPFILE()) {
/* Need for kaslr_offset and phys_base */
- if (STREQ(x->name, "divide_error"))
+ if (STREQ(x->name, "divide_error") ||
+ STREQ(x->name, "asm_exc_divide_error"))
st->divide_error_vmlinux = valueof(x);
- else if (STREQ(y->name, "divide_error"))
+ else if (STREQ(y->name, "divide_error") ||
+ STREQ(y->name, "asm_exc_divide_error"))
st->divide_error_vmlinux = valueof(y);
if (STREQ(x->name, "idt_table"))
--
2.25.1
4 years, 1 month
[PATCH 0/5] zram related changes for zram support of crash gcore command
by HATAYAMA Daisuke
This patch set is to make changes I found necessary during development
of zram support for crash gcore command.
HATAYAMA Daisuke (5):
diskdump, zram: cleanup try_zram_decompress()
diskdump, zram: initialize zram symbol information when needed
diskname, zram: fix fault error when reading zram disk with no symbol
information
diskname, zram: Notify necessity of loading zram module
memory, zram: introduce and export readswap()
defs.h | 1 +
diskdump.c | 220 ++++++++++++++++++++++++++++++++++++-------------------------
memory.c | 5 +-
3 files changed, 136 insertions(+), 90 deletions(-)
--
1.8.3.1
4 years, 1 month
Crash broken for latest upstream kernel
by Nikolay Borisov
Hello,
I haven't been able to open a crashdump generated by 'dump-guest-memory
-z' option. When I run crash -d10 vmlinux dump.img last thing I get is:
kaslr_helper: failed to determine which kernel was running at crash,
kaslr_helper: asssuming the kdump 1st kernel.
calc_kaslr_offset: kaslr_offset=ffffffff9ba00810
calc_kaslr_offset: phys_base=19a5ff7f0
crash: pv_ops exists: ARCH_PVOPS
<readmem: 137e001e0, PHYSADDR, "linux_banner verify", 13, (ROE|Q),
7ffffe50ff50>
<read_diskdump: addr: 137e001e0 paddr: 137e001e0 cnt: 13>
read_diskdump: paddr/pfn: 137e001e0/137e00 -> cache physical page: 137e00000
gdb vmlinux
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
GETBUF(328 -> 0)
GETBUF(1500 -> 1)
WARNING: kernel relocated [1605MB]: patching 97581 gdb minimal_symbol values
FREEBUF(1)
FREEBUF(0)
<readmem: ffffffff1db75260, KVADDR, "page_offset_base", 8, (FOE|Q),
55bcc3a177e8>
<read_diskdump: addr: ffffffff1db75260 paddr: 77ff1db75260 cnt: 8>
read_diskdump: SEEK_ERROR: paddr/pfn: 77ff1db75260/77ff1db75 max_mapnr:
140000
crash: seek error: kernel virtual address: ffffffff1db75260 type:
"page_offset_base"
That kernel has RANDOMIZE_BASE set to y
I get same error when I take an image dump of a kernel booted with
nokaslr.
My crash is freshly compiled, with HEAD commit : 915cc069ec03 x86_64:
Perform EFRAME_VERIFY always if set in x86_64_exception_frame (7 weeks
ago) <David Mair>
4 years, 1 month
[RFC PATCH 0/1] support lockless printk ringbuffer
by John Ogness
Hi Dave,
I created a proof-of-concept patch to work with the new printk
ringbuffer (as it is currently being proposed). I create a separate
source file (printk.c) because of all the helper functions.
The code doesn't do much error checking if symbols were missing,
and it probably doesn't work unless the machine running crash(8)
has the same endian and pointer-size as the crashed machine. But
otherwise, it does work correctly.
The most important part I wanted to have implemented was the new
logic for record traversal and printing. Being one of the authors
for the new printk ringbuffer, implementing this was far easier
for me than for someone unfamiliar with the ringbuffer internals.
It is using the new "prb" symbol. I did not add VMCOREINFO
support.
Note that this is based on the PATCHv2 that I have queued for
posting to LKML, but as of right now have not yet posted.
Basically I am waiting for feedback from Kazuhito regarding my
VMCOREINFO query. (It will not work with previous iterations
of the new ringbuffer because the struct names have changed.)
I don't expect you to take the patch as-is, but I hope it can
provide some positive ground work for moving forward.
John Ogness (1):
crash: printk: add support for lockless ringbuffer
Makefile | 5 +
defs.h | 24 +++++
kernel.c | 8 +-
printk.c | 298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 334 insertions(+), 1 deletion(-)
create mode 100644 printk.c
--
2.20.1
4 years, 1 month
Re: [Crash-utility] [PATCH v3] x86_64_exception_frame only performs EFRAME_VERIFY if it is the only flag
by lijiang
Hi, David Mair
Thank you for the fix.
在 2020年09月11日 00:00, crash-utility-request(a)redhat.com 写道:
> Message: 2
> Date: Thu, 10 Sep 2020 09:35:34 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [PATCH v3] x86_64_exception_frame only
> performs EFRAME_VERIFY if it is the only flag
> Message-ID:
> <OSBPR01MB19919A04D573C74CD0727B82DD270(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> -----Original Message-----
>> Hi Kazu,
>>
>> I swear that last week I couldn't build past:
>>
>> verify_addr = (local - bt->stackbuf) + bt->stackbase;
>>
>> without a gcc error on the two char * in the parentheses being
>> used in a ulong assignment. Last week it required casts on both
>> char * to build for me. This week build of the same workspace
>> of expanded source works through the same line without any casts.
>> Below is a patch to replace the one in this thread's header post.
>> It is cleaned of the casts I previously had in the line above.
>> It builds fixes the problems I described in this thread's header
>> and is unmodified other than removal of the casts I previously
>> had in the line above.
> OK, so for the following patch and the v3 commit message [1]
> without its last paragraph about the cast to uintptr_t,
>
> Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> Please wait for another ack.
>
> [1] https://www.redhat.com/archives/crash-utility/2020-September/msg00016.html
>
> Thanks,
> Kazu
>
>> I'm sorry for the trouble getting it tidy.
>>
>> Signed-off-by: David Mair <dmair(a)suse.com>
>> ---
>> diff --git a/x86_64.c b/x86_64.c
>> index fc05e8a..dec3730 100644
>> --- a/x86_64.c
>> +++ b/x86_64.c
>> @@ -4412,15 +4412,20 @@ x86_64_exception_frame(ulong flags, ulong kvaddr, char *local,
>> long r8, r9, r10, r11, r12, r13, r14, r15;
>> struct machine_specific *ms;
>> struct syment *sp;
>> - ulong offset;
>> + ulong offset, verify_addr;
>> char *pt_regs_buf;
>> long verified;
>> long err;
>> char buf[BUFSIZE];
>>
>> - if (flags == EFRAME_VERIFY) {
>> - if (!accessible(kvaddr) ||
>> - !accessible(kvaddr + SIZE(pt_regs) - sizeof(long)))
Actually, that would be good to have a simple code comment for this change.
Anyway, this fix looks good to me. Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>> + if (flags & EFRAME_VERIFY) {
>> + if (kvaddr)
>> + verify_addr = kvaddr;
>> + else
>> + verify_addr = (local - bt->stackbuf) + bt->stackbase;
>> +
>> + if (!accessible(verify_addr) ||
>> + !accessible(verify_addr + SIZE(pt_regs) - sizeof(long)))
>> return FALSE;
>> }
>>
>>
>> --
>> Crash-utility mailing list
>> Crash-utility(a)redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
4 years, 1 month
[PATCH 0/2] Improve kaslr_offset detection
by Alexey Makhalov
Hi all,
This patchset was developed to improve detection of kaslr_offset and phys base.
First patch fixes VMware facility where CPU #0 has zeroed IDTR.
Second one introduces alternative method of finding kaslr_offset and phys base.
Alexey Makhalov (2):
vmware_vmss: get proper ITDR
kaslr: get offset by walking page tree
kaslr_helper.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vmware_vmss.c | 21 +++++++++++
2 files changed, 136 insertions(+)
--
2.11.0
4 years, 2 months
Re: [Crash-utility] [PATCH] xendump: fix failure to match arm/aarch64 elf format of xendump file
by lijiang
在 2020年09月24日 15:41, crash-utility-request(a)redhat.com 写道:
> Message: 3
> Date: Thu, 24 Sep 2020 07:41:37 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Cc: Goodbach <goodbach(a)gmail.com>
> Subject: Re: [Crash-utility] [PATCH] xendump: fix failure to match
> arm/aarch64 elf format of xendump file
> Message-ID:
> <OSBPR01MB1991FE95D0BCF61A8E90AD6DDD390(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> -----Original Message-----
>> From: Goodbach <goodbach(a)gmail.com>
>> Date: Wed, 12 Aug 2020 11:22:29 +0800
>>
>> Resolves: https://github.com/crash-utility/crash/pull/61
>> Signed-off-by: Goodbach <goodbach(a)gmail.com>
> I'm not sure whether it's needed to also add the ARM one to 32-bit side,
There may be needed to add the EM_ARM branch in the if-elf32 block although
the scenarios are relatively rare for xen dumU.
Anyway, would you mind helping to check this issue? Goodbach.
Or let's still leave this part to xen engineers?
Thanks.
Lianbo
> but the patch itself looks good to me.
>
> Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> Thanks,
> Kazu
>
>> ---
>> xendump.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/xendump.c b/xendump.c
>> index 70cf261..a81817d 100644
>> --- a/xendump.c
>> +++ b/xendump.c
>> @@ -2055,6 +2055,16 @@ xc_core_elf_verify(char *file, char *buf)
>> goto bailout;
>> break;
>>
>> + case EM_ARM:
>> + if (machine_type_mismatch(file, "ARM", NULL, 0))
>> + goto bailout;
>> + break;
>> +
>> + case EM_AARCH64:
>> + if (machine_type_mismatch(file, "ARM64", NULL, 0))
>> + goto bailout;
>> + break;
>> +
>> default:
>> if (machine_type_mismatch(file, "(unknown)", NULL, 0))
>> goto bailout;
>>
>>
>> --
>> Crash-utility mailing list
>> Crash-utility(a)redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
>
4 years, 2 months
Re: [Crash-utility] [PATCH 5/5] memory, zram: introduce and export readswap()
by lijiang
Hi, HATAYAMA
Thanks for the patch series.
在 2020年10月11日 09:34, crash-utility-request(a)redhat.com 写道:
> Date: Sun, 11 Oct 2020 10:34:38 +0900
> From: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
> To: crash-utility(a)redhat.com
> Cc: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
> Subject: [Crash-utility] [PATCH 5/5] memory, zram: introduce and
> export readswap()
> Message-ID: <1602380078-27010-6-git-send-email-d.hatayama(a)fujitsu.com>
> Content-Type: text/plain; charset="US-ASCII"
>
> try_zram_decompress() is currently exported to extension modules, but
> from a viewpoint of author of extension modules, it's better to export
> an interface to read memory on swap; difference of decompressor are
> then hidden within the interface and there is no need for extension
> modules to update accordingly each time new decompressor are added in
> the future.
>
> So let's introduce function readswap() as an interface to read memory
> on swap.
>
> Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
> ---
After applied this patch, I got the following compiling error. But when I
used the 'make lzo' command to compile, it doen't have any problems, which
automatically added the option '-DLZO' to compiling command.
Did you run into this compiling issue? Or is that the expected result?
BTW: Crash can be compiled successfully without this patch [PATCH 5/5].
[root@dell-pec5125-03 crash]# make
TARGET: X86_64
CRASH: 7.2.8++
GDB: 7.6
gcc -g -O2 -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DCRASH_MERGE -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber -I./gnulib/import -Ibuild-gnulib/import -DTUI=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -c -o symtab.o -MT symtab.o -MMD -MP -MF .deps/symtab.Tpo symtab.c
Making init.c
gcc -g -O2 -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DCRASH_MERGE -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber -I./gnulib/import -Ibuild-gnulib/import -DTUI=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -c -o init.o -MT init.o -MMD -MP -MF .deps/init.Tpo init.c
cc -c -g -DX86_64 -DGDB_7_6 build_data.c
cc -c -g -DX86_64 -DGDB_7_6 main.c
cc -c -g -DX86_64 -DGDB_7_6 tools.c
cc -c -g -DX86_64 -DGDB_7_6 global_data.c
cc -c -g -DX86_64 -DGDB_7_6 memory.c
cc -c -g -DX86_64 -DGDB_7_6 filesys.c
cc -c -g -DX86_64 -DGDB_7_6 help.c
cc -c -g -DX86_64 -DGDB_7_6 task.c
cc -c -g -DX86_64 -DGDB_7_6 kernel.c
cc -c -g -DX86_64 -DGDB_7_6 test.c
cc -c -g -DX86_64 -DGDB_7_6 gdb_interface.c
cc -c -g -DX86_64 -DGDB_7_6 net.c
cc -c -g -DX86_64 -DGDB_7_6 dev.c
cc -c -g -DX86_64 -DGDB_7_6 bpf.c
cc -c -g -DX86_64 -DGDB_7_6 alpha.c
cc -c -g -DX86_64 -DGDB_7_6 x86.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 ppc.c
cc -c -g -DX86_64 -DGDB_7_6 ia64.c
cc -c -g -DX86_64 -DGDB_7_6 s390.c
cc -c -g -DX86_64 -DGDB_7_6 s390x.c
cc -c -g -DX86_64 -DGDB_7_6 s390dbf.c
cc -c -g -DX86_64 -DGDB_7_6 ppc64.c
cc -c -g -DX86_64 -DGDB_7_6 x86_64.c
cc -c -g -DX86_64 -DGDB_7_6 arm.c
cc -c -g -DX86_64 -DGDB_7_6 arm64.c
cc -c -g -DX86_64 -DGDB_7_6 mips.c
cc -c -g -DX86_64 -DGDB_7_6 sparc64.c
cc -c -g -DX86_64 -DGDB_7_6 extensions.c
cc -c -g -DX86_64 -DGDB_7_6 va_server.c
cc -c -g -DX86_64 -DGDB_7_6 va_server_v1.c
cc -c -g -DX86_64 -DGDB_7_6 symbols.c -I./gdb-7.6/bfd -I./gdb-7.6/include
cc -c -g -DX86_64 -DGDB_7_6 cmdline.c -I./gdb-7.6/readline
cc -c -g -DX86_64 -DGDB_7_6 lkcd_common.c
cc -c -g -DX86_64 -DGDB_7_6 lkcd_v1.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 lkcd_v2_v3.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 lkcd_v5.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 lkcd_v7.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 lkcd_v8.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 lkcd_fix_mem.c -DMCLX
cc -c -g -DX86_64 -DGDB_7_6 s390_dump.c
cc -c -g -DX86_64 -DGDB_7_6 netdump.c
cc -c -g -DX86_64 -DGDB_7_6 diskdump.c
cc -c -g -DX86_64 -DGDB_7_6 makedumpfile.c
cc -c -g -DX86_64 -DGDB_7_6 xendump.c
cc -c -g -DX86_64 -DGDB_7_6 lkcd_x86_trace.c -DREDHAT
cc -c -g -DX86_64 -DGDB_7_6 unwind.c -DREDHAT -DUNWIND_V1 -o unwind_v1.o
cc -c -g -DX86_64 -DGDB_7_6 unwind.c -DREDHAT -DUNWIND_V2 -o unwind_v2.o
cc -c -g -DX86_64 -DGDB_7_6 unwind.c -DREDHAT -DUNWIND_V3 -o unwind_v3.o
cc -c -g -DX86_64 -DGDB_7_6 unwind_x86_32_64.c -o unwind_x86_32_64.o
cc -c -g -DX86_64 -DGDB_7_6 unwind_arm.c -o unwind_arm.o
cc -c -g -DX86_64 -DGDB_7_6 xen_hyper.c
cc -c -g -DX86_64 -DGDB_7_6 xen_hyper_command.c
cc -c -g -DX86_64 -DGDB_7_6 xen_hyper_global_data.c
cc -c -g -DX86_64 -DGDB_7_6 xen_hyper_dump_tables.c
cc -c -g -DX86_64 -DGDB_7_6 kvmdump.c
cc -c -g -DX86_64 -DGDB_7_6 qemu.c
cc -c -g -DX86_64 -DGDB_7_6 qemu-load.c
cc -c -g -DX86_64 -DGDB_7_6 sadump.c
cc -c -g -DX86_64 -DGDB_7_6 ipcs.c
cc -c -g -DX86_64 -DGDB_7_6 ramdump.c
cc -c -g -DX86_64 -DGDB_7_6 vmware_vmss.c
cc -c -g -DX86_64 -DGDB_7_6 vmware_guestdump.c
cc -c -g -DX86_64 -DGDB_7_6 xen_dom0.c
cc -c -g -DX86_64 -DGDB_7_6 kaslr_helper.c
ar -rs crashlib.a main.o tools.o global_data.o memory.o filesys.o help.o task.o build_data.o kernel.o test.o gdb_interface.o net.o dev.o bpf.o alpha.o x86.o ppc.o ia64.o s390.o s390x.o s390dbf.o ppc64.o x86_64.o arm.o arm64.o mips.o sparc64.o extensions.o remote.o va_server.o va_server_v1.o symbols.o cmdline.o lkcd_common.o lkcd_v1.o lkcd_v2_v3.o lkcd_v5.o lkcd_v7.o lkcd_v8.o lkcd_fix_mem.o s390_dump.o netdump.o diskdump.o makedumpfile.o xendump.o lkcd_x86_trace.o unwind_v1.o unwind_v2.o unwind_v3.o unwind_x86_32_64.o unwind_arm.o xen_hyper.o xen_hyper_command.o xen_hyper_global_data.o xen_hyper_dump_tables.o kvmdump.o qemu.o qemu-load.o sadump.o ipcs.o ramdump.o vmware_vmss.o vmware_guestdump.o xen_dom0.o kaslr_helper.o
ar: creating crashlib.a
gcc -g -O2 \
-o ../../crash ../../crashlib.a amd64-tdep.o amd64-linux-tdep.o i386-tdep.o i387-tdep.o i386-linux-tdep.o glibc-tdep.o solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o ser-base.o ser-unix.o ser-pipe.o ser-tcp.o inf-ptrace.o fork-child.o i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o linux-osdata.o proc-service.o linux-thread-db.o linux-fork.o linux-procfs.o linux-ptrace.o linux-btrace.o remote.o dcache.o tracepoint.o ax-general.o ax-gdb.o remote-fileio.o remote-notif.o cli-dump.o cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-logging.o cli-interp.o cli-utils.o mi-out.o mi-console.o mi-cmds.o mi-cmd-catch.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-cmd-target.o mi-cmd-info.o mi-interp.o mi-main.o mi-parse.o mi-getopt.o tui-command.o tui-data.o tui-disasm.o tui-file.o tui-hooks.o tui-interp.o tui-io.o tui-layout.o tui-out.o tui-regs.o tui-source.o tui-stack.o tui-win.o tui-windata.o tui-wingeneral.o tui-winsource.o tui.o python.o py-value.o py-prettyprint.o py-auto-load.o elfread.o stap-probe.o posix-hdep.o c-exp.o cp-name-parser.o ada-exp.o jv-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o version.o annotate.o addrmap.o auto-load.o auxv.o agent.o bfd-target.o blockframe.o breakpoint.o break-catch-sig.o findvar.o regcache.o cleanups.o charset.o continuations.o corelow.o disasm.o dummy-frame.o dfp.o source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o block.o symtab.o psymtab.o symfile.o symmisc.o linespec.o dictionary.o infcall.o infcmd.o infrun.o expprint.o environ.o stack.o thread.o exceptions.o filesystem.o inf-child.o interps.o minidebug.o main.o macrotab.o macrocmd.o macroexp.o macroscope.o mi-common.o event-loop.o event-top.o inf-loop.o completer.o gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o gdb_obstack.o osabi.o copying.o memattr.o mem-break.o target.o parse.o language.o buildsym.o findcmd.o std-regs.o signals.o exec.o reverse.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o dbxread.o coffread.o coff-pe-re
ad.o dwarf2read.o mipsread.o stabsread.o corefile.o dwarf2expr.o dwarf2loc.o dwarf2-frame.o dwarf2-frame-tailcall.o ada-lang.o c-lang.o d-lang.o f-lang.o objc-lang.o ada-tasks.o ada-varobj.o ui-out.o cli-out.o varobj.o vec.o go-lang.o go-valprint.o go-typeprint.o jv-lang.o jv-valprint.o jv-typeprint.o m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o sentinel-frame.o complaints.o typeprint.o ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o ada-valprint.o c-valprint.o cp-valprint.o d-valprint.o f-valprint.o m2-valprint.o serial.o mdebugread.o top.o utils.o ui-file.o user-regs.o frame.o frame-unwind.o doublest.o frame-base.o inline-frame.o gnu-v2-abi.o gnu-v3-abi.o cp-abi.o cp-support.o cp-namespace.o reggroups.o regset.o trad-frame.o tramp-frame.o solib.o solib-target.o prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o xml-utils.o target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o inferior.o osdata.o gdb_usleep.o record.o record-full.o gcore.o gdb_vecs.o jit.o progspace.o skip.o probe.o common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o format.o registry.o btrace.o record-btrace.o inflow.o init.o \
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -ldl -lncurses -lz -lm -llzma ../libiberty/libiberty.a build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list -lz -ldl -rdynamic
/usr/bin/ld: ../../crashlib.a(memory.o): in function `readmem':
/home/crash/memory.c:2299: undefined reference to `readswap'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:1188: gdb] Error 1
make[2]: *** [Makefile:245: rebuild] Error 2
make[1]: *** [Makefile:233: gdb_merge] Error 2
make: *** [Makefile:225: all] Error 2
[root@dell-pec5125-03 crash]#
Thanks.
Lianbo
> defs.h | 1 +
> diskdump.c | 67 ++++++++++++++++++++++++++++++++++++++++++++------------------
> memory.c | 5 ++++-
> 3 files changed, 53 insertions(+), 20 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index c899fe2..8bb5618 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -6506,6 +6506,7 @@ int diskdump_kaslr_check(void);
> QEMUCPUState *diskdump_get_qemucpustate(int);
> void diskdump_device_dump_info(FILE *);
> void diskdump_device_dump_extract(int, char *, FILE *);
> +ulong readswap(ulonglong pte_val, char *buf, ulong len, ulonglong vaddr);
> /*support for zram*/
> ulong try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong vaddr);
> #ifdef LZO
> diff --git a/diskdump.c b/diskdump.c
> index cdbc2d5..3762314 100644
> --- a/diskdump.c
> +++ b/diskdump.c
> @@ -2704,24 +2704,15 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
> return NULL;
> }
>
> -ulong (*decompressor)(unsigned char *in_addr, ulong in_size, unsigned char *out_addr, ulong *out_size, void *other/* NOT USED */);
> -/*
> - * If userspace address was swapped out to zram, this function is called to decompress the object.
> - * try_zram_decompress returns decompressed page data and data length
> - */
> -ulong
> -try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong vaddr)
> +static int get_disk_name_private_data(ulonglong pte_val,
> + ulonglong vaddr,
> + char *name,
> + ulong *private_data)
> {
> - char name[32] = {0};
> - ulonglong swp_offset;
> - ulong swap_info, bdev, bd_disk, zram, zram_table_entry, sector, index, entry, flags, size, outsize, off;
> - unsigned char *obj_addr = NULL;
> - unsigned char *zram_buf = NULL;
> - unsigned char *outbuf = NULL;
> + ulong swap_info, bdev, bd_disk;
>
> - off = PAGEOFFSET(vaddr);
> if (!symbol_exists("swap_info"))
> - return 0;
> + return FALSE;
>
> swap_info = symbol_value("swap_info");
>
> @@ -2738,16 +2729,53 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
> sizeof(void *), "swap_info_struct_bdev", FAULT_ON_ERROR);
> readmem(bdev + OFFSET(block_device_bd_disk), KVADDR, &bd_disk,
> sizeof(void *), "block_device_bd_disk", FAULT_ON_ERROR);
> - readmem(bd_disk + OFFSET(gendisk_disk_name), KVADDR, name,
> + if (name)
> + readmem(bd_disk + OFFSET(gendisk_disk_name), KVADDR, name,
> strlen("zram"), "gendisk_disk_name", FAULT_ON_ERROR);
> + if (private_data)
> + readmem(bd_disk + OFFSET(gendisk_private_data), KVADDR,
> + private_data, sizeof(void *), "gendisk_private_data",
> + FAULT_ON_ERROR);
> +
> + return TRUE;
> +}
> +
> +ulong readswap(ulonglong pte_val, char *buf, ulong len, ulonglong vaddr)
> +{
> + char name[32] = {0};
>
> - if (strncmp(name, "zram", strlen("zram"))) {
> + if (!get_disk_name_private_data(pte_val, vaddr, name, NULL))
> + return 0;
> +
> + if (!strncmp(name, "zram", 4)) {
> + return try_zram_decompress(pte_val,
> + (unsigned char *)buf,
> + len,
> + vaddr);
> + } else {
> if (CRASHDEBUG(2))
> error(WARNING,
> "this page has been swapped to %s\n",
> name);
> return 0;
> }
> +}
> +
> +ulong (*decompressor)(unsigned char *in_addr, ulong in_size, unsigned char *out_addr, ulong *out_size, void *other/* NOT USED */);
> +/*
> + * If userspace address was swapped out to zram, this function is called to decompress the object.
> + * try_zram_decompress returns decompressed page data and data length
> + */
> +ulong
> +try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong vaddr)
> +{
> + char name[32] = {0};
> + ulonglong swp_offset;
> + unsigned char *obj_addr = NULL;
> + unsigned char *zram_buf = NULL;
> + unsigned char *outbuf = NULL;
> + ulong zram, zram_table_entry, sector, index, entry, flags, size,
> + outsize, off;
>
> if (INVALID_MEMBER(zram_compressor)) {
> zram_init();
> @@ -2763,8 +2791,8 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
> if (CRASHDEBUG(2))
> error(WARNING, "this page has swapped to zram\n");
>
> - readmem(bd_disk + OFFSET(gendisk_private_data), KVADDR, &zram,
> - sizeof(void *), "gendisk_private_data", FAULT_ON_ERROR);
> + if (!get_disk_name_private_data(pte_val, vaddr, NULL, &zram))
> + return 0;
>
> readmem(zram + OFFSET(zram_compressor), KVADDR, name,
> sizeof(name), "zram compressor", FAULT_ON_ERROR);
> @@ -2789,6 +2817,7 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
>
> zram_buf = (unsigned char *)GETBUF(PAGESIZE());
> /*lookup page from swap cache*/
> + off = PAGEOFFSET(vaddr);
> obj_addr = lookup_swap_cache(pte_val, zram_buf);
> if (obj_addr != NULL) {
> memcpy(buf, obj_addr + off, len);
> diff --git a/memory.c b/memory.c
> index c951827..44213bb 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2296,7 +2296,10 @@ readmem(ulonglong addr, int memtype, void *buffer, long size,
> if (cnt > size)
> cnt = size;
>
> - cnt = try_zram_decompress(paddr, (unsigned char *)bufptr, cnt, addr);
> + cnt = readswap(addr,
> + bufptr,
> + cnt,
> + addr);
> if (cnt) {
> bufptr += cnt;
> addr += cnt;
> -- 1.8.3.1
4 years, 2 months
Re: [Crash-utility] [PATCH] Fix for failure when using extensions on PPC64 target x86_64 binary
by lijiang
Hi, Kazu and Arun
在 2020年09月25日 00:00, crash-utility-request(a)redhat.com 写道:
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. [PATCH] Fix for failure when using extensions on PPC64 target
> x86_64 binary (HAGIO KAZUHITO (?????))
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 24 Sep 2020 08:16:06 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Subject: [Crash-utility] [PATCH] Fix for failure when using extensions
> on PPC64 target x86_64 binary
> Message-ID:
> <OSBPR01MB1991B1B7CD686FBC72827E2BDD390(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> Without the patch, the "extend" command on an x86_64 binary that can
> be used to analyze ppc64le dumpfiles fails with the error meesage
> "extend: <path to extension>: not an ELF format object".
>
> Suggested-by: Arun Easi <aeasi.linux(a)gmail.com>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> I'm not sure which tag I should use in this case, so if you want
> me to use another one e.g. Signed-off-by, please let me know.
>
> symbols.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/symbols.c b/symbols.c
> index d22fb1d9bdd1..603946db4f34 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -3868,7 +3868,8 @@ is_shared_object(char *file)
> break;
>
> case EM_X86_64:
> - if (machine_type("X86_64") || machine_type("ARM64"))
> + if (machine_type("X86_64") || machine_type("ARM64") ||
> + machine_type("PPC64"))
For the other architectures such as S390, IA64, etc, is it possible to occur
the similar problems on an x86_64 host? Or no one uses it like this?
Thanks.
Lianbo
> return TRUE;
> break;
>
>
4 years, 2 months