From f06dfbcdbe80f26f09ba4268be8cc909a4a88497 Mon Sep 17 00:00:00 2001 From: laokz Date: Wed, 12 Mar 2025 11:23:00 +0800 Subject: [PATCH] add riscv64 patch (cherry picked from commit bc759962c4a60801faa9dd696205059c0dbf6ecc) --- add-riscv64-support.patch | 66 +++++++++++++++++++++++++++++++++++++++ sysmonitor-kmod.spec | 9 +++++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 add-riscv64-support.patch diff --git a/add-riscv64-support.patch b/add-riscv64-support.patch new file mode 100644 index 0000000..b957909 --- /dev/null +++ b/add-riscv64-support.patch @@ -0,0 +1,66 @@ +From 756f6595b562a3fff5de9ab8dd38865f20aa022c Mon Sep 17 00:00:00 2001 +From: laokz +Date: Thu, 25 Apr 2024 22:21:28 +0800 +Subject: [PATCH] add riscv64 support + +Signal info referenced: +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/kernel/signal.c#L373 + +Max CPUs referenced: +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/Kconfig#L411 + +Local disk suport PCI and VIRTIO both. +--- + sysmonitor-1.3.2/module/signo_catch.c | 8 ++++++++ + sysmonitor-1.3.2/script/get_local_disk.sh | 2 ++ + sysmonitor-1.3.2/src/sys_resources.c | 2 ++ + 3 files changed, 12 insertions(+) + +diff --git a/sysmonitor-1.3.2/module/signo_catch.c b/sysmonitor-1.3.2/module/signo_catch.c +index c038e161ff19..043a14838f98 100644 +--- a/module/signo_catch.c ++++ b/module/signo_catch.c +@@ -272,6 +272,14 @@ static int pre_handler(struct kprobe *p, struct pt_regs *regs) + data.p = (struct task_struct *)((unsigned long *)regs->dx); + do_store_sig_info(&data); + #endif ++ ++#if defined(CONFIG_RISCV) && defined(CONFIG_64BIT) ++ send_sig_info_data_t data; ++ data.sig = regs->a0; ++ data.info = (struct kernel_siginfo *)((unsigned long *)regs->a1); ++ data.p = (struct task_struct *)((unsigned long *)regs->a2); ++ do_store_sig_info(&data); ++#endif + return 0; + } + +diff --git a/sysmonitor-1.3.2/script/get_local_disk.sh b/sysmonitor-1.3.2/script/get_local_disk.sh +index 318374cbffdd..063e540cebd4 100755 +--- a/script/get_local_disk.sh ++++ b/script/get_local_disk.sh +@@ -9,6 +9,8 @@ fc_disk_file="" + local_disk_file="" + if uname -a | grep -q aarch64; then + fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|HISI0162' 2> /dev/null` ++elif uname -a | grep -q riscv64; then ++ fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|virtio' 2> /dev/null` + else + fc_local_disk=`ls -l /sys/block/ | grep pci 2> /dev/null` + fi +diff --git a/sysmonitor-1.3.2/src/sys_resources.c b/sysmonitor-1.3.2/src/sys_resources.c +index fdf52561e07d..87f2fdd73b10 100644 +--- a/src/sys_resources.c ++++ b/src/sys_resources.c +@@ -64,6 +64,8 @@ + #define MAX_DOMAIN_CPU_COUNT 256 + #ifdef __x86_64__ + #define DOMAIN_CPU_LEN 1024 /* x86 supports max 8192 CPUs */ ++#elif defined(__riscv) ++#define DOMAIN_CPU_LEN 64 /* riscv supports max 512 CPUs */ + #else + #define DOMAIN_CPU_LEN 128 /* arm64 supports max 1024 CPUs */ + #endif +-- +2.39.5 + diff --git a/sysmonitor-kmod.spec b/sysmonitor-kmod.spec index db41886..da192db 100644 --- a/sysmonitor-kmod.spec +++ b/sysmonitor-kmod.spec @@ -7,7 +7,7 @@ %define kmod_name sysmonitor %define version 1.3.2 -%define releaseversion 1.7 +%define releaseversion 1.8 Summary: System Monitor Daemon Name: %{kmod_name}-kmod Version: %{version} @@ -40,6 +40,7 @@ Patch2: bugfix-fix-fd-path-failed-to-open.patch Patch3: update-support-loongarch-fix-compilation-errors.patch Patch4: add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch Patch5: support-monitor-process-function-by-kprobe.patch +Patch6: add-riscv64-support.patch %description System Monitor Daemon @@ -174,6 +175,12 @@ systemctl daemon-reload 2>/dev/null 1>/dev/null /usr/lib/systemd/system/multi-user.target.wants/sysmonitor.service %changelog +* Wed Mar 12 2025 laokz - 1.3.2-1.8 +- Type:update +- CVE:NA +- SUG:NA +- DESC: support riscv64 build + * Sun Sep 22 2024 guo-zhicheng666<1678717630@qq.com> - 1.3.2-1.7 - Type:bugfix - CVE:NA -- Gitee