[gentoo-commits] proj/riscv:master commit in: sys-apps/kexec-tools/files/

2022-08-21 Thread Yixun Lan
commit: 9bd3aaeeaf5a9d6f1bfb851e535c802ada2f7c83
Author: Yixun Lan  gentoo  org>
AuthorDate: Sun Aug 21 23:44:04 2022 +
Commit: Yixun Lan  gentoo  org>
CommitDate: Sun Aug 21 23:45:00 2022 +
URL:https://gitweb.gentoo.org/proj/riscv.git/commit/?id=9bd3aaee

sys-apps/kexec-tools: fix memory location issue

the initrd should be put at low address
http://lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html

Signed-off-by: Yixun Lan  gentoo.org>

 sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch 
b/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch
index 1fab497..66f4bf8 100644
--- a/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch
+++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch
@@ -699,7 +699,7 @@ index 000..d05c47d
 + initrd_base + initrd_size);
 +
 +  dbgprintf("Base addr for initrd image: 0x%lX\n", initrd_base);
-+  min_usable = initrd_base;
++  max_usable = initrd_base;
 +  }
 +
 +  /* Add device tree */



[gentoo-commits] proj/riscv:master commit in: sys-apps/kexec-tools/, sys-apps/kexec-tools/files/

2022-07-02 Thread Yixun Lan
commit: 31108ac2c9aa23918f46ff3f56e3084d0bb725f2
Author: Yixun Lan  gentoo  org>
AuthorDate: Sat Jul  2 09:35:25 2022 +
Commit: Yixun Lan  gentoo  org>
CommitDate: Sat Jul  2 09:36:03 2022 +
URL:https://gitweb.gentoo.org/proj/riscv.git/commit/?id=31108ac2

sys-apps/kexec-tools: add riscv support

Signed-off-by: Yixun Lan  gentoo.org>

 .../files/kexec-tools-2.0.24-riscv.patch   | 1513 
 sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild |9 +-
 2 files changed, 1516 insertions(+), 6 deletions(-)

diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch 
b/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch
new file mode 100644
index 000..1fab497
--- /dev/null
+++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch
@@ -0,0 +1,1513 @@
+From 6975082921e577ed5034e56010d2b433aeaf6907 Mon Sep 17 00:00:00 2001
+From: Nick Kossifidis 
+Date: Tue, 5 Oct 2021 15:01:19 +0300
+Subject: [PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools
+
+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.
+
+Tested on Qemu's rv64 virt machine.
+
+Signed-off-by: Nick Kossifidis 
+---
+ configure.ac|   3 +
+ include/elf.h   |   3 +-
+ 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  | 364 +++
+ 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(+), 2 deletions(-)
+ 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
+
+diff --git a/configure.ac b/configure.ac
+index cf8e8a2..d21552c 100644
+--- a/configure.ac
 b/configure.ac
+@@ -58,6 +58,9 @@ case $target_cpu in
+   hppa*)
+   ARCH="hppa"
+   ;;
++  riscv32|riscv64 )
++  ARCH="riscv"
++  ;;
+   * )
+   AC_MSG_ERROR([unsupported architecture $target_cpu])
+   ;;
+diff --git a/include/elf.h b/include/elf.h
+index b7677a2..123f167 100644
+--- a/include/elf.h
 b/include/elf.h
+@@ -259,7 +259,8 @@ typedef struct
+ #define EM_ARC_A5 93  /* ARC Cores Tangent-A5 */
+ #define EM_XTENSA 94  /* Tensilica Xtensa Architecture */
+ #define EM_AARCH64183 /* ARM AARCH64 */
+-#define EM_NUM184
++#define EM_RISCV  243 /* RISC-V */
++#define EM_NUM244
+ 
+ /* If it is necessary to assign new unofficial EM_* values, please
+pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
+diff --git a/kexec/Makefile b/kexec/Makefile
+index e69e309..ca17831 100644
+--- a/kexec/Makefile
 b/kexec/Makefile
+@@ -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
+diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
+new file mode 100644
+index 000..f26cc90
+--- /dev/null
 b/kexec/arch/riscv/Makefile
+@@ -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)
++

[gentoo-commits] proj/riscv:master commit in: sys-apps/kexec-tools/, sys-apps/kexec-tools/files/

2022-07-02 Thread Yixun Lan
commit: dd7015229da7ba9823e0d446231d6bd4c819c396
Author: Yixun Lan  gentoo  org>
AuthorDate: Sat Jul  2 09:34:07 2022 +
Commit: Yixun Lan  gentoo  org>
CommitDate: Sat Jul  2 09:34:20 2022 +
URL:https://gitweb.gentoo.org/proj/riscv.git/commit/?id=dd701522

sys-apps/kexec-tools: import original 2.0.24 from official tree

Signed-off-by: Yixun Lan  gentoo.org>

 sys-apps/kexec-tools/Manifest  |   1 +
 sys-apps/kexec-tools/files/90_kexec|   9 +
 sys-apps/kexec-tools/files/README.Gentoo   |  33 
 sys-apps/kexec-tools/files/kexec-r2.init   | 200 +
 .../kexec-tools-2.0.4-disable-kexec-test.patch |  17 ++
 .../files/kexec-tools-2.0.4-out-of-source.patch|  24 +++
 sys-apps/kexec-tools/files/kexec.conf  |  16 ++
 sys-apps/kexec-tools/files/kexec.conf-2.0.4|  34 
 sys-apps/kexec-tools/files/kexec.service   |  16 ++
 sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild | 124 +
 sys-apps/kexec-tools/metadata.xml  |  13 ++
 11 files changed, 487 insertions(+)

diff --git a/sys-apps/kexec-tools/Manifest b/sys-apps/kexec-tools/Manifest
new file mode 100644
index 000..d6b3aa3
--- /dev/null
+++ b/sys-apps/kexec-tools/Manifest
@@ -0,0 +1 @@
+DIST kexec-tools-2.0.24.tar.xz 303808 BLAKE2B 
8188602f1b843c1dccc0307131f8c9ec0426c6cb3de898040352c1fed5f6d4bd7c58a0c2bf54290b91c8fe3401180df682959ee6c41693d07acc199c087c7db2
 SHA512 
ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822

diff --git a/sys-apps/kexec-tools/files/90_kexec 
b/sys-apps/kexec-tools/files/90_kexec
new file mode 100644
index 000..40bad42
--- /dev/null
+++ b/sys-apps/kexec-tools/files/90_kexec
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+version="$1" ; shift
+image="$1" ; shift
+
+exec sed \
+   -e "s:\"vmlinuz-.*\":\"vmlinuz-${version}\":" \
+   -e "s:/boot/initramfs-.*\.img:/boot/initramfs-${version}\.img:" \
+   -i /etc/kexec.conf

diff --git a/sys-apps/kexec-tools/files/README.Gentoo 
b/sys-apps/kexec-tools/files/README.Gentoo
new file mode 100644
index 000..7735e32
--- /dev/null
+++ b/sys-apps/kexec-tools/files/README.Gentoo
@@ -0,0 +1,33 @@
+Usage
+=
+
+Do
+ $ man 8 kexec
+for full understanding of the underlying kexec command.
+Gentoo offers a wrapper to the bare kexec command through
+/etc/init.d/kexec.
+
+Configuration
+-
+
+Configuration is done in /etc/conf.d/kexec, which is self-documented.
+
+Usage
+-
+
+In Gentoo, kexec is invoked, i.e., the new kernel will be booted when
+rebooting, by reboot (8) command or by pressing Ctrl+Alt+Del.
+
+If you want to use kexec once, just run
+ $ /etc/init.d/kexec start
+
+It'll reserve kexec call at reboot. Later on, you can reboot anytime,
+letting kexec starts another (or the same) kernel. When all is done in
+the runlevel 6 - killing processes, unmounting volumes, etc - kexec
+starts the new kernel instead of doing the normal hardware reboot.
+
+If you want kexec to be run every time you reboot, add it to a runlevel:
+ $ rc-update add kexec 
+
+If you want to reboot in the normal way this time, do:
+ $ touch /nokexec

diff --git a/sys-apps/kexec-tools/files/kexec-r2.init 
b/sys-apps/kexec-tools/files/kexec-r2.init
new file mode 100644
index 000..0578f51
--- /dev/null
+++ b/sys-apps/kexec-tools/files/kexec-r2.init
@@ -0,0 +1,200 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Set up some defaults.
+: "${LOAD_DURING_SHUTDOWN:=yes}"
+: "${BOOTPART:=/boot}"
+: "${DONT_MOUNT_BOOT:=no}"
+
+depend() {
+   need localmount
+}
+
+auto_prefix_bootpath() {
+   # Only auto-add prefix to relative paths.
+   case $1 in
+   */*) echo "$1";;
+   *)   echo "${BOOTPART}/$1" ;;
+   esac
+}
+
+get_genkernel_arch() {
+   case $1 in
+   x86_64) echo "amd64" ;;
+   i[3456]86) echo "x86" ;;
+   *) echo "$1" ;;
+   esac
+}
+
+image_path() {
+   # Do no sanity checking if the user has set a value.
+   if [ -n "${KNAME}" ]; then
+   auto_prefix_bootpath "${KNAME}"
+   return
+   fi
+
+   local x kver="$(uname -r)" karch="$(uname -m)"
+   local gkarch="$(get_genkernel_arch $karch)"
+   for x in \
+   "bzImage" \
+   "vmlinux" \
+   "vmlinuz" \
+   "kernel" \
+   "bzImage-${kver}" \
+   "vmlinux-${kver}" \
+   "vmlinuz-${kver}" \
+   "kernel-genkernel-${karch}-${kver}" \
+   "kernel-genkernel-${gkarch}-${kver}" \
+   "kernel-${kver}" \
+   "kernel-${karch}"; do
+   if [ -e "${BOOTPART}/${x}" ]; then
+   echo "${BOOTPART}/${x}"
+   return
+   fi
+   done
+

[gentoo-commits] proj/riscv:master commit in: sys-apps/kexec-tools/

2022-07-02 Thread Yixun Lan
commit: f3278d7aa754f3e32444e815e62db6b047ab3af8
Author: Yixun Lan  gentoo  org>
AuthorDate: Sat Jul  2 11:43:50 2022 +
Commit: Yixun Lan  gentoo  org>
CommitDate: Sat Jul  2 11:44:04 2022 +
URL:https://gitweb.gentoo.org/proj/riscv.git/commit/?id=f3278d7a

sys-apps/kexec-tools: keyword 2.0.24 for ~riscv

Signed-off-by: Yixun Lan  gentoo.org>

 sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild 
b/sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild
index 7251c1b..264a5b8 100644
--- a/sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild
+++ b/sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild
@@ -11,7 +11,7 @@ if [[ ${PV} == "" ]] ; then
 else

SRC_URI="https://www.kernel.org/pub/linux/utils/kernel/kexec/${P/_/-}.tar.xz;
[[ "${PV}" == *_rc* ]] || \
-   KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
+   KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
 fi
 
 DESCRIPTION="Load another kernel from the currently executing Linux kernel"