On Wed, Aug 24, 2022 at 4:58 PM Xianting Tian <xianting.tian@linux.alibaba.com> wrote:
Hi Li Jiang

I just saw this reply from Yixun,


Thank you for sharing the information, Xianting and Yixun. I will try it later.
If I run into any issues, I will let you know.

Thanks.
Lianbo
 
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