[PATCH V3 0/9] Support RISCV64 arch and common commands
Xianting Tian
xianting.tian at linux.alibaba.com
Wed Aug 24 01:57:51 PDT 2022
在 2022/8/22 下午3:28, Yixun Lan 写道:
> Hi lijiang
>
> On Mon, Aug 22, 2022 at 3:56 AM lijiang <lijiang at redhat.com> wrote:
>> Hi, Xianting
>> Thank you for the update.
>> On Sat, Aug 13, 2022 at 11:18 AM Xianting Tian <xianting.tian at linux.alibaba.com> wrote:
>>> 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/linux-riscv/20220811074150.3020189-1-xianting.tian@linux.alibaba.com/
>>> [ Patch 1 ~ 4 already merged to Linux for-next branch, targeted for 5.20;
>>> Patch 5, 6 already merged to Palmer's riscv-crash branch:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/log/?h=riscv-crash ]
>>>
>> Can you also help to share the patch link for kexec-tools? Or share your loading steps and generate a vmcore in riscv64 system?
>>
>> I tried it with kexec-tools and got the following error:
>>
>> [root at fedora-riscv kexec-tools]# ./configure
>> checking for gcc... gcc
>> checking whether the C compiler works... yes
>> checking for C compiler default output file name... a.out
>> checking for suffix of executables...
>> checking whether we are cross compiling... no
>> checking for suffix of object files... o
>> checking whether we are using the GNU C compiler... yes
>> checking whether gcc accepts -g... yes
>> checking for gcc option to accept ISO C89... none needed
>> checking build system type... riscv64-unknown-linux-gnu
>> checking host system type... riscv64-unknown-linux-gnu
>> checking target system type... riscv64-unknown-linux-gnu
>> configure: error: unsupported architecture riscv64
>>
>> Thanks.
>> Lianbo
>>
>>> 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_map
>>> mem_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 PHYSICAL
>>> ffffffff0113e740 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 FLAGS
>>> ff6000003f0777d8 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.
>>>
>>>
>>> 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 | 252 +++++++-
>>> 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 | 1491 +++++++++++++++++++++++++++++++++++++++++++
>>> symbols.c | 10 +
>>> 12 files changed, 1848 insertions(+), 22 deletions(-)
>>> create mode 100644 riscv64.c
>>>
>>> --
>>> 2.17.1
>>>
> FYI, take a look at
> lists.infradead.org/pipermail/linux-riscv/2021-October/008773.html
>
> also need this extra fix
> lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html
>
> and just follow normal scheme to use kexec + crash, there is nothing different
Hi Li Jiang
I just saw this reply from Yixun,
there is some bug for kexec when use initrd, I used a temporary solution
to fix the issue. And recently, Yixun fixed the issue, it is a better
fix, you can use it to test on QEMU.
Fot the test on Xuantie 910 RISC-V SoC platform, I didn't use initrd,
the kexec command I used as below:
cmdline=$(cat /proc/cmdline)
kexec -p vmlinux --append="$cmdline"
And with the additional patches:
diff --git a/kexec/arch/riscv/crashdump-riscv.c
b/kexec/arch/riscv/crashdump-riscv.c
index 4f3ecd6..be73e34 100644
--- a/kexec/arch/riscv/crashdump-riscv.c
+++ b/kexec/arch/riscv/crashdump-riscv.c
@@ -84,7 +84,7 @@ int load_elfcorehdr(struct kexec_info *info)
for (i = 0; i < info->memory_ranges; i++) {
ret = mem_regions_alloc_and_add(&crash_mem_ranges,
ranges[i].start,
- ranges[i].end -
ranges[i].start,
+ ranges[i].end -
ranges[i].start + 1,
ranges[i].type);
if (ret ) {
fprintf(stderr, "Could not create
crash_mem_ranges\n");
diff --git a/kexec/arch/riscv/kexec-riscv.c b/kexec/arch/riscv/kexec-riscv.c
index c7bbe5f..1a047de 100644
--- a/kexec/arch/riscv/kexec-riscv.c
+++ b/kexec/arch/riscv/kexec-riscv.c
@@ -455,10 +455,13 @@ static int add_memory_region(struct memory_ranges
*mem_ranges,
entry_size = (addr_cells + size_cells) * sizeof(uint32_t);
reg = fdt_getprop(fdt->buf, node_offset, "reg", &prop_size);
if (!reg) {
- fprintf(stderr, "Warning: Malformed memory region with no "
- "reg property (%s) !\n",
- fdt_get_name(fdt->buf, node_offset, NULL));
- return -EINVAL;
+ reg = fdt_getprop(fdt->buf, node_offset, "alloc-ranges",
&prop_size);
+ if (!reg) {
+ fprintf(stderr, "Warning: Malformed memory
region with no "
+ "reg property (%s) !\n",
+ fdt_get_name(fdt->buf,
node_offset, NULL));
+ return -EINVAL;
+ }
}
num_entries = prop_size / entry_size;
diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index ad7d3f1..f650bcd 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -126,7 +126,7 @@ int mem_regions_exclude(struct memory_ranges *ranges,
return 0;
}
-#define KEXEC_MEMORY_RANGES 16
+#define KEXEC_MEMORY_RANGES 32
>
> Yixun
More information about the kexec
mailing list