Skip to contentSkip to conversation

RISC-V: Add support for riscv kexec/kdump on kexec-tools

PATCH In review Xianting Tian 5 participants 11 messages Oct 21, 2022 – Jul 19, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 RISC-V: Add support for riscv kexec/kdump on kexec-tools

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,

      lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;

2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

---
Changes
V1 -> V2:
1, Rebase the patch to latest kexec code.
2, Set patch author Nick Kossifidis.

 configure.ac                            |   3 +
 include/elf.h                           |   1 +
 kexec/Makefile                          |   1 +
 kexec/arch/riscv/Makefile               |  35 ++
 kexec/arch/riscv/crashdump-riscv.c      | 140 ++++++++
 kexec/arch/riscv/include/arch/options.h |  43 +++
 kexec/arch/riscv/kexec-elf-riscv.c      | 255 ++++++++++++++
 kexec/arch/riscv/kexec-riscv.c          | 365 +++++++++++++++++++
 kexec/arch/riscv/kexec-riscv.h          |  32 ++
 kexec/dt-ops.c                          | 442 +++++++++++++++++++++++-
 kexec/dt-ops.h                          |   7 +
 kexec/kexec-syscall.h                   |   4 +
 purgatory/Makefile                      |   1 +
 purgatory/arch/riscv/Makefile           |   7 +
 14 files changed, 1335 insertions(+), 1 deletion(-)
 create mode 100644 kexec/arch/riscv/Makefile
 create mode 100644 kexec/arch/riscv/crashdump-riscv.c
 create mode 100644 kexec/arch/riscv/include/arch/options.h
 create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.h
 create mode 100644 purgatory/arch/riscv/Makefile
configure.ac +3 -0
index d081c82..9204c37 100644
@@ -61,6 +61,9 @@ case $target_cpu in
 	loongarch*)
 		ARCH="loongarch"
 		;;
+	riscv32|riscv64)
+		ARCH="riscv"
+		;;
 	* )
 		AC_MSG_ERROR([unsupported architecture $target_cpu])
 		;;
include/elf.h +1 -0
index 1c8d2cc..93a5ee5 100644
@@ -259,6 +259,7 @@ typedef struct
 #define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
 #define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
 #define EM_AARCH64	183		/* ARM AARCH64 */
+#define EM_RISCV	243		/* RISC-V */
 #define EM_LOONGARCH	258		/* Loongson Loongarch*/
 #define EM_NUM		184
 
kexec/Makefile +1 -0
index 8a52e8d..405864a 100644
@@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
 include $(srcdir)/kexec/arch/cris/Makefile
 include $(srcdir)/kexec/arch/ppc/Makefile
 include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/riscv/Makefile
 include $(srcdir)/kexec/arch/s390/Makefile
 include $(srcdir)/kexec/arch/sh/Makefile
 include $(srcdir)/kexec/arch/x86_64/Makefile
kexec/arch/riscv/Makefile new file +35 -0
new file mode 100644
index 0000000..f26cc90
@@ -0,0 +1,35 @@
+#
+# kexec riscv
+#
+riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
+
+riscv_MEM_REGIONS = kexec/mem_regions.c
+
+riscv_DT_OPS += kexec/dt-ops.c
+
+riscv_ARCH_REUSE_INITRD =
+
+riscv_CPPFLAGS += -I $(srcdir)/kexec/
+
+dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)			\
+	kexec/arch/riscv/kexec-riscv.h					\
+	kexec/arch/riscv/include/arch/options.h
+
+ifdef HAVE_LIBFDT
+
+LIBS += -lfdt
+
+else
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+
+riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+
+riscv_KEXEC_SRCS += $(libfdt_SRCS)
+
+endif
+
kexec/arch/riscv/crashdump-riscv.c new file +140 -0

140 lines not on this page · raw message

kexec/arch/riscv/include/arch/options.h new file +43 -0

43 lines not on this page · raw message

kexec/arch/riscv/kexec-elf-riscv.c new file +255 -0

255 lines not on this page · raw message

kexec/arch/riscv/kexec-riscv.c new file +365 -0

365 lines not on this page · raw message

kexec/arch/riscv/kexec-riscv.h new file +32 -0
new file mode 100644
index 0000000..c4323a6
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 FORTH-ICS/CARV
+ *              Nick Kossifidis <[email protected]>
+ */
+
+struct fdt_image {
+	char	*buf;
+	off_t	size;
+};
+
+struct riscv_opts {
+	char *cmdline;
+	char *fdt_path;
+	char *initrd_path;
+	uint64_t initrd_start;
+	uint64_t initrd_end;
+	struct fdt_image *fdt;
+};
+
+/* crashdump-riscv.c */
+extern struct memory_range elfcorehdr_mem;
+int load_elfcorehdr(struct kexec_info *info);
+
+/* kexec-riscv.c */
+int load_extra_segments(struct kexec_info *info, uint64_t kernel_base,
+			uint64_t kernel_size, uint64_t max_addr);
+
+int elf_riscv_probe(const char *buf, off_t len);
+void elf_riscv_usage(void);
+int elf_riscv_load(int argc, char **argv, const char *buf, off_t len,
+		   struct kexec_info *info);
kexec/dt-ops.c +441 -1

460 lines not on this page · raw message

kexec/dt-ops.h +7 -0
index 03659ce..3014205 100644
@@ -11,4 +11,11 @@ int dtb_set_property(char **dtb, off_t *dtb_size, const char *node,
 
 int dtb_delete_property(char *dtb, const char *node, const char *prop);
 
+void dtb_extract_int_property(uint64_t *val, const void *buf, uint32_t cells);
+void dtb_fill_int_property(void *buf, uint64_t val, uint32_t cells);
+int dtb_add_range_property(char **dtb, off_t *dtb_size, uint64_t start, uint64_t end,
+                           const char *node, const char* parent);
+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges,
+			  struct memory_ranges *extra_ranges);
+
 #endif
kexec/kexec-syscall.h +4 -0
index be6ccd5..4cdae84 100644
@@ -137,6 +137,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd,
 #define KEXEC_ARCH_MIPS_LE (10 << 16)
 #define KEXEC_ARCH_MIPS    ( 8 << 16)
 #define KEXEC_ARCH_CRIS    (76 << 16)
+#define KEXEC_ARCH_RISCV   (243 << 16)
 #define KEXEC_ARCH_LOONGARCH	(258 << 16)
 
 #define KEXEC_MAX_SEGMENTS 16
@@ -184,5 +185,8 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd,
 #if defined(__loongarch__)
 #define KEXEC_ARCH_NATIVE	KEXEC_ARCH_LOONGARCH
 #endif
+#if defined(__riscv__) || defined(__riscv)
+#define KEXEC_ARCH_NATIVE	KEXEC_ARCH_RISCV
+#endif
 
 #endif /* KEXEC_SYSCALL_H */
purgatory/Makefile +1 -0
index 4d2d071..7d1175f 100644
@@ -25,6 +25,7 @@ include $(srcdir)/purgatory/arch/ia64/Makefile
 include $(srcdir)/purgatory/arch/mips/Makefile
 include $(srcdir)/purgatory/arch/ppc/Makefile
 include $(srcdir)/purgatory/arch/ppc64/Makefile
+include $(srcdir)/purgatory/arch/riscv/Makefile
 include $(srcdir)/purgatory/arch/s390/Makefile
 include $(srcdir)/purgatory/arch/sh/Makefile
 include $(srcdir)/purgatory/arch/x86_64/Makefile
purgatory/arch/riscv/Makefile new file +7 -0
new file mode 100644
index 0000000..8bded71
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)
Signature · 7 lines
2.17.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 6 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

Quoted 8 lines

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,

      lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;

2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 5 lines

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 355

Quoted 2 lines
kexec/dt-ops.c +2 -0
+	ret = mem_regions_alloc_and_add(mem_ranges, start,
+					end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

...

Quoted 2 lines
kexec/dt-ops.c +2 -0
+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges)
+{

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 613

Quoted 1 line
kexec/dt-ops.c +1 -0
+	mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

purgatory/arch/riscv/Makefile line 7

Quoted 13 lines
purgatory/arch/riscv/Makefile new file +7 -0
new file mode 100644
index 0000000..8bded71
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

Hi Simon

thanks for the comments

Quoted 28 lines · Simon Horman
Quoted 6 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

Quoted 8 lines

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,
lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 355

Quoted 2 lines
kexec/dt-ops.c +2 -0
+	ret = mem_regions_alloc_and_add(mem_ranges, start,
+					end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges, kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 28 lines

...

Quoted 2 lines
kexec/dt-ops.c +2 -0
+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges)
+{

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 613

Quoted 1 line
kexec/dt-ops.c +1 -0
+	mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

purgatory/arch/riscv/Makefile line 7

Quoted 13 lines
purgatory/arch/riscv/Makefile new file +7 -0
new file mode 100644
index 0000000..8bded71
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Quoted 4 lines

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 82 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 28 lines · Simon Horman
Quoted 6 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

Quoted 8 lines

This patch was firstly developed by Nick Kossifidis, and two fixes ( 1: fail to find free memory area for dtb load when using initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html; 2: fix memory range size calculation, kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

Quoted 2 lines

+    ret = mem_regions_alloc_and_add(mem_ranges, start, +                    end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges, kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 29 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+    mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

purgatory/arch/riscv/Makefile line 7

Quoted 13 lines
purgatory/arch/riscv/Makefile new file +7 -0
new file mode 100644
index 0000000..8bded71
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Quoted 5 lines
Quoted 4 lines

Else the distribution tarball won't include this Makefile

You can exercise this using:
   make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

Hi Xianting,

Quoted 92 lines · Xianting Tian
Quoted 90 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 30 lines · Simon Horman
Quoted 14 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes ( 1: fail to find free memory area for dtb load when using initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html; 2: fix memory range size calculation, kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Quoted 2 lines

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

Quoted 2 lines

+    ret = mem_regions_alloc_and_add(mem_ranges, start, +                    end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 32 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+    mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +0 -0
new file mode 100644
index 0000000..8bded71

purgatory/arch/riscv/Makefile line 7

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

You can exercise this using:
   make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this patchset and post after polishing.

Thanks
Baoquan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw

F.Y.I

[email protected]

Quoted 113 lines · Baoquan He

Hi Xianting,

Quoted 92 lines · Xianting Tian
Quoted 90 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 30 lines · Simon Horman
Quoted 14 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using
initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Quoted 2 lines

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 355

Quoted 2 lines
kexec/dt-ops.c +2 -0
+    ret = mem_regions_alloc_and_add(mem_ranges, start,
+                    end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 32 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+ mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +0 -0
new file mode 100644
index 0000000..8bded71

purgatory/arch/riscv/Makefile line 7

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this patchset and post after polishing.

Thanks
Baoquan

Signature · 7 lines
Best Regards
 Guo Ren

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#6 lore raw
Quoted 114 lines · On Mon, 27 Mar 2023 16:27:56 +0800 Guo Ren <[email protected]> wrote:

F.Y.I

[email protected]

Quoted 109 lines · Baoquan He

Hi Xianting,

Quoted 92 lines · Xianting Tian
Quoted 90 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 30 lines · Simon Horman
Quoted 14 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using
initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Quoted 2 lines

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 355

Quoted 2 lines
kexec/dt-ops.c +2 -0
+    ret = mem_regions_alloc_and_add(mem_ranges, start,
+                    end - start, type);  

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 32 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+ mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +0 -0
new file mode 100644
index 0000000..8bded71

purgatory/arch/riscv/Makefile line 7

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)  

s/sh/riscv/

Else the distribution tarball won't include this Makefile

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this patchset and post after polishing.

Now it seems I am interested. FYI my plan is to start working on this if there is no further reaction from anybody else within a fortnight.

Petr T

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
Quoted 105 lines · Petr Tesařík
Quoted 102 lines · On Mon, 27 Mar 2023 16:27:56 +0800 Guo Ren <[email protected]> wrote:

F.Y.I

[email protected]

Quoted 97 lines · Baoquan He

Hi Xianting,

Quoted 94 lines · Xianting Tian
Quoted 86 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 30 lines · Simon Horman
Quoted 14 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using
initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Quoted 2 lines

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+    ret = mem_regions_alloc_and_add(mem_ranges, start,
+                    end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 29 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+ mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +0 -0
new file mode 100644
index 0000000..8bded71

purgatory/arch/riscv/Makefile line 7

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Quoted 5 lines
Quoted 4 lines

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this patchset and post after polishing.

Now it seems I am interested. FYI my plan is to start working on this if there is no further reaction from anybody else within a fortnight.

Good, please feel free to do it.

Quoted 2 lines

Petr T

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw
Quoted 107 lines · On Tue, 18 Jul 2023 17:40:17 +0800 Xianting Tian…
Quoted 106 lines · Petr Tesařík
Quoted 103 lines · On Mon, 27 Mar 2023 16:27:56 +0800 Guo Ren <[email protected]> wrote:

F.Y.I

[email protected]

Quoted 98 lines · Baoquan He

Hi Xianting,

Quoted 95 lines · Xianting Tian
Quoted 86 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 30 lines · Simon Horman
Quoted 14 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using
initrd image, lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Quoted 2 lines

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines
Quoted 8 lines

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+    ret = mem_regions_alloc_and_add(mem_ranges, start,
+                    end - start, type);  

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 29 lines

...

Quoted 3 lines

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) +{

...

Quoted 1 line

+ mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +0 -0
new file mode 100644
index 0000000..8bded71

purgatory/arch/riscv/Makefile line 7

Quoted 7 lines
purgatory/arch/riscv/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)  

s/sh/riscv/

Quoted 5 lines
Quoted 4 lines

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

Is this patchset reposting still in your working plan? I don't see the code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this patchset and post after polishing.

Now it seems I am interested. FYI my plan is to start working on this if there is no further reaction from anybody else within a fortnight.

Good, please feel free to do it.

Oh, thank you for your quick answer!

Good. Cloned from Gitee, rebasing, testing...

Petr T

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw
In reply to Xianting Tian
Quoted 40 lines · Xianting Tian

Hi Simon

thanks for the comments

Quoted 35 lines · Simon Horman
Quoted 6 lines · Xianting Tian

From: Nick Kossifidis <[email protected]>

This patch adds support for loading the ELF kernel image. It parses the current/provided device tree to determine the system's memory layout, and /proc/iomem for the various kernel segments.

Quoted 8 lines

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,
lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github workflow. If you could include that in V3 I'd be most grateful.

Quoted 4 lines

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 355

Quoted 2 lines
kexec/dt-ops.c +2 -0
+	ret = mem_regions_alloc_and_add(mem_ranges, start,
+					end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Quoted 6 lines
Quoted 1 line

Ref: https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common funtions,

The build error of mips is caused by this riscv patch?

Yes, I think so.

The workflow passes on main: https://github.com/horms/kexec-tools/actions/runs/3344523519
But not with the riscv patch applied: https://github.com/horms/kexec-tools/tree/build-test-riscv-v2

Quoted 37 lines

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges) kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);

kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges *ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges *ranges,

Quoted 28 lines

...

Quoted 2 lines
kexec/dt-ops.c +2 -0
+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges)
+{

...

kexec/dt-ops.c int dtb_delete_property(char *dtb, const char *node, const char *prop) · line 613

Quoted 1 line
kexec/dt-ops.c +1 -0
+	mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available. f.e. on mips this causes a build failure.

...

purgatory/arch/riscv/Makefile line 7

Quoted 13 lines
purgatory/arch/riscv/Makefile new file +7 -0
new file mode 100644
index 0000000..8bded71
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Quoted 5 lines
Quoted 4 lines

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

Thanks.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

PATCH 1/1 github: add RISC-V to workflow

In reply to Xianting Tian

Add RISC-V builds to workflow

---
 .github/workflows/build.yml | 3 +++
 1 file changed, 3 insertions(+)

Hi Xianting Tian,

Please consider including this a v3 patch-set
to add RISC-V to kexec-tools.

.github/workflows/build.yml +3 -0
index e554751e0017..2731282d9521 100644
@@ -19,6 +19,8 @@ jobs:
         - powerpc
         - powerpc64
         - powerpc64le
+        - riscv32
+        - riscv64
         - sh4
         - s390x
         - x86_64-x32
@@ -42,6 +44,7 @@ jobs:
         case $ARCH in
           arm)         GNU_ARCH="arm-linux-gnueabi" ;;
           arm64)       GNU_ARCH="aarch64-linux-gnu" ;;
+          riscv32)     CROSS_COMPILER_PKG="gcc-riscv64-linux-gnu" ;;
           x86_64)      ;;
           x86_64-x32)  GNU_ARCH="x86_64-linux-gnux32"
                        CROSS_COMPILER_PKG="gcc-x86-64-linux-gnux32" ;;
Signature · 7 lines
2.30.2


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec