From 0243089afee38b71f42514623ffe576e09f6c9d0 Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Wed, 16 Oct 2024 15:18:44 +0200 Subject: [PATCH 1/4] pushing riscv changes, still missing syscall repository in deps --- src/client/intercept.cpp | 12 ++++++++++-- src/client/syscalls/detail/syscall_info.c | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 45346fdc8..a2e4215eb 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -775,20 +775,22 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg1), 0); break; #endif +#ifdef SYS_renameat case SYS_renameat: *result = gkfs::hook::hook_renameat( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2), reinterpret_cast(arg3), 0); break; - +#endif +#ifdef SYS_renameat2 case SYS_renameat2: *result = gkfs::hook::hook_renameat( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2), reinterpret_cast(arg3), static_cast(arg4)); break; - +#endif case SYS_fstatfs: *result = gkfs::hook::hook_fstatfs( static_cast(arg0), @@ -1062,9 +1064,11 @@ start_self_interception() { LOG(DEBUG, "Enabling syscall interception for self"); intercept_hook_point = internal_hook_guard_wrapper; +#ifndef __riscv intercept_hook_point_post_kernel = hook_forwarded_syscall; intercept_hook_point_clone_child = hook_clone_at_child; intercept_hook_point_clone_parent = hook_clone_at_parent; +#endif } void @@ -1076,9 +1080,11 @@ start_interception() { // Set up the callback function pointer intercept_hook_point = hook_guard_wrapper; +#ifndef __riscv intercept_hook_point_post_kernel = hook_forwarded_syscall; intercept_hook_point_clone_child = hook_clone_at_child; intercept_hook_point_clone_parent = hook_clone_at_parent; +#endif } void @@ -1089,9 +1095,11 @@ stop_interception() { // Reset callback function pointer intercept_hook_point = nullptr; +#ifndef __riscv intercept_hook_point_post_kernel = nullptr; intercept_hook_point_clone_child = nullptr; intercept_hook_point_clone_parent = nullptr; +#endif } } // namespace gkfs::preload diff --git a/src/client/syscalls/detail/syscall_info.c b/src/client/syscalls/detail/syscall_info.c index 954486f54..44092f0c7 100644 --- a/src/client/syscalls/detail/syscall_info.c +++ b/src/client/syscalls/detail/syscall_info.c @@ -472,7 +472,9 @@ SYSCALL(getpmsg, 5, S_RET(rdec), S_NARG(arg, "arg0"), #endif SYSCALL(newfstatat, 4, S_RET(rdec), S_NARG(atfd, "dfd"), S_NARG(cstr, "pathname"), S_NARG(ptr, "statbuf"), S_NARG(arg, "flag")), SYSCALL(unlinkat, 3, S_RET(rdec), S_NARG(atfd, "dfd"), S_NARG(cstr, "pathname"), S_NARG(arg, "flag")), +#ifdef SYS_renameat SYSCALL(renameat, 4, S_RET(rdec), S_NARG(atfd, "olddfd"), S_NARG(cstr, "oldname"), S_NARG(atfd, "newdfd"), S_NARG(cstr, "newname")), +#endif SYSCALL(linkat, 5, S_RET(rdec), S_NARG(atfd, "olddfd"), S_NARG(cstr, "oldpath"), S_NARG(atfd, "newdfd"), S_NARG(cstr, "newpath"), S_NARG(arg, "flags")), SYSCALL(symlinkat, 3, S_RET(rdec), S_NARG(cstr, "oldname"), S_NARG(atfd, "newdfd"), S_NARG(cstr, "newname")), SYSCALL(readlinkat, 4, S_RET(rdec), S_NARG(atfd, "dfd"), S_NARG(cstr, "pathname"), S_NARG(ptr, "buf"), S_NARG(arg, "bufsiz")), @@ -1132,7 +1134,9 @@ const struct named_syscall_entry syscalls_by_name[] = { #ifdef SYS_rename SYSCALL_BY_NAME(rename), #endif +#ifdef SYS_renameat SYSCALL_BY_NAME(renameat), +#endif SYSCALL_BY_NAME(renameat2), SYSCALL_BY_NAME(request_key), SYSCALL_BY_NAME(restart_syscall), -- GitLab From 042aa9ca7a876058974270d0c6fbbf37dd780417 Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Thu, 23 Jan 2025 12:11:33 +0100 Subject: [PATCH 2/4] riscv profile --- scripts/profiles/0.9.4/riscv.specs | 79 +++++++++++++++++++++++++ tests/scripts/dl_dep.sh/0.9.4/riscv.out | 12 ++++ 2 files changed, 91 insertions(+) create mode 100644 scripts/profiles/0.9.4/riscv.specs create mode 100644 tests/scripts/dl_dep.sh/0.9.4/riscv.out diff --git a/scripts/profiles/0.9.4/riscv.specs b/scripts/profiles/0.9.4/riscv.specs new file mode 100644 index 000000000..42a2a6654 --- /dev/null +++ b/scripts/profiles/0.9.4/riscv.specs @@ -0,0 +1,79 @@ +################################################################################ +# Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain # +# Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany # +# # +# This software was partially supported by the # +# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). # +# # +# This software was partially supported by the # +# ADA-FS project under the SPPEXA project funded by the DFG. # +# # +# This file is part of GekkoFS. # +# # +# GekkoFS is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# GekkoFS is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with GekkoFS. If not, see . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +# vi: ft=bash + +# Variables to be imported into the scripts +declare -A wgetdeps clonedeps clonedeps_args clonedeps_patches extra_install_args +declare -a order + +# Comment that should be displayed when printing the profile +comment="All dependencies" + +# Dependencies that must be downloaded directly +wgetdeps=( + ["lz4"]="1.9.4" + ["capstone"]="5.0.5" + ["argobots"]="1.2" + ["rocksdb"]="8.10.0" + ["json-c"]="0.17-20230812" +) + +# Dependencies that must be cloned. +clonedeps=( + ["libfabric"]="HEAD@v1.20.1" + ["mercury"]="v2.4.0" + ["margo"]="v0.18.3" + ["syscall_intercept"]="6527b944981a746ee37cefb123b0c1f17f23a868" +) + +# Extra arguments for git clone +clonedeps_args=( + ["mercury"]="--recurse-submodules" +) + +# Patches that should be applied post-clone +clonedeps_patches=( + ["syscall_intercept"]="syscall_intercept.patch syscall_intercept_clone3.patch" +) + +# Ordering that MUST be followed when downloading +order=( + "lz4" "capstone" "json-c" "libfabric" "mercury" "argobots" "margo" "rocksdb" "syscall_intercept" +) + +# Extra arguments passed to the installation script. As such, they can +# reference the following variables: +# - CMAKE: a variable that expands to the cmake binary +# - SOURCE_DIR: the directory where the sources for the package were +# downloaded +# - INSTALL_DIR: the directory where the package should be installed +# - CORES: the number of cores to use when building +# - PERFORM_TEST: whether tests for the package should be executed +extra_install_args=( +) diff --git a/tests/scripts/dl_dep.sh/0.9.4/riscv.out b/tests/scripts/dl_dep.sh/0.9.4/riscv.out new file mode 100644 index 000000000..4d90db27b --- /dev/null +++ b/tests/scripts/dl_dep.sh/0.9.4/riscv.out @@ -0,0 +1,12 @@ +Downloaded 'https://github.com/lz4/lz4/archive/v1.9.4.tar.gz' to 'lz4' +Downloaded 'https://github.com/aquynh/capstone/archive/5.0.5.tar.gz' to 'capstone' +Downloaded 'https://github.com/json-c/json-c/archive/json-c-0.17-20230812.tar.gz' to 'json-c' +Cloned 'https://github.com/ofiwg/libfabric.git' to 'libfabric' with commit '[HEAD]' and flags '--branch=v1.20.1' +Cloned 'https://github.com/mercury-hpc/mercury' to 'mercury' with commit '[v2.4.0]' and flags '--recurse-submodules' +Downloaded 'https://github.com/pmodels/argobots/archive/v1.2.tar.gz' to 'argobots' +Cloned 'https://github.com/mochi-hpc/mochi-margo' to 'margo' with commit '[v0.18.3]' and flags '' +Downloaded 'https://github.com/facebook/rocksdb/archive/v8.10.0.tar.gz' to 'rocksdb' +Cloned 'https://github.com/GekkoFS/syscall_intercept.git' to 'syscall_intercept' with commit '[6527b944981a746ee37cefb123b0c1f17f23a868]' and flags '' +Applying patch '/builds/gitlab/hpc/gekkofs/scripts/patches/syscall_intercept.patch'... +Applying patch '/builds/gitlab/hpc/gekkofs/scripts/patches/syscall_intercept_clone3.patch'... +Done -- GitLab From 28dbc9366e65e82d56ec5ec8a3f149ae3a7f6b06 Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Tue, 28 Jan 2025 12:35:10 +0100 Subject: [PATCH 3/4] patch syscall_intercept header for riscv, activate logs, new syscall_intercept version --- scripts/profiles/0.9.4/install/syscall_intercept.install | 5 +++++ scripts/profiles/0.9.4/riscv.specs | 9 ++------- src/client/intercept.cpp | 6 ------ tests/integration/harness/gkfs.io/syscall_coverage.cpp | 6 ++++++ tests/scripts/dl_dep.sh/0.9.4/riscv.out | 6 ++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/profiles/0.9.4/install/syscall_intercept.install b/scripts/profiles/0.9.4/install/syscall_intercept.install index f47185c9f..668e9e850 100644 --- a/scripts/profiles/0.9.4/install/syscall_intercept.install +++ b/scripts/profiles/0.9.4/install/syscall_intercept.install @@ -66,6 +66,11 @@ pkg_install() { if [[ ${EXTRA_INSTALL_ARGS} == "ARM64" ]]; then cp "${CURR}"/arch/aarch64/include/libsyscall_intercept_hook_point.h ${INSTALL_DIR}/include fi + + # patch for riscv syscall_intercept version to fit other implementations + # it replaces line 91 only if there is the struct wrapper_ret of riscv + sed -i '91s/struct wrapper_ret/long/g' \ + ${INSTALL_DIR}/include/libsyscall_intercept_hook_point.h } pkg_check() { diff --git a/scripts/profiles/0.9.4/riscv.specs b/scripts/profiles/0.9.4/riscv.specs index 42a2a6654..41edbd008 100644 --- a/scripts/profiles/0.9.4/riscv.specs +++ b/scripts/profiles/0.9.4/riscv.specs @@ -38,7 +38,7 @@ comment="All dependencies" # Dependencies that must be downloaded directly wgetdeps=( ["lz4"]="1.9.4" - ["capstone"]="5.0.5" + ["capstone"]="6.0.0-Alpha2" ["argobots"]="1.2" ["rocksdb"]="8.10.0" ["json-c"]="0.17-20230812" @@ -49,7 +49,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.20.1" ["mercury"]="v2.4.0" ["margo"]="v0.18.3" - ["syscall_intercept"]="6527b944981a746ee37cefb123b0c1f17f23a868" + ["syscall_intercept"]="2a25b21926ab115d667e135389458a7a159e8bb1" ) # Extra arguments for git clone @@ -57,11 +57,6 @@ clonedeps_args=( ["mercury"]="--recurse-submodules" ) -# Patches that should be applied post-clone -clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch syscall_intercept_clone3.patch" -) - # Ordering that MUST be followed when downloading order=( "lz4" "capstone" "json-c" "libfabric" "mercury" "argobots" "margo" "rocksdb" "syscall_intercept" diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index a2e4215eb..b933ff162 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -1064,11 +1064,9 @@ start_self_interception() { LOG(DEBUG, "Enabling syscall interception for self"); intercept_hook_point = internal_hook_guard_wrapper; -#ifndef __riscv intercept_hook_point_post_kernel = hook_forwarded_syscall; intercept_hook_point_clone_child = hook_clone_at_child; intercept_hook_point_clone_parent = hook_clone_at_parent; -#endif } void @@ -1080,11 +1078,9 @@ start_interception() { // Set up the callback function pointer intercept_hook_point = hook_guard_wrapper; -#ifndef __riscv intercept_hook_point_post_kernel = hook_forwarded_syscall; intercept_hook_point_clone_child = hook_clone_at_child; intercept_hook_point_clone_parent = hook_clone_at_parent; -#endif } void @@ -1095,11 +1091,9 @@ stop_interception() { // Reset callback function pointer intercept_hook_point = nullptr; -#ifndef __riscv intercept_hook_point_post_kernel = nullptr; intercept_hook_point_clone_child = nullptr; intercept_hook_point_clone_parent = nullptr; -#endif } } // namespace gkfs::preload diff --git a/tests/integration/harness/gkfs.io/syscall_coverage.cpp b/tests/integration/harness/gkfs.io/syscall_coverage.cpp index fb253314e..08246289b 100644 --- a/tests/integration/harness/gkfs.io/syscall_coverage.cpp +++ b/tests/integration/harness/gkfs.io/syscall_coverage.cpp @@ -401,19 +401,23 @@ syscall_coverage_exec(const syscall_coverage_options& opts) { } ::close(fd_append); +#ifdef SYS_open // sys_open rv = ::syscall(SYS_open, opts.pathname.c_str(), O_RDONLY, 0); if(rv < 0) { output("sys_open", rv, opts); return; } +#endif +#ifdef SYS_creat // sys_creat rv = ::syscall(SYS_creat, opts.pathname.c_str(), 0777); if(rv < 0) { output("sys_creat", rv, opts); return; } +#endif // sys_unlinkat rv = ::syscall(SYS_unlinkat, AT_FDCWD, opts.pathname.c_str(), 0); @@ -430,12 +434,14 @@ syscall_coverage_exec(const syscall_coverage_options& opts) { return; } +#ifdef SYS_chmod // SYS_chmod rv = ::syscall(SYS_chmod, opts.pathname.c_str(), 0777); if(errno != ENOTSUP) { output("sys_chmod", rv, opts); return; } +#endif // hook_faccessat coverage rv = ::syscall(SYS_faccessat, AT_FDCWD, opts.pathname.c_str(), F_OK, 0); diff --git a/tests/scripts/dl_dep.sh/0.9.4/riscv.out b/tests/scripts/dl_dep.sh/0.9.4/riscv.out index 4d90db27b..6a8640356 100644 --- a/tests/scripts/dl_dep.sh/0.9.4/riscv.out +++ b/tests/scripts/dl_dep.sh/0.9.4/riscv.out @@ -1,12 +1,10 @@ Downloaded 'https://github.com/lz4/lz4/archive/v1.9.4.tar.gz' to 'lz4' -Downloaded 'https://github.com/aquynh/capstone/archive/5.0.5.tar.gz' to 'capstone' +Downloaded 'https://github.com/aquynh/capstone/archive/6.0.0-Alpha2.tar.gz' to 'capstone' Downloaded 'https://github.com/json-c/json-c/archive/json-c-0.17-20230812.tar.gz' to 'json-c' Cloned 'https://github.com/ofiwg/libfabric.git' to 'libfabric' with commit '[HEAD]' and flags '--branch=v1.20.1' Cloned 'https://github.com/mercury-hpc/mercury' to 'mercury' with commit '[v2.4.0]' and flags '--recurse-submodules' Downloaded 'https://github.com/pmodels/argobots/archive/v1.2.tar.gz' to 'argobots' Cloned 'https://github.com/mochi-hpc/mochi-margo' to 'margo' with commit '[v0.18.3]' and flags '' Downloaded 'https://github.com/facebook/rocksdb/archive/v8.10.0.tar.gz' to 'rocksdb' -Cloned 'https://github.com/GekkoFS/syscall_intercept.git' to 'syscall_intercept' with commit '[6527b944981a746ee37cefb123b0c1f17f23a868]' and flags '' -Applying patch '/builds/gitlab/hpc/gekkofs/scripts/patches/syscall_intercept.patch'... -Applying patch '/builds/gitlab/hpc/gekkofs/scripts/patches/syscall_intercept_clone3.patch'... +Cloned 'https://github.com/GekkoFS/syscall_intercept.git' to 'syscall_intercept' with commit '[2a25b21926ab115d667e135389458a7a159e8bb1]' and flags '' Done -- GitLab From f9fdbc4a57c68247e2e78b8b22c80f032a6b6d89 Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Tue, 4 Mar 2025 14:12:53 +0100 Subject: [PATCH 4/4] Add CHANGELOG for riscv support --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4dc518a..0d6b1a625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### New + +- Add RISC-V profile ([!220](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/220)) + ### Changed - Unify dependency scripts (dl and compile): Unify `-d` and `-p` flags ([!174](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/174)). -- GitLab