Support RISCV64 arch and common commands
Subsystems (4)
v4 cover Support RISCV64 arch and common commands
This series of patches are for Crash-utility tool, it make crash tool support RISCV64 arch and the common commands(*, bt, p, rd, mod, log, set, struct, task, dis, help -r, help -m, and so on).
To make the crash tool work normally for RISCV64 arch, we need a Linux kernel patch, which exports the kernel virtual memory layout, va_bits, phys_ram_base to vmcoreinfo, it can simplify the development of crash tool.
The Linux kernel patch set:
https://lore.kernel.org/lkml/[email protected]/
This series of patches are tested on QEMU RISCV64 env and SoC platform of T-head Xuantie 910 RISCV64 CPU.
====================================
Some test examples list as below
====================================
... ...
KERNEL: vmlinux
DUMPFILE: vmcore
CPUS: 1
DATE: Fri Jul 15 10:24:25 CST 2022
UPTIME: 00:00:33
LOAD AVERAGE: 0.05, 0.01, 0.00
TASKS: 41
NODENAME: buildroot
RELEASE: 5.18.9
VERSION: #30 SMP Fri Jul 15 09:47:03 CST 2022
MACHINE: riscv64 (unknown Mhz)
MEMORY: 1 GB
PANIC: "Kernel panic - not syncing: sysrq triggered crash"
PID: 113
COMMAND: "sh"
TASK: ff60000002269600 [THREAD_INFO: ff60000002269600]
CPU: 0
STATE: TASK_RUNNING (PANIC)carsh>
crash> p mem_mapmem_map = $1 = (struct page *) 0xff6000003effbf00
crash> p /x *(struct page *) 0xff6000003effbf00
$5 = {
flags = 0x1000,
{
{
{
lru = {
next = 0xff6000003effbf08,
prev = 0xff6000003effbf08
},
{
__filler = 0xff6000003effbf08,
mlock_count = 0x3effbf08
}
},
mapping = 0x0,
index = 0x0,
private = 0x0
},... ...
crash> mod
MODULE NAME BASE SIZE OBJECT FILE ffffffff0113e740 nvme_core ffffffff01133000 98304 (not loaded) [CONFIG_KALLSYMS] ffffffff011542c0 nvme ffffffff0114c000 61440 (not loaded) [CONFIG_KALLSYMS]
crash> rd ffffffff0113e740 8
ffffffff0113e740: 0000000000000000 ffffffff810874f8 .........t...... ffffffff0113e750: ffffffff011542c8 726f635f656d766e .B......nvme_cor ffffffff0113e760: 0000000000000065 0000000000000000 e............... ffffffff0113e770: 0000000000000000 0000000000000000 ................
crash> vtop ffffffff0113e740
VIRTUAL PHYSICALffffffff0113e740 8254d740
PGD: ffffffff810e9ff8 => 2ffff001
P4D: 0000000000000000 => 000000002fffec01
PUD: 00005605c2957470 => 0000000020949801
PMD: 00007fff7f1750c0 => 0000000020947401
PTE: 0 => 209534e7
PAGE: 000000008254d000
PTE PHYSICAL FLAGS 209534e7 8254d000 (PRESENT|READ|WRITE|GLOBAL|ACCESSED|DIRTY)
PAGE PHYSICAL MAPPING INDEX CNT FLAGSff6000003f0777d8 8254d000 0 0 1 0
crash> bt
PID: 113 TASK: ff6000000226c200 CPU: 0 COMMAND: "sh"
#0 [ff20000010333b90] riscv_crash_save_regs at ffffffff800078f8 #1 [ff20000010333cf0] panic at ffffffff806578c6
#2 [ff20000010333d50] sysrq_reset_seq_param_set at ffffffff8038c03c #3 [ff20000010333da0] __handle_sysrq at ffffffff8038c604 #4 [ff20000010333e00] write_sysrq_trigger at ffffffff8038cae4 #5 [ff20000010333e20] proc_reg_write at ffffffff801b7ee8 #6 [ff20000010333e40] vfs_write at ffffffff80152bb2
#7 [ff20000010333e80] ksys_write at ffffffff80152eda
#8 [ff20000010333ed0] sys_write at ffffffff80152f52
-------
Changes V1 -> V2:
1, Do the below fixes based on HAGIO KAZUHITO's comments:
Fix build warnings,
Use MACRO for Linux version,
Add description of x86_64 binary for riscv64 in README,
Fix build error for the "sticky" target for build on x86_64,
Fix the mixed indent.
2, Add 'help -m/M' support patch to this patch set.
3, Support native compiling approach, which means the host OS distro
is also a riscv64 (lp64d) Linux, based on Yixun Lan's comments.
4, Use __riscv and __riscv_xlen instead of __riscv64__ based on Yixun Lan's comments.
Changes V2 -> V3:
1, Fix coding style, avoid including the header twice, move free() to right place,
introduce VM_FLAGS and so on based on Li Jiang's comments.
2, Adjust the implementation of riscv64_verify_symbol(refer to the logic of x86_64_verify_symbol)
as KSYMS_START isn't set when verify symbol in some case.
Changes V3 -> V4:
1, rebase this patch set to latest crash code.
2, Remove the code of get the value of ADDRESS_SPACE_END, which is not used in current implementation.
Xianting Tian (9):
Add RISCV64 framework code support
RISCV64: Make crash tool enter command line and support some commands
RISCV64: Add 'dis' command support
RISCV64: Add irq command support
RISCV64: Add 'bt' command support
RISCV64: Add 'help -r' command support
RISCV64: Add 'help -m/M' command support
RISCV64: Add 'mach' command support
RISCV64: Add the implementation of symbol verify
Makefile | 7 +- README | 4 +- configure.c | 43 +- defs.h | 251 +++++++- diskdump.c | 21 +- help.c | 2 +- lkcd_vmdump_v1.h | 8 +- lkcd_vmdump_v2_v3.h | 8 +- netdump.c | 22 +- ramdump.c | 2 + riscv64.c | 1485 +++++++++++++++++++++++++++++++++++++++++++ symbols.c | 10 + 12 files changed, 1841 insertions(+), 22 deletions(-) create mode 100644 riscv64.c
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 1/9 Add RISCV64 framework code support
This patch mainly added some environment configurations, macro definitions, specific architecture structures and some function declarations supported by the RISCV64 architecture.
We can use the build command to get the simplest version crash tool:
make target=RISCV64 -j2
--- Makefile | 7 +- README | 4 +- configure.c | 43 ++++++++++++- defs.h | 154 +++++++++++++++++++++++++++++++++++++++++++- diskdump.c | 11 +++- help.c | 2 +- lkcd_vmdump_v1.h | 8 +-- lkcd_vmdump_v2_v3.h | 8 +-- netdump.c | 9 ++- ramdump.c | 2 + riscv64.c | 54 ++++++++++++++++ symbols.c | 10 +++ 12 files changed, 290 insertions(+), 22 deletions(-) create mode 100644 riscv64.c
Makefile +5 -2
@@ -64,7 +64,7 @@ CFILES=main.c tools.c global_data.c memory.c filesys.c help.c task.c \ kernel.c test.c gdb_interface.c configure.c net.c dev.c bpf.c \ printk.c \ alpha.c x86.c ppc.c ia64.c s390.c s390x.c s390dbf.c ppc64.c x86_64.c \ - arm.c arm64.c mips.c mips64.c sparc64.c \ + arm.c arm64.c mips.c mips64.c riscv64.c sparc64.c \ extensions.c remote.c va_server.c va_server_v1.c symbols.c cmdline.c \ lkcd_common.c lkcd_v1.c lkcd_v2_v3.c lkcd_v5.c lkcd_v7.c lkcd_v8.c\ lkcd_fix_mem.c s390_dump.c lkcd_x86_trace.c \
@@ -84,7 +84,7 @@ OBJECT_FILES=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 \ printk.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 mips64.o sparc64.o \ + arm.o arm64.o mips.o mips64.o riscv64.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 \
@@ -438,6 +438,9 @@ mips.o: ${GENERIC_HFILES} ${REDHAT_HFILES} mips.c mips64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} mips64.c ${CC} -c ${CRASH_CFLAGS} mips64.c ${WARNING_OPTIONS} ${WARNING_ERROR} +riscv64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} riscv64.c + ${CC} -c ${CRASH_CFLAGS} riscv64.c ${WARNING_OPTIONS} ${WARNING_ERROR} + sparc64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} sparc64.c ${CC} -c ${CRASH_CFLAGS} sparc64.c ${WARNING_OPTIONS} ${WARNING_ERROR}
README +3 -1
@@ -37,7 +37,7 @@ These are the current prerequisites: o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future. o One size fits all -- the utility can be run on any Linux kernel version
@@ -98,6 +98,8 @@ arm64 dumpfiles may be built by typing "make target=ARM64". o On an x86_64 host, an x86_64 binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On an x86_64 host, an x86_64 binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utility
configure.c +42 -1
127 lines not on this page · raw message
defs.h +153 -1
202 lines not on this page · raw message
diskdump.c +9 -2
@@ -622,6 +622,9 @@ restart:else if (STRNEQ (header->utsname.machine,"aarch64" ) &&machine_type_mismatch (file,"ARM64" ,NULL ,0 )) goto err; +else if (STRNEQ (header->utsname.machine,"riscv64" ) && +machine_type_mismatch (file,"RISCV64" ,NULL ,0 )) + goto err;if (header->block_size != block_size) { block_size = header->block_size;
@@ -780,6 +783,8 @@ restart: dd->machine_type =EM_AARCH64 ; else if (machine_type("SPARC64")) dd->machine_type =EM_SPARCV9 ; + else if (machine_type("RISCV64")) + dd->machine_type =EM_RISCV ; else { error(INFO, "%s: unsupported machine type: %s\n", DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
@@ -1751,7 +1756,8 @@ dump_note_offsets(FILE *fp) qemu = FALSE;if (machine_type ("X86_64" ) ||machine_type ("S390X" ) ||machine_type ("ARM64" ) ||machine_type ("PPC64" ) || -machine_type ("SPARC64" ) ||machine_type ("MIPS64" )) { +machine_type ("SPARC64" ) ||machine_type ("MIPS64" ) || +machine_type ("RISCV64" )) { note64 = (void *)dd->notes_buf + tot; len =sizeof (Elf64_Nhdr);if (STRNEQ ((char *)note64 + len,"QEMU" ))
@@ -2558,7 +2564,8 @@ dump_registers_for_compressed_kdump(void)if (!KDUMP_CMPRS_VALID () || (dd->header->header_version <4 ) || !(machine_type ("X86" ) ||machine_type ("X86_64" ) ||machine_type ("ARM64" ) ||machine_type ("PPC64" ) || -machine_type ("MIPS" ) ||machine_type ("MIPS64" ))) +machine_type ("MIPS" ) ||machine_type ("MIPS64" ) || +machine_type ("RISCV64" )))error (FATAL ,"-r option not supported for this dumpfile\n" );if (machine_type ("ARM64" ) && (kt->cpus != dd->num_prstatus_notes))
help.c +1 -1
@@ -9512,7 +9512,7 @@ char *README[] = {" These are the current prerequisites: " ,"" ," o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips," , -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" ," may be addressed in the future." ,"" , " o One size fits all -- the utility can be run on any Linux kernel version",
lkcd_vmdump_v1.h +1 -7
@@ -114,14 +114,8 @@ typedef struct _dump_header_s {struct new_utsname dh_utsname;/* the dump registers */ -#ifndef IA64 -#ifndef S390 -#ifndef S390X -#ifndef ARM64 +#if !defined(IA64 ) && !defined(S390 ) && !defined(S390X ) && !defined(ARM64 ) && !defined(RISCV64 )struct pt_regs dh_regs; -#endif -#endif -#endif #endif /* the address of the current task */
lkcd_vmdump_v2_v3.h +2 -6
@@ -37,7 +37,7 @@#if defined(ARM ) || defined(X86 ) || defined(PPC ) || defined(S390 ) || \ defined(S390X ) || defined(ARM64 ) || defined(MIPS ) || \ - defined(MIPS64 ) || defined(SPARC64 ) + defined(MIPS64 ) || defined(SPARC64 ) || defined(RISCV64 )/* * Kernel header file for Linux crash dumps.
@@ -84,13 +84,9 @@ typedef struct _dump_header_asm_s {uint32_t dha_eip;/* the dump registers */ -#ifndef S390 -#ifndef S390X -#ifndef ARM64 +#if !defined(S390 ) && !defined(S390X ) && !defined(ARM64 ) && !defined(RISCV64 )struct pt_regs dha_regs;#endif -#endif -#endif } dump_header_asm_t;
netdump.c +8 -1
@@ -300,6 +300,12 @@ is_netdump(char *file, ulong source_query) goto bailout;break ; +case EM_RISCV : +if (machine_type_mismatch (file,"RISCV64" ,NULL , + source_query)) + goto bailout; +break ; +default :if (machine_type_mismatch (file,"(unknown)" ,NULL , source_query))
@@ -2935,7 +2941,8 @@ dump_registers_for_elf_dumpfiles(void)if (!(machine_type ("X86" ) ||machine_type ("X86_64" ) ||machine_type ("ARM64" ) ||machine_type ("PPC64" ) || -machine_type ("MIPS" ) ||machine_type ("MIPS64" ))) +machine_type ("MIPS" ) ||machine_type ("MIPS64" ) || +machine_type ("RISCV64" )))error (FATAL ,"-r option not supported for this dumpfile\n" );if (NETDUMP_DUMPFILE ()) {
ramdump.c +2 -0
@@ -188,6 +188,8 @@ char *ramdump_to_elf(void) e_machine =EM_MIPS ; else if (machine_type("X86_64")) e_machine =EM_X86_64 ; + else if (machine_type("RISCV64")) + e_machine =EM_RISCV ; else error(FATAL, "ramdump: unsupported machine type: %s\n", MACHINE_TYPE);
riscv64.c new file +54 -0
54 lines not on this page · raw message
symbols.c +10 -0
@@ -3743,6 +3743,11 @@ is_kernel(char *file) goto bailout;break ; +case EM_RISCV : +if (machine_type_mismatch (file,"RISCV64" ,NULL ,0 )) + goto bailout; +break ; +default :if (machine_type_mismatch (file,"(unknown)" ,NULL ,0 )) goto bailout;
@@ -4002,6 +4007,11 @@ is_shared_object(char *file)if (machine_type ("MIPS64" ))return TRUE;break ; + +case EM_RISCV : +if (machine_type ("RISCV64" )) +return TRUE; +break ; }if (CRASHDEBUG (1 ))
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
README line 41
Quoted 11 lines · Xianting Tian
README +1
-1@@ -37,7 +37,7 @@ These are the current prerequisites: o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future.
Sentences in the README are wrapped within 80 characters, I will change this to:
+ mips64, riscv64, s390 and s390x-based kernels are supported. Other
+ architectures may be addressed in the future.
Quoted 18 lines
README +2
-0o One size fits all -- the utility can be run on any Linux kernel version@@ -98,6 +98,8 @@ arm64 dumpfiles may be built by typing "make target=ARM64". o On an x86_64 host, an x86_64 binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On an x86_64 host, an x86_64 binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utilityhelp.c +0
-0
help.c char *README[] = { · line 9518
Quoted 8 lines
help.c +1
-1@@ -9512,7 +9512,7 @@ char *README[] = {" These are the current prerequisites: " ,"" ," o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips," , -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" ," may be addressed in the future." ,"" , " o One size fits all -- the utility can be run on any Linux kernel version",
Same as above.
And help.c lacks this part, will add:
@@ -9572,6 +9572,8 @@ README_ENTER_DIRECTORY,
" arm64 dumpfiles may be built by typing \"make target=ARM64\".", " o On an x86_64 host, an x86_64 binary that can be used to analyze", " ppc64le dumpfiles may be built by typing \"make target=PPC64\".",
+" o On an x86_64 host, an x86_64 binary that can be used to analyze",
+" riscv64 dumpfiles may be built by typing \"make target=RISCV64\".",
"",
" Traditionally when vmcores are compressed via the makedumpfile(8) facility", " the libz compression library is used, and by default the crash utility",
With these, the v4 crash patch set looks good to me.
Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
Quoted 9 lines · HAGIO KAZUHITO(萩尾 一仁)
Quoted 7 lines · Xianting Tian
README +0
-0@@ -37,7 +37,7 @@ These are the current prerequisites:
Quoted 5 lines
README line 41
Quoted 4 lines
README +1
-1o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future.Sentences in the README are wrapped within 80 characters, I will change
thanks,
Do you need me to send V5 patch set to fix this?
Quoted 45 lines
this to:
(quoted diff) +2
-0+ mips64, riscv64, s390 and s390x-based kernels are supported. Other + architectures may be addressed in the future.Quoted 18 lines
README +2
-0o One size fits all -- the utility can be run on any Linux kernel version@@ -98,6 +98,8 @@ arm64 dumpfiles may be built by typing "make target=ARM64". o On an x86_64 host, an x86_64 binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On an x86_64 host, an x86_64 binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utilityhelp.c +0
-0help.c char *README[] = { · line 9518
Quoted 8 lines
help.c +1
-1@@ -9512,7 +9512,7 @@ char *README[] = {" These are the current prerequisites: " ,"" ," o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips," , -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" ," may be addressed in the future." ,"" , " o One size fits all -- the utility can be run on any Linux kernel version",Same as above.
And
help.clacks this part, will add:(quoted diff) +2
-0@@ -9572,6 +9572,8 @@ README_ENTER_DIRECTORY, " arm64 dumpfiles may be built by typing \"make target=ARM64\".", " o On an x86_64 host, an x86_64 binary that can be used to analyze", " ppc64le dumpfiles may be built by typing \"make target=PPC64\".", +" o On an x86_64 host, an x86_64 binary that can be used to analyze", +" riscv64 dumpfiles may be built by typing \"make target=RISCV64\".", "", " Traditionally when vmcores are compressed via the makedumpfile(8) facility", " the libz compression library is used, and by default the crash utility",
Quoted 6 lines
With these, the v4 crash patch set looks good to me.
Acked-by Kazuhito Hagio <[email protected]>Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
Quoted 16 lines · Xianting Tian
Quoted 13 lines · HAGIO KAZUHITO(萩尾 一仁)
Quoted 10 lines · Xianting Tian
README +0
-0@@ -37,7 +37,7 @@These are the current prerequisites:
o At this point, x86, ia64,x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future.Sentences in the README are wrapped within 80 characters, I will change
Quoted 3 lines
thanks,
Do you need me to send V5 patch set to fix this?
No, I will amend these when applying.
Thanks,
Kazu
Quoted 44 lines
Quoted 44 lines
this to:
+ mips64, riscv64, s390 and s390x-based kernels are supported. Other + architectures may be addressed in the future.
Quoted 15 lines
o One size fits all -- the utility can be run on any Linux kernel version
README +0
-0@@ -98,6 +98,8 @@arm64 dumpfiles may be built by typing "make target=ARM64". o On an
x86_64host, anx86_64binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On anx86_64host, anx86_64binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utilityhelp.c +0
-0help.c char *README[] = { · line 9518
Quoted 8 lines
help.c +1
-1@@ -9512,7 +9512,7 @@ char *README[] = { " These are the current prerequisites: ", "", " o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips,", -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" , " may be addressed in the future.", "", " o One size fits all -- the utility can be run on any Linux kernel version",Same as above.
And
help.clacks this part, will add:(quoted diff) +2
-0@@ -9572,6 +9572,8 @@ README_ENTER_DIRECTORY, " arm64 dumpfiles may be built by typing \"make target=ARM64\".", " o On an x86_64 host, an x86_64 binary that can be used to analyze", " ppc64le dumpfiles may be built by typing \"make target=PPC64\".", +" o On an x86_64 host, an x86_64 binary that can be used to analyze", +" riscv64 dumpfiles may be built by typing \"make target=RISCV64\".", "", " Traditionally when vmcores are compressed via the makedumpfile(8) facility", " the libz compression library is used, and by default the crash utility",
Quoted 6 lines
Quoted 6 lines
With these, the v4 crash patch set looks good to me.
Acked-by Kazuhito Hagio <[email protected]>Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
Quoted 18 lines · HAGIO KAZUHITO(萩尾 一仁)
Quoted 16 lines · Xianting Tian
Quoted 13 lines · HAGIO KAZUHITO(萩尾 一仁)
README line 40
Quoted 10 lines · Xianting Tian
README +1
-1@@ -37,7 +37,7 @@ These are the current prerequisites: o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future.Sentences in the README are wrapped within 80 characters, I will change
Quoted 6 lines
Quoted 3 lines
thanks,
Do you need me to send V5 patch set to fix this?
No, I will amend these when applying.
On the kernel side, some relevant kernel patches got ack, it seems they won't change anymore.
And the V4 looks good to me, so: Ack.
Thanks.
Lianbo
Quoted 47 lines
Thanks,
KazuQuoted 44 lines
Quoted 44 lines
this to:
(quoted diff) +2
-0+ mips64, riscv64, s390 and s390x-based kernels are supported. Other + architectures may be addressed in the future.Quoted 16 lines
README +2
-0o One size fits all -- the utility can be run on any Linux kernel version@@ -98,6 +98,8 @@ arm64 dumpfiles may be built by typing "make target=ARM64". o On an x86_64 host, an x86_64 binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On an x86_64 host, an x86_64 binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utilityhelp.c +0
-0help.c char *README[] = { · line 9518
Quoted 8 lines
help.c +1
-1@@ -9512,7 +9512,7 @@ char *README[] = {" These are the current prerequisites: " ,"" ," o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips," , -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" ," may be addressed in the future." ,"" , " o One size fits all -- the utility can be run on any Linux kernel version",Same as above.
And
help.clacks this part, will add:(quoted diff) +2
-0@@ -9572,6 +9572,8 @@ README_ENTER_DIRECTORY, " arm64 dumpfiles may be built by typing \"make target=ARM64\".", " o On an x86_64 host, an x86_64 binary that can be used to analyze", " ppc64le dumpfiles may be built by typing \"make target=PPC64\".", +" o On an x86_64 host, an x86_64 binary that can be used to analyze", +" riscv64 dumpfiles may be built by typing \"make target=RISCV64\".", "", " Traditionally when vmcores are compressed via the makedumpfile(8) facility", " the libz compression library is used, and by default the crash utility",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
With these, the v4 crash patch set looks good to me.
Acked-by Kazuhito Hagio <[email protected]>Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
Quoted 19 lines · lijiang
Quoted 17 lines · HAGIO KAZUHITO(萩尾 一仁)
Quoted 16 lines · Xianting Tian
Quoted 13 lines · HAGIO KAZUHITO(萩尾 一仁)
README line 40
Quoted 10 lines · Xianting Tian
README +1
-1@@ -37,7 +37,7 @@ These are the current prerequisites: o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips, - mips64, s390 and s390x-based kernels are supported. Other architectures + mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures may be addressed in the future.Sentences in the README are wrapped within 80 characters, I will change
thanks,
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Do you need me to send V5 patch set to fix this?
No, I will amend these when applying.
On the kernel side, some relevant kernel patches got ack, it seems they won't change anymore.
And the V4 looks good to me, so: Ack.
Thanks, Linux kenrel RISC-V maintainer still don't apply the kernel patch, let's wait.
Quoted 49 lines
Thanks.
LianboQuoted 45 lines
Thanks,
KazuQuoted 42 lines
Quoted 42 lines
this to:
(quoted diff) +2
-0+ mips64, riscv64, s390 and s390x-based kernels are supported. Other + architectures may be addressed in the future.Quoted 15 lines
README +2
-0o One size fits all -- the utility can be run on any Linux kernel version@@ -98,6 +98,8 @@ arm64 dumpfiles may be built by typing "make target=ARM64". o On an x86_64 host, an x86_64 binary that can be used to analyze ppc64le dumpfiles may be built by typing "make target=PPC64". + o On an x86_64 host, an x86_64 binary that can be used to analyze + riscv64 dumpfiles may be built by typing "make target=RISCV64". Traditionally when vmcores are compressed via the makedumpfile(8) facility the libz compression library is used, and by default the crash utilityhelp.c +0
-0help.c char *README[] = { · line 9518
Quoted 8 lines
help.c +1
-1@@ -9512,7 +9512,7 @@ char *README[] = {" These are the current prerequisites: " ,"" ," o At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips," , -" mips64, s390 and s390x-based kernels are supported. Other architectures" , +" mips64, riscv64, s390 and s390x-based kernels are supported. Other architectures" ," may be addressed in the future." ,"" , " o One size fits all -- the utility can be run on any Linux kernel version",Same as above.
And
help.clacks this part, will add:(quoted diff) +2
-0@@ -9572,6 +9572,8 @@ README_ENTER_DIRECTORY, " arm64 dumpfiles may be built by typing \"make target=ARM64\".", " o On an x86_64 host, an x86_64 binary that can be used to analyze", " ppc64le dumpfiles may be built by typing \"make target=PPC64\".", +" o On an x86_64 host, an x86_64 binary that can be used to analyze", +" riscv64 dumpfiles may be built by typing \"make target=RISCV64\".", "", " Traditionally when vmcores are compressed via the makedumpfile(8) facility", " the libz compression library is used, and by default the crash utility",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
With these, the v4 crash patch set looks good to me.
Acked-by Kazuhito Hagio <[email protected]>Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [Crash-utility][PATCH V4 1/9] Add RISCV64 framework code support
Quoted 5 lines · Xianting Tian
Quoted 4 lines
On the kernel side, some relevant kernel patches got ack, it seems they won't change anymore.
And the V4 looks good to me, so: Ack.
Thanks, Linux kenrel RISC-V maintainer still don't apply the kernel patch, let's wait.
Now I see 649d6b1019a2 ("RISC-V: Add arch_crash_save_vmcoreinfo") in the mainline, so applied the crash patchset.
https://github.com/crash-utility/crash/compare/88a4910d95d4...0d5ad129252a
Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 2/9 RISCV64: Make crash tool enter command line and support some commands
In reply to Xianting Tian1. Add riscv64_init() implementation, do all necessary machine-specific setup, which will be called multiple times during initialization.
2. Add riscv64 sv39/48/57 pagetable macro definitions, the function of converting virtual address to a physical address via 4K page table.
For 2M and 1G pagesize, they will be implemented in the future(currently not supported).
3. Add the implementation of the vtop command, which is used to convert a virtual address to a physical address(call the functions defined in 2).
4. Add the implementation to get virtual memory layout, va_bits, phys_ram_base from vmcoreinfo. As these configurations changes from time to time, we send a Linux kernel patch to export these configurations, which can simplify the development of crash tool.
The Linux patch (patch 5 of the patch set):
https://lore.kernel.org/linux-riscv/[email protected]/
5. Add riscv64_get_smp_cpus() implementation, get the number of cpus.
6. Add riscv64_get_page_size() implementation, get page size. And so on.
With this patch, we can enter crash command line, and run "vtop", "mod", "rd", "*", "p", "kmem" ...
Tested on QEMU RISCV64 end and SoC platform of T-head Xuantie 910 CPU.
KERNEL: vmlinux
DUMPFILE: vmcore
CPUS: 1
DATE: Fri Jul 15 10:24:25 CST 2022
UPTIME: 00:00:33
LOAD AVERAGE: 0.05, 0.01, 0.00
TASKS: 41
NODENAME: buildroot
RELEASE: 5.18.9
VERSION: #30 SMP Fri Jul 15 09:47:03 CST 2022
MACHINE: riscv64 (unknown Mhz)
MEMORY: 1 GB
PANIC: "Kernel panic - not syncing: sysrq triggered crash"
PID: 113
COMMAND: "sh"
TASK: ff60000002269600 [THREAD_INFO: ff60000002269600]
CPU: 0
STATE: TASK_RUNNING (PANIC)crash> p mem_mapmem_map = $1 = (struct page *) 0xff6000003effbf00
crash> p /x *(struct page *) 0xff6000003effbf00
$5 = {
flags = 0x1000,
{
{
{
lru = {
next = 0xff6000003effbf08,
prev = 0xff6000003effbf08
},
{
__filler = 0xff6000003effbf08,
mlock_count = 0x3effbf08
}
},
mapping = 0x0,
index = 0x0,
private = 0x0
},crash> mod
MODULE NAME BASE SIZE OBJECT FILE ffffffff0113e740 nvme_core ffffffff01133000 98304 (not loaded) [CONFIG_KALLSYMS] ffffffff011542c0 nvme ffffffff0114c000 61440 (not loaded) [CONFIG_KALLSYMS]
crash> rd ffffffff0113e740 8
ffffffff0113e740: 0000000000000000 ffffffff810874f8 .........t...... ffffffff0113e750: ffffffff011542c8 726f635f656d766e .B......nvme_cor ffffffff0113e760: 0000000000000065 0000000000000000 e............... ffffffff0113e770: 0000000000000000 0000000000000000 ................
crash> vtop ffffffff0113e740
VIRTUAL PHYSICALffffffff0113e740 8254d740
PGD: ffffffff810e9ff8 => 2ffff001
P4D: 0000000000000000 => 000000002fffec01
PUD: 00005605c2957470 => 0000000020949801
PMD: 00007fff7f1750c0 => 0000000020947401
PTE: 0 => 209534e7
PAGE: 000000008254d000
PTE PHYSICAL FLAGS 209534e7 8254d000 (PRESENT|READ|WRITE|GLOBAL|ACCESSED|DIRTY)
PAGE PHYSICAL MAPPING INDEX CNT FLAGSff6000003f0777d8 8254d000 0 0 1 0
--- defs.h | 97 ++++++ diskdump.c | 10 + riscv64.c | 994 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1101 insertions(+)
defs.h +97 -0
@@ -3494,6 +3494,85 @@ struct arm64_stackframe {#define _64BIT_#define MACHINE_TYPE "RISCV64" +typedef struct {ulong pgd; }pgd_t ; +typedef struct {ulong p4d; }p4d_t ; +typedef struct {ulong pud; }pud_t ; +typedef struct {ulong pmd; }pmd_t ; +typedef struct {ulong pte; }pte_t ; +typedef signed int s32 ; + +/* arch/riscv/include/asm/pgtable-64.h */ +#define PGD_SHIFT_L3 (30) +#define PGD_SHIFT_L4 (39) +#define PGD_SHIFT_L5 (48) + +#define P4D_SHIFT (39) +#define PUD_SHIFT (30) +#define PMD_SHIFT (21) + +#define PTRS_PER_PGD (512) +#define PTRS_PER_P4D (512) +#define PTRS_PER_PUD (512) +#define PTRS_PER_PMD (512) +#define PTRS_PER_PTE (512) + +/* +* Mask for bit 0~53(PROT and PPN) of PTE +* 63 6261 60 54 53 10 9 8 7 6 5 4 3 2 1 0 +* N PBMT Reserved P P N RSW D A G U X W R V +*/ +#define PTE_PFN_PROT_MASK 0x3FFFFFFFFFFFFF + +/* +* 3-levels / 4K pages +* +* sv39 +* PGD | PMD | PTE | OFFSET | +* 9 | 9 | 9 | 12 | +*/ +#define pgd_index_l3_4k (addr) (((addr) >> PGD_SHIFT_L3) & (PTRS_PER_PGD - 1)) +#define pmd_index_l3_4k (addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) +#define pte_index_l3_4k (addr) (((addr) >> PAGESHIFT()) & (PTRS_PER_PTE - 1)) + +/* +* 4-levels / 4K pages +* +* sv48 +* PGD | PUD | PMD | PTE | OFFSET | +* 9 | 9 | 9 | 9 | 12 | +*/ +#define pgd_index_l4_4k (addr) (((addr) >> PGD_SHIFT_L4) & (PTRS_PER_PGD - 1)) +#define pud_index_l4_4k (addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) +#define pmd_index_l4_4k (addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) +#define pte_index_l4_4k (addr) (((addr) >> PAGESHIFT()) & (PTRS_PER_PTE - 1)) + +/* +* 5-levels / 4K pages +* +* sv57 +* PGD | P4D | PUD | PMD | PTE | OFFSET | +* 9 | 9 | 9 | 9 | 9 | 12 | +*/ +#define pgd_index_l5_4k (addr) (((addr) >> PGD_SHIFT_L5) & (PTRS_PER_PGD - 1)) +#define p4d_index_l5_4k (addr) (((addr) >> P4D_SHIFT) & (PTRS_PER_P4D - 1)) +#define pud_index_l5_4k (addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) +#define pmd_index_l5_4k (addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) +#define pte_index_l5_4k (addr) (((addr) >> PAGESHIFT()) & (PTRS_PER_PTE - 1)) + +#define VM_L3_4K (0x2) +#define VM_L3_2M (0x4) +#define VM_L3_1G (0x8) +#define VM_L4_4K (0x10) +#define VM_L4_2M (0x20) +#define VM_L4_1G (0x40) +#define VM_L5_4K (0x80) +#define VM_L5_2M (0x100) +#define VM_L5_1G (0x200) + +#define VM_FLAGS (VM_L3_4K | VM_L3_2M | VM_L3_1G | \ + VM_L4_4K | VM_L4_2M | VM_L4_1G | \ + VM_L5_4K | VM_L5_2M | VM_L5_1G) +/* * Direct memory mapping */
@@ -3545,6 +3624,14 @@ struct arm64_stackframe {#define PHYS_MASK_SHIFT _MAX_PHYSMEM_BITS#define PHYS_MASK (((1UL) << PHYS_MASK_SHIFT) - 1) +#define IS_LAST_P4D_READ (p4d) ((ulong)(p4d) == machdep->machspec->last_p4d_read) +#define FILL_P4D (P4D ,TYPE ,SIZE ) \ + if (!IS_LAST_P4D_READ(P4D)) { \ + readmem((ulonglong)((ulong)(P4D)), TYPE, machdep->machspec->p4d, \ + SIZE, "p4d page", FAULT_ON_ERROR); \ + machdep->machspec->last_p4d_read = (ulong)(P4D); \ + } +#endif /* RISCV64 */ #ifdef X86
@@ -6811,6 +6898,10 @@ struct machine_specific {ulong _page_soft;ulong _pfn_shift; +ulong va_bits; +char *p4d; +ulong last_p4d_read; +ulong struct_page_size;struct riscv64_register *crash_task_regs; };
@@ -6834,6 +6925,12 @@ struct machine_specific {#define _PAGE_PROT_NONE _PAGE_READ#define _PAGE_PFN_SHIFT 10 +/* from 'struct pt_regs' definitions of RISC-V arch */ +#define RISCV64_REGS_EPC 0 +#define RISCV64_REGS_RA 1 +#define RISCV64_REGS_SP 2 +#define RISCV64_REGS_FP 8 +#endif /* RISCV64 */ /*
diskdump.c +10 -0
@@ -1531,6 +1531,12 @@ get_diskdump_regs_mips(struct bt_info *bt, ulong *eip, ulong *esp) machdep->get_stack_frame (bt, eip, esp); } +static void +get_diskdump_regs_riscv64 (struct bt_info *bt,ulong *eip,ulong *esp) +{ + machdep->get_stack_frame (bt, eip, esp); +} +static void get_diskdump_regs_sparc64 (struct bt_info *bt,ulong *eip,ulong *esp) {
@@ -1610,6 +1616,10 @@ get_diskdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)get_diskdump_regs_sparc64 (bt, eip, esp);break ; +case EM_RISCV : +get_diskdump_regs_riscv64 (bt, eip, esp); +break ; +default : error(FATAL, "%s: unsupported machine type: %s\n", DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
riscv64.c +994 -0
1,015 lines not on this page · raw message
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 3/9 RISCV64: Add 'dis' command support
In reply to Xianting TianUse generic_dis_filter() function to support dis command implementation.
With this patch, we can get the disassembled code, crash> dis __crash_kexec
0xffffffff80088580 <__crash_kexec>: addi sp,sp,-352 0xffffffff80088582 <__crash_kexec+2>: sd s0,336(sp) 0xffffffff80088584 <__crash_kexec+4>: sd s1,328(sp) 0xffffffff80088586 <__crash_kexec+6>: sd s2,320(sp) 0xffffffff80088588 <__crash_kexec+8>: addi s0,sp,352 0xffffffff8008858a <__crash_kexec+10>: sd ra,344(sp) 0xffffffff8008858c <__crash_kexec+12>: sd s3,312(sp) 0xffffffff8008858e <__crash_kexec+14>: sd s4,304(sp) 0xffffffff80088590 <__crash_kexec+16>: auipc s2,0x1057 0xffffffff80088594 <__crash_kexec+20>: addi s2,s2,-1256 0xffffffff80088598 <__crash_kexec+24>: ld a5,0(s2) 0xffffffff8008859c <__crash_kexec+28>: mv s1,a0 0xffffffff8008859e <__crash_kexec+30>: auipc a0,0xfff
--- riscv64.c | 1 + 1 file changed, 1 insertion(+)
riscv64.c +1 -0
@@ -988,6 +988,7 @@ riscv64_init(int when) machdep->is_task_addr = riscv64_is_task_addr; machdep->get_smp_cpus = riscv64_get_smp_cpus; machdep->value_to_symbol = generic_machdep_value_to_symbol; + machdep->dis_filter = generic_dis_filter; machdep->show_interrupts = generic_show_interrupts; machdep->get_irq_affinity = generic_get_irq_affinity; machdep->init_kernel_pgd =NULL ;/* pgd set by symbol_value("swapper_pg_dir") */
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 4/9 RISCV64: Add irq command support
In reply to Xianting TianWith the patch, we can get the irq info,
crash> irq
IRQ IRQ_DESC/_DATA IRQACTION NAME
0 (unused) (unused)
1 ff60000001329600 ff60000001d17180 "101000.rtc" 2 ff60000001329800 ff60000001d17680 "ttyS0" 3 ff60000001329a00 ff60000001c33c00 "virtio0" 4 ff60000001329c00 ff60000001c33f80 "virtio1" 5 ff6000000120f400 ff60000001216000 "riscv-timer"
--- riscv64.c | 1 + 1 file changed, 1 insertion(+)
riscv64.c +1 -0
@@ -989,6 +989,7 @@ riscv64_init(int when) machdep->get_smp_cpus = riscv64_get_smp_cpus; machdep->value_to_symbol = generic_machdep_value_to_symbol; machdep->dis_filter = generic_dis_filter; + machdep->dump_irq = generic_dump_irq; machdep->show_interrupts = generic_show_interrupts; machdep->get_irq_affinity = generic_get_irq_affinity; machdep->init_kernel_pgd =NULL ;/* pgd set by symbol_value("swapper_pg_dir") */
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 5/9 RISCV64: Add 'bt' command support
In reply to Xianting Tian1, Add the implementation to get stack frame from active & inactive
task's stack.
2, Add 'bt -l' command support get a line number associated with a
current pc address.
3, Add 'bt -f' command support to display all stack data contained
in a frame
With the patch, we can get the backtrace,
crash> bt
PID: 113 TASK: ff6000000226c200 CPU: 0 COMMAND: "sh"
#0 [ff20000010333b90] riscv_crash_save_regs at ffffffff800078f8 #1 [ff20000010333cf0] panic at ffffffff806578c6
#2 [ff20000010333d50] sysrq_reset_seq_param_set at ffffffff8038c03c #3 [ff20000010333da0] __handle_sysrq at ffffffff8038c604 #4 [ff20000010333e00] write_sysrq_trigger at ffffffff8038cae4 #5 [ff20000010333e20] proc_reg_write at ffffffff801b7ee8 #6 [ff20000010333e40] vfs_write at ffffffff80152bb2
#7 [ff20000010333e80] ksys_write at ffffffff80152eda
#8 [ff20000010333ed0] sys_write at ffffffff80152f52
crash> bt -l
PID: 113 TASK: ff6000000226c200 CPU: 0 COMMAND: "sh"
#0 [ff20000010333b90] riscv_crash_save_regs at ffffffff800078f8
/buildroot/qemu_riscv64_virt_defconfig/build/linux-custom/arch/riscv/kernel/crash_save_regs.S: 47
#1 [ff20000010333cf0] panic at ffffffff806578c6
/buildroot/qemu_riscv64_virt_defconfig/build/linux-custom/kernel/panic.c: 276
... ...
crash> bt -f
PID: 113 TASK: ff6000000226c200 CPU: 0 COMMAND: "sh"
#0 [ff20000010333b90] riscv_crash_save_regs at ffffffff800078f8
[PC: ffffffff800078f8 RA: ffffffff806578c6 SP: ff20000010333b90 SIZE: 352]
ff20000010333b90: ff20000010333bb0 ffffffff800078f8
ff20000010333ba0: ffffffff8008862c ff20000010333b90
ff20000010333bb0: ffffffff810dde38 ff6000000226c200
ff20000010333bc0: ffffffff8032be68 0720072007200720... ...
--- netdump.c | 13 +++ riscv64.c | 283 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+)
netdump.c +13 -0
@@ -42,6 +42,7 @@ static void get_netdump_regs_ppc64(struct bt_info *, ulong *, ulong *);static void get_netdump_regs_arm (struct bt_info *,ulong *,ulong *);static void get_netdump_regs_arm64 (struct bt_info *,ulong *,ulong *);static void get_netdump_regs_mips (struct bt_info *,ulong *,ulong *); +static void get_netdump_regs_riscv (struct bt_info *,ulong *,ulong *);static void check_dumpfile_size (char *);static int proc_kcore_init_32 (FILE *,int );static int proc_kcore_init_64 (FILE *,int );
@@ -2675,6 +2676,10 @@ get_netdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)return get_netdump_regs_mips (bt, eip, esp);break ; +case EM_RISCV : +get_netdump_regs_riscv (bt, eip, esp); +break ; +default : error(FATAL, "support for ELF machine type %d not available\n",
@@ -2931,6 +2936,8 @@ display_regs_from_elf_notes(int cpu, FILE *ofp)mips_display_regs_from_elf_notes (cpu, ofp); }else if (machine_type ("MIPS64" )) {mips64_display_regs_from_elf_notes (cpu, ofp); + }else if (machine_type ("RISCV64" )) { +riscv64_display_regs_from_elf_notes (cpu, ofp); } }
@@ -3877,6 +3884,12 @@ get_netdump_regs_mips(struct bt_info *bt, ulong *eip, ulong *esp) machdep->get_stack_frame (bt, eip, esp); } +static void +get_netdump_regs_riscv (struct bt_info *bt,ulong *eip,ulong *esp) +{ + machdep->get_stack_frame (bt, eip, esp); +} +int is_partial_netdump (void ) {
riscv64.c +283 -0
307 lines not on this page · raw message
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 6/9 RISCV64: Add 'help -r' command support
In reply to Xianting TianAdd support form printing out the registers from the dump file.
With the patch, we can get the regs,
crash> help -r
CPU 0:
epc : 00ffffffa5537400 ra : ffffffff80088620 sp : ff2000001039bb90
gp : ffffffff810dde38 tp : ff60000002269600 t0 : ffffffff8032be5c t1 : 0720072007200720 t2 : 666666666666663c s0 : ff2000001039bcf0 s1 : 0000000000000000 a0 : ff2000001039bb98 a1 : 0000000000000001 a2 : 0000000000000010 a3 : 0000000000000000 a4 : 0000000000000000 a5 : ff60000001c7d000 a6 : 000000000000003c a7 : ffffffff8035c998 s2 : ffffffff810df0a8 s3 : ffffffff810df718 s4 : ff2000001039bb98 s5 : 0000000000000000 s6 : 0000000000000007 s7 : ffffffff80c4a468 s8 : 00fffffffde45410 s9 : 0000000000000007 s10: 00aaaaaad1640700
s11: 0000000000000001 t3 : ff60000001218f00 t4 : ff60000001218f00 t5 : ff60000001218000 t6 : ff2000001039b988
--- riscv64.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
riscv64.c +38 -0
@@ -1320,6 +1320,44 @@ riscv64_init(int when)void riscv64_display_regs_from_elf_notes (int cpu,FILE *ofp) { +const struct machine_specific *ms = machdep->machspec; +struct riscv64_register *regs; + +if (!ms->crash_task_regs) { +error (INFO ,"registers not collected for cpu %d\n" , cpu); +return ; + } + + regs = &ms->crash_task_regs[cpu]; +if (!regs->regs[RISCV64_REGS_SP ] && !regs->regs[RISCV64_REGS_EPC ]) { +error (INFO ,"registers not collected for cpu %d\n" , cpu); +return ; + } + +/* Print riscv64 32 regs */ +fprintf (ofp, +"epc : " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n" +" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n" +" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n" +" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n" +" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n" +" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n" +" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n" +" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n" +" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n" +" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n" +" t5 : " REG_FMT " t6 : " REG_FMT "\n" , + regs->regs[0 ], regs->regs[1 ], regs->regs[2 ], + regs->regs[3 ], regs->regs[4 ], regs->regs[5 ], + regs->regs[6 ], regs->regs[7 ], regs->regs[8 ], + regs->regs[9 ], regs->regs[10 ], regs->regs[11 ], + regs->regs[12 ], regs->regs[13 ], regs->regs[14 ], + regs->regs[15 ], regs->regs[16 ], regs->regs[17 ], + regs->regs[18 ], regs->regs[19 ], regs->regs[20 ], + regs->regs[21 ], regs->regs[22 ], regs->regs[23 ], + regs->regs[24 ], regs->regs[25 ], regs->regs[26 ], + regs->regs[27 ], regs->regs[28 ], regs->regs[29 ], + regs->regs[30 ], regs->regs[31 ]); }#else /* !RISCV64 */
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 7/9 RISCV64: Add 'help -m/M' command support
In reply to Xianting TianAdd riscv64_dump_machdep_table() implementation, display machdep_table.
crash> help -m
flags: 80 ()
kvbase: ff60000000000000
identity_map_base: ff60000000000000
pagesize: 4096
pageshift: 12
pagemask: fffffffffffff000
pageoffset: fff
pgdir_shift: 48
ptrs_per_pgd: 512
ptrs_per_pte: 512
stacksize: 16384
hz: 250
memsize: 1071644672 (0x3fe00000)
bits: 64
back_trace: riscv64_back_trace_cmd()
processor_speed: riscv64_processor_speed()
uvtop: riscv64_uvtop()
kvtop: riscv64_kvtop()
get_stack_frame: riscv64_get_stack_frame()
get_stackbase: generic_get_stackbase()
get_stacktop: generic_get_stacktop()
translate_pte: riscv64_translate_pte()
memory_size: generic_memory_size()
vmalloc_start: riscv64_vmalloc_start()
is_task_addr: riscv64_is_task_addr()
verify_symbol: riscv64_verify_symbol()
dis_filter: generic_dis_filter()
dump_irq: generic_dump_irq()
show_interrupts: generic_show_interrupts()
get_irq_affinity: generic_get_irq_affinity()
cmd_mach: riscv64_cmd_mach()
get_smp_cpus: riscv64_get_smp_cpus()
is_kvaddr: riscv64_is_kvaddr()
is_uvaddr: riscv64_is_uvaddr()
verify_paddr: generic_verify_paddr()
init_kernel_pgd: NULL
value_to_symbol: generic_machdep_value_to_symbol()
line_number_hooks: NULL
last_pgd_read: ffffffff810e9000
last_p4d_read: 81410000
last_pud_read: 81411000
last_pmd_read: 81412000
last_ptbl_read: 81415000
pgd: 560d586f3ab0
p4d: 560d586f4ac0
pud: 560d586f5ad0
pmd: 560d586f6ae0
ptbl: 560d586f7af0
section_size_bits: 27
max_physmem_bits: 56
sections_per_root: 0
machspec: 560d57d204a0--- riscv64.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)
riscv64.c +59 -1
@@ -132,7 +132,65 @@ riscv64_verify_symbol(const char *name, ulong value, char type)void riscv64_dump_machdep_table (ulong arg) { -/* TODO: */ +int others =0 ; + +fprintf (fp," flags: %lx (" , machdep->flags); +if (machdep->flags &KSYMS_START ) +fprintf (fp,"%sKSYMS_START" , others++ ?"|" :"" ); +fprintf (fp,")\n" ); + +fprintf (fp," kvbase: %lx\n" , machdep->kvbase); +fprintf (fp," identity_map_base: %lx\n" , machdep->identity_map_base); +fprintf (fp," pagesize: %d\n" , machdep->pagesize); +fprintf (fp," pageshift: %d\n" , machdep->pageshift); +fprintf (fp," pagemask: %llx\n" , machdep->pagemask); +fprintf (fp," pageoffset: %lx\n" , machdep->pageoffset); +fprintf (fp," pgdir_shift: %ld\n" , machdep->machspec->va_bits -9 ); +fprintf (fp," ptrs_per_pgd: %u\n" ,PTRS_PER_PGD ); +fprintf (fp," ptrs_per_pte: %d\n" ,PTRS_PER_PTE ); +fprintf (fp," stacksize: %ld\n" , machdep->stacksize); +fprintf (fp," hz: %d\n" , machdep->hz); +fprintf (fp," memsize: %ld (0x%lx)\n" , + machdep->memsize, machdep->memsize); +fprintf (fp," bits: %d\n" , machdep->bits); +fprintf (fp," back_trace: riscv64_back_trace_cmd()\n" ); +fprintf (fp," processor_speed: riscv64_processor_speed()\n" ); +fprintf (fp," uvtop: riscv64_uvtop()\n" ); +fprintf (fp," kvtop: riscv64_kvtop()\n" ); +fprintf (fp," get_stack_frame: riscv64_get_stack_frame()\n" ); +fprintf (fp," get_stackbase: generic_get_stackbase()\n" ); +fprintf (fp," get_stacktop: generic_get_stacktop()\n" ); +fprintf (fp," translate_pte: riscv64_translate_pte()\n" ); +fprintf (fp," memory_size: generic_memory_size()\n" ); +fprintf (fp," vmalloc_start: riscv64_vmalloc_start()\n" ); +fprintf (fp," is_task_addr: riscv64_is_task_addr()\n" ); +fprintf (fp," verify_symbol: riscv64_verify_symbol()\n" ); +fprintf (fp," dis_filter: generic_dis_filter()\n" ); +fprintf (fp," dump_irq: generic_dump_irq()\n" ); +fprintf (fp," show_interrupts: generic_show_interrupts()\n" ); +fprintf (fp," get_irq_affinity: generic_get_irq_affinity()\n" ); +fprintf (fp," cmd_mach: riscv64_cmd_mach()\n" ); +fprintf (fp," get_smp_cpus: riscv64_get_smp_cpus()\n" ); +fprintf (fp," is_kvaddr: riscv64_is_kvaddr()\n" ); +fprintf (fp," is_uvaddr: riscv64_is_uvaddr()\n" ); +fprintf (fp," verify_paddr: generic_verify_paddr()\n" ); +fprintf (fp," init_kernel_pgd: NULL\n" ); +fprintf (fp," value_to_symbol: generic_machdep_value_to_symbol()\n" ); +fprintf (fp," line_number_hooks: NULL\n" ); +fprintf (fp," last_pgd_read: %lx\n" , machdep->last_pgd_read); +fprintf (fp," last_p4d_read: %lx\n" , machdep->machspec->last_p4d_read); +fprintf (fp," last_pud_read: %lx\n" , machdep->last_pud_read); +fprintf (fp," last_pmd_read: %lx\n" , machdep->last_pmd_read); +fprintf (fp," last_ptbl_read: %lx\n" , machdep->last_ptbl_read); +fprintf (fp," pgd: %lx\n" , (ulong )machdep->pgd); +fprintf (fp," p4d: %lx\n" , (ulong )machdep->machspec->p4d); +fprintf (fp," pud: %lx\n" , (ulong )machdep->pud); +fprintf (fp," pmd: %lx\n" , (ulong )machdep->pmd); +fprintf (fp," ptbl: %lx\n" , (ulong )machdep->ptbl); +fprintf (fp," section_size_bits: %ld\n" , machdep->section_size_bits); +fprintf (fp," max_physmem_bits: %ld\n" , machdep->max_physmem_bits); +fprintf (fp," sections_per_root: %ld\n" , machdep->sections_per_root); +fprintf (fp," machspec: %lx\n" , (ulong )machdep->machspec); } static ulong
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 8/9 RISCV64: Add 'mach' command support
In reply to Xianting TianWith the patch we can get some basic machine state information, crash> mach
MACHINE TYPE: riscv64
MEMORY SIZE: 1 GB
CPUS: 1
PROCESSOR SPEED: (unknown)
HZ: 250
PAGE SIZE: 4096
KERNEL STACK SIZE: 16384
--- riscv64.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
riscv64.c +44 -1
@@ -116,10 +116,53 @@ static void riscv64_get_struct_page_size(struct machine_specific *ms) } } +/* +* "mach" command output. +*/ +static void +riscv64_display_machine_stats (void ) +{ +struct new_utsname *uts; +char buf[BUFSIZE ]; +ulong mhz; + + uts = &kt->utsname; + +fprintf (fp," MACHINE TYPE: %s\n" , uts->machine); +fprintf (fp," MEMORY SIZE: %s\n" ,get_memory_size (buf)); +fprintf (fp," CPUS: %d\n" ,get_cpus_to_display ()); +fprintf (fp," PROCESSOR SPEED: " ); +if ((mhz = machdep->processor_speed ())) +fprintf (fp,"%ld Mhz\n" , mhz); +else +fprintf (fp,"(unknown)\n" ); +fprintf (fp," HZ: %d\n" , machdep->hz); +fprintf (fp," PAGE SIZE: %d\n" ,PAGESIZE ()); +fprintf (fp," KERNEL STACK SIZE: %ld\n" ,STACKSIZE ()); +} +static void riscv64_cmd_mach (void ) { -/* TODO: */ +int c; + +while ((c =getopt (argcnt, args,"cmo" )) !=EOF ) { +switch (c) { +case 'c' : +case 'm' : +case 'o' : +option_not_supported (c); +break ; +default : + argerrs++; +break ; + } + } + +if (argerrs) +cmd_usage (pc->curcmd,SYNOPSIS ); + +riscv64_display_machine_stats (); } static int
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 9/9 RISCV64: Add the implementation of symbol verify
In reply to Xianting TianVerify the symbol to accept or reject a symbol from the kernel namelist.
--- riscv64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
riscv64.c +14 -1
@@ -165,10 +165,23 @@ riscv64_cmd_mach(void)riscv64_display_machine_stats (); } +/* +* Accept or reject a symbol from the kernel namelist. +*/ static int riscv64_verify_symbol (const char *name,ulong value,char type) { -/* TODO: */ +if (CRASHDEBUG (8 ) && name &&strlen (name)) +fprintf (fp,"%08lx %s\n" , value, name); + +if (!(machdep->flags &KSYMS_START )) { +if (STREQ (name,"_text" ) ||STREQ (name,"_stext" )) + machdep->flags |=KSYMS_START ; + +return (name &&strlen (name) && !STRNEQ (name,"__func__." ) && + !STRNEQ (name,"__crc_" )); + } +return TRUE; }
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec