diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index bfdaacadf7d74814ade69e2873271950b85c00d5..5b78d9eeb342c06797c2cd80dd2f86b9c9082e39 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -208,7 +208,7 @@ public: is_internal_fd(int fd) const; void - protect_user_fds(); + protect_user_fds(int root_fd); void unprotect_user_fds(); diff --git a/scripts/compile_dep.sh b/scripts/compile_dep.sh index fe76c7063710eb3fdfc3c601d551065180cb2854..0e872e92c72a2d2ce5ecf798e02346579be825e3 100755 --- a/scripts/compile_dep.sh +++ b/scripts/compile_dep.sh @@ -471,6 +471,20 @@ while [[ $# -gt 0 ]]; do help_msg exit ;; + -a | --arch) + ARCH=$2 + echo "System arch is $ARCH" + + if [[ "$ARCH" == "arm64" ]];then + SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" + PROFILE_VERSION="${DEFAULT_VERSION}.arm64" + else + SOURCES_FILE="${PROFILES_DIR}/sources.list" + fi + echo "SOURCES_FILE is set to ${SOURCES_FILE}" + shift # past argument + shift # past value + ;; -n | --dry-run) DRY_RUN=true shift diff --git a/scripts/dl_dep.sh b/scripts/dl_dep.sh index 5cba6d0ca108d2fa335736b789a618ea0f4db3c6..00412d745014785682cfb40907e492544bd154c1 100755 --- a/scripts/dl_dep.sh +++ b/scripts/dl_dep.sh @@ -31,6 +31,7 @@ COMMON_CURL_FLAGS="--silent --fail --show-error --location -O" COMMON_GIT_FLAGS="--quiet --single-branch -c advice.detachedHead=false" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PATCH_DIR="${SCRIPT_DIR}/patches" +ARCH="" DEPENDENCY="" EXECUTION_MODE= @@ -42,7 +43,9 @@ DEFAULT_VERSION="latest" PROFILE_NAME=${DEFAULT_PROFILE} PROFILE_VERSION=${DEFAULT_VERSION} PROFILES_DIR="${SCRIPT_DIR}/profiles" -SOURCES_FILE="${PROFILES_DIR}/sources.list" + +SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" + declare -a PROFILE_DEP_LIST declare -A PROFILE_DEP_NAMES declare -A PROFILE_WGETDEPS PROFILE_CLONEDEPS PROFILE_SOURCES @@ -174,7 +177,7 @@ load_profile() { PROFILE_WGETDEPS=() local filename="${PROFILES_DIR}/${version}/${profile}.specs" - + echo "filename is $filename" if [[ ! -f "${filename}" ]]; then echo "Profile '${profile}:${version}' does not exist." exit 1 @@ -307,6 +310,7 @@ usage_short() { usage: dl_dep.sh -p PROFILE_NAME[:PROFILE_VERSION] | -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | -l [[PROFILE_NAME:]PROFILE_VERSION] | + -a [ARCH] | -h [ -P PROFILES_DIR ] [ -n ] DESTINATION_PATH @@ -345,6 +349,7 @@ optional arguments: Choose the directory to be used when searching for profiles. If unspecified, PROFILES_DIR defaults to \${PWD}/profiles. -n, --dry-run Do not actually run, print only what would be done. + -a, --arch The arch of the target host. -v, --verbose Increase download verbosity " } @@ -439,6 +444,20 @@ while [[ $# -gt 0 ]]; do exit ;; + -a | --arch) + ARCH=$2 + echo "System arch is $ARCH" + + if [[ "$ARCH" == "arm64" ]];then + SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" + PROFILE_VERSION="${DEFAULT_VERSION}.arm64" + else + SOURCES_FILE="${PROFILES_DIR}/sources.list" + fi + echo "SOURCES_FILE is set to ${SOURCES_FILE}" + shift # past argument + shift # past value + ;; -h | --help) help_msg exit @@ -455,7 +474,9 @@ while [[ $# -gt 0 ]]; do fi PROFILES_DIR="$2" - SOURCES_FILE="${PROFILES_DIR}/sources.list" + if [[ -f "${SOURCES_FILE}" ]];then + SOURCES_FILE=${SOURCES_FILE} + fi shift # past argument shift # past value ;; diff --git a/scripts/patches/syscall_intercept.patch.arm64 b/scripts/patches/syscall_intercept.patch.arm64 new file mode 100644 index 0000000000000000000000000000000000000000..72fd06e6cc31b18ce394df0e9bf8478a5d7b574f --- /dev/null +++ b/scripts/patches/syscall_intercept.patch.arm64 @@ -0,0 +1,148 @@ +From dc462223c52f97e94464eb597e1af9ab961aa781 Mon Sep 17 00:00:00 2001 +From: sktzwhj +Date: Thu, 24 Feb 2022 17:34:40 +0800 +Subject: [PATCH] changes for gekkofs + +--- + CMakeLists.txt | 16 +++--- + .../include/libsyscall_intercept_hook_point.h | 17 ++++++- + arch/aarch64/src/intercept.c | 50 ++++++++++++++++--- + 3 files changed, 65 insertions(+), 18 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 13fcdb9..11b621a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -220,14 +220,14 @@ install(TARGETS syscall_intercept_shared + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +-if (NOT SUBMOUDLE_BUILD) +- install(TARGETS syscall_intercept_static +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +- add_subdirectory(doc) +-endif() ++# if (NOT SUBMOUDLE_BUILD) ++# install(TARGETS syscall_intercept_static ++# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++# install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ++# add_subdirectory(doc) ++# endif() + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" +diff --git a/arch/aarch64/include/libsyscall_intercept_hook_point.h b/arch/aarch64/include/libsyscall_intercept_hook_point.h +index 2fe7d57..46f7eff 100644 +--- a/arch/aarch64/include/libsyscall_intercept_hook_point.h ++++ b/arch/aarch64/include/libsyscall_intercept_hook_point.h +@@ -57,8 +57,21 @@ extern int (*intercept_hook_point)(long syscall_number, + long arg4, long arg5, + long *result); + +-extern void (*intercept_hook_point_clone_child)(void); +-extern void (*intercept_hook_point_clone_parent)(long pid); ++ ++extern void (*intercept_hook_point_clone_child)( ++ unsigned long flags, void *child_stack, ++ int *ptid, int *ctid, long newtls); ++ ++extern void (*intercept_hook_point_clone_parent)( ++ unsigned long flags, void *child_stack, ++ int *ptid, int *ctid, long newtls, ++ long returned_pid); ++ ++extern void (*intercept_hook_point_post_kernel)(long syscall_number, ++ long arg0, long arg1, ++ long arg2, long arg3, ++ long arg4, long arg5, ++ long result); + + /* + * syscall_no_intercept - syscall without interception +diff --git a/arch/aarch64/src/intercept.c b/arch/aarch64/src/intercept.c +index a15aa97..72e4b7a 100644 +--- a/arch/aarch64/src/intercept.c ++++ b/arch/aarch64/src/intercept.c +@@ -68,11 +68,24 @@ int (*intercept_hook_point)(long syscall_number, + long *result) + __attribute__((visibility("default"))); + +-void (*intercept_hook_point_clone_child)(void) +- __attribute__((visibility("default"))); +-void (*intercept_hook_point_clone_parent)(long) +- __attribute__((visibility("default"))); +- ++void (*intercept_hook_point_clone_child)( ++ unsigned long flags, void *child_stack, ++ int *ptid, int *ctid, ++ long newtls) ++__attribute__((visibility("default"))); ++ ++void (*intercept_hook_point_clone_parent)( ++ unsigned long flags, void *child_stack, ++ int *ptid, int *ctid, ++ long newtls, long returned_pid) ++__attribute__((visibility("default"))); ++ ++void (*intercept_hook_point_post_kernel)(long syscall_number, ++ long arg0, long arg1, ++ long arg2, long arg3, ++ long arg4, long arg5, ++ long result) ++__attribute__((visibility("default"))); + bool debug_dumps_on; + + void +@@ -630,7 +643,15 @@ intercept_routine(struct context *context) + + if (handle_magic_syscalls(&desc, &result) == 0) + return (struct wrapper_ret){.x0 = result, .x1 = 1 }; +- ++ if (intercept_hook_point_post_kernel != NULL) ++ intercept_hook_point_post_kernel(desc.nr, ++ desc.args[0], ++ desc.args[1], ++ desc.args[2], ++ desc.args[3], ++ desc.args[4], ++ desc.args[5], ++ result); + intercept_log_syscall(patch, &desc, UNKNOWN, 0); + + if (intercept_hook_point != NULL) +@@ -693,12 +714,25 @@ intercept_routine(struct context *context) + struct wrapper_ret + intercept_routine_post_clone(struct context *context) + { ++ struct syscall_desc desc; ++ get_syscall_in_context(context, &desc); + if (context->x0 == 0) { + if (intercept_hook_point_clone_child != NULL) +- intercept_hook_point_clone_child(); ++ intercept_hook_point_clone_child( ++ (unsigned long)desc.args[0], ++ (void *)desc.args[1], ++ (int *)desc.args[2], ++ (int *)desc.args[3], ++ desc.args[4]); + } else { + if (intercept_hook_point_clone_parent != NULL) +- intercept_hook_point_clone_parent(context->x0); ++ intercept_hook_point_clone_parent( ++ (unsigned long)desc.args[0], ++ (void *)desc.args[1], ++ (int *)desc.args[2], ++ (int *)desc.args[3], ++ desc.args[4], ++ context->x0); + } + + return (struct wrapper_ret){.x0 = context->x0, .x1 = 1 }; +-- +2.17.1 + diff --git a/scripts/profiles/0.9.0/agios.specs b/scripts/profiles/0.9.0/agios.specs index 066cf7cb1dfe9948e4edb6ecfc7fea321177be6f..4f7b267bb40be9e5dbfabcaa748b4d0fe56e167b 100644 --- a/scripts/profiles/0.9.0/agios.specs +++ b/scripts/profiles/0.9.0/agios.specs @@ -49,7 +49,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ["agios"]="c26a6544200f823ebb8f890dd94e653d148bf226@development" ) @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/ci.specs b/scripts/profiles/0.9.0/ci.specs index 261f1e21f30f8712d967c643305289dc04724a67..1eab6190dae609a501f4f1d58b1b91856f9cc588 100644 --- a/scripts/profiles/0.9.0/ci.specs +++ b/scripts/profiles/0.9.0/ci.specs @@ -46,7 +46,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ["agios"]="c26a6544200f823ebb8f890dd94e653d148bf226@development" ) @@ -58,7 +58,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/default.specs b/scripts/profiles/0.9.0/default.specs index 4c893a36a0a819bdc8ac068a3b039aefa7b9aa23..25f1b8676c4a9eff7b0632dc96f51beec66f7c80 100644 --- a/scripts/profiles/0.9.0/default.specs +++ b/scripts/profiles/0.9.0/default.specs @@ -49,7 +49,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -60,7 +60,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/direct.specs b/scripts/profiles/0.9.0/direct.specs index c65f528f76cc58fab4ebcd00f5e71cc83fe3385c..53daf211ccb5780b94f29358dd4920f540ed77e0 100644 --- a/scripts/profiles/0.9.0/direct.specs +++ b/scripts/profiles/0.9.0/direct.specs @@ -46,7 +46,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ) # Extra arguments for git clone @@ -56,7 +56,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/infiniband_verbs.specs b/scripts/profiles/0.9.0/infiniband_verbs.specs index e7215869f7ac07c8941e5e0b24107ee0c60d7019..1fcfede99d331b2c84051de342bb14a304bf233f 100644 --- a/scripts/profiles/0.9.0/infiniband_verbs.specs +++ b/scripts/profiles/0.9.0/infiniband_verbs.specs @@ -49,7 +49,7 @@ clonedeps=( ["libfabric%verbs"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -60,7 +60,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading/installing diff --git a/scripts/profiles/0.9.0/install/rocksdb.install b/scripts/profiles/0.9.0/install/rocksdb.install index 9350e9feb8a34491d61f447be06efd33de315bfb..bf03e109f60f85c57227ca7b05c2db031922ca41 100644 --- a/scripts/profiles/0.9.0/install/rocksdb.install +++ b/scripts/profiles/0.9.0/install/rocksdb.install @@ -61,7 +61,7 @@ pkg_install() { -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" \ -DCMAKE_INSTALL_LIBDIR="${INSTALL_DIR}/lib" \ -DCMAKE_INSTALL_INCLUDEDIR="${INSTALL_DIR}/include" \ - -DROCKSDB_BUILD_SHARED=OFF \ + -DROCKSDB_BUILD_SHARED=ON \ -DWITH_LZ4=ON \ -DWITH_GFLAGS=OFF \ -DUSE_RTTI=1 \ diff --git a/scripts/profiles/0.9.0/install/syscall_intercept.install b/scripts/profiles/0.9.0/install/syscall_intercept.install index 9dd287271c61838a29cedd5e3bf3146ffb598f08..ea82b944c961e4895dc622f35351e337ad6846f0 100644 --- a/scripts/profiles/0.9.0/install/syscall_intercept.install +++ b/scripts/profiles/0.9.0/install/syscall_intercept.install @@ -45,9 +45,13 @@ pkg_install() { ID="syscall_intercept" + echo "aarch64 install" CURR="${SOURCE_DIR}/${ID}" prepare_build_dir "${CURR}" - cd "${CURR}"/build + cd "${CURR}"/arch/aarch64/ + mkdir -p build + cd build + echo $PWD $CMAKE -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_BUILD_TYPE:STRING=Debug \ diff --git a/scripts/profiles/0.9.0/marenostrum4.specs b/scripts/profiles/0.9.0/marenostrum4.specs index 2f64676f6e4bae3cd5f8ca7f825fa80b6ca76b12..170c411a90c8f1ebe63d9b36702fbf575976c19e 100644 --- a/scripts/profiles/0.9.0/marenostrum4.specs +++ b/scripts/profiles/0.9.0/marenostrum4.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/mogon2.specs b/scripts/profiles/0.9.0/mogon2.specs index ee6c1d0a2dd25ca74a90d53491ab35c092d5e41d..3e5e8860bb44b7f1af6cff0f92abcebb6eedd085 100644 --- a/scripts/profiles/0.9.0/mogon2.specs +++ b/scripts/profiles/0.9.0/mogon2.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/ngio.specs b/scripts/profiles/0.9.0/ngio.specs index ae633e44d86d6abf8bdeb3c69e3787abd6d1f870..cebf7b8bcfa99e303202f54f6f901d98217de204 100644 --- a/scripts/profiles/0.9.0/ngio.specs +++ b/scripts/profiles/0.9.0/ngio.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/omnipath_psm2.specs b/scripts/profiles/0.9.0/omnipath_psm2.specs index 779c3dadd789b151f65514a259c5d293cae1e7c4..aa475d32ef32bf312d09f7a50ac67ac040372294 100644 --- a/scripts/profiles/0.9.0/omnipath_psm2.specs +++ b/scripts/profiles/0.9.0/omnipath_psm2.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/latest.arm64 b/scripts/profiles/latest.arm64 new file mode 120000 index 0000000000000000000000000000000000000000..899f24fc754a14b89617093824d258aaa3aa2943 --- /dev/null +++ b/scripts/profiles/latest.arm64 @@ -0,0 +1 @@ +0.9.0 \ No newline at end of file diff --git a/scripts/profiles/sources.list.arm64 b/scripts/profiles/sources.list.arm64 new file mode 100644 index 0000000000000000000000000000000000000000..551fd1cdce24965ba07f83db7bcfe2ac9068736c --- /dev/null +++ b/scripts/profiles/sources.list.arm64 @@ -0,0 +1,75 @@ +################################################################################ +# Copyright 2018-2022, Barcelona Supercomputing Center (BSC), Spain # +# Copyright 2015-2022, 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 + +declare -A sources + +sources=( + ["bzip2"]="https://sourceforge.net/projects/bzip2/files/bzip2-{{VERSION}}.tar.gz" + ["zstd"]="https://github.com/facebook/zstd/archive/v{{VERSION}}.tar.gz" + ["lz4"]="https://github.com/lz4/lz4/archive/v{{VERSION}}.tar.gz" + ["snappy"]="https://github.com/google/snappy/archive/{{VERSION}}.tar.gz" + ["capstone"]="https://github.com/aquynh/capstone/archive/{{VERSION}}.tar.gz" + ["argobots"]="https://github.com/pmodels/argobots/archive/v{{VERSION}}.tar.gz" + ["rocksdb"]="https://github.com/facebook/rocksdb/archive/v{{VERSION}}.tar.gz" + ["rocksdb%experimental"]="https://github.com/facebook/rocksdb/archive/v{{VERSION}}.tar.gz" + ["psm2"]="https://github.com/intel/opa-psm2/archive/PSM2_{{VERSION}}.tar.gz" + ["bmi"]="https://github.com/radix-io/bmi/" + ["libfabric"]="https://github.com/ofiwg/libfabric.git" + ["libfabric%experimental"]="https://github.com/ofiwg/libfabric.git" + ["libfabric%verbs"]="https://github.com/ofiwg/libfabric.git" + ["mercury"]="https://github.com/mercury-hpc/mercury" + ["margo"]="https://github.com/mochi-hpc/mochi-margo" + ["syscall_intercept"]="https://github.com/RIKEN-SysSoft/syscall_intercept.git" + ["date"]="https://github.com/HowardHinnant/date.git" + ["agios"]="https://github.com/francielizanon/agios.git" + ["json-c"]="https://github.com/json-c/json-c/archive/json-c-{{VERSION}}.tar.gz" +) + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 681c264f1c35f704fa758e7ba32b8b360187db6a..f017bc5a2b9f76f958b9f030c016fa6e844909d5 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -26,6 +26,13 @@ # # # SPDX-License-Identifier: LGPL-3.0-or-later # ################################################################################ + +set(syscall_info_file "") +if(x86_64) +set(syscall_info_file "MAKE_CURRENT_LIST_DIR}/syscalls/detail/syscall_info.c") +endif() + + set(PRELOAD_SOURCES PRIVATE ${CMAKE_CURRENT_LIST_DIR}/gkfs_functions.cpp @@ -43,7 +50,7 @@ set(PRELOAD_SOURCES ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_data.cpp ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_management.cpp ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_metadata.cpp - ${CMAKE_CURRENT_LIST_DIR}/syscalls/detail/syscall_info.c + ${syscall_info_file} PUBLIC ${INCLUDE_DIR}/client/gkfs_functions.hpp ${INCLUDE_DIR}/config.hpp diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index d58302373fa97b81ac1dc5c93edff22950ffddbe..460f28cc8038629fa85e5ff76a8a4d4fc58d2bff 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -71,6 +71,7 @@ syscall_no_intercept_wrapper(long syscall_number, Args... args) { namespace gkfs::hook { +#if defined x86_64 || defined ARM64 int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { @@ -98,7 +99,9 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { return -EINVAL; } } +#endif +#if defined x86_64 || defined ARM64 int hook_close(int fd) { @@ -118,7 +121,9 @@ hook_close(int fd) { return syscall_no_intercept_wrapper(SYS_close, fd); } +#endif +#if defined x86_64 int hook_stat(const char* path, struct stat* buf) { @@ -132,8 +137,10 @@ hook_stat(const char* path, struct stat* buf) { return syscall_no_intercept_wrapper(SYS_stat, rel_path.c_str(), buf); } +#endif #ifdef STATX_TYPE +#if defined x86_64 || defined ARM64 int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, @@ -169,8 +176,10 @@ hook_statx(int dirfd, const char* path, int flags, unsigned int mask, return syscall_no_intercept(SYS_statx, dirfd, path, flags, mask, buf); } +#endif #endif +#if defined x86_64 int hook_lstat(const char* path, struct stat* buf) { @@ -184,7 +193,9 @@ hook_lstat(const char* path, struct stat* buf) { return syscall_no_intercept_wrapper(SYS_lstat, rel_path.c_str(), buf); ; } +#endif +#if defined x86_64 || defined ARM64 int hook_fstat(unsigned int fd, struct stat* buf) { @@ -408,8 +419,9 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) { return -EINVAL; } } +#endif - +#if defined x86_64 int hook_access(const char* path, int mask) { @@ -425,7 +437,9 @@ hook_access(const char* path, int mask) { } return syscall_no_intercept_wrapper(SYS_access, rel_path.c_str(), mask); } +#endif +#if defined x86_64 || defined ARM64 int hook_faccessat(int dirfd, const char* cpath, int mode) { @@ -509,7 +523,9 @@ hook_dup(unsigned int fd) { } return syscall_no_intercept_wrapper(SYS_dup, fd); } +#endif +#if defined x86_64 int hook_dup2(unsigned int oldfd, unsigned int newfd) { @@ -520,7 +536,9 @@ hook_dup2(unsigned int oldfd, unsigned int newfd) { } return syscall_no_intercept_wrapper(SYS_dup2, oldfd, newfd); } +#endif +#if defined x86_64 || defined ARM64 int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags) { @@ -535,7 +553,9 @@ hook_dup3(unsigned int oldfd, unsigned int newfd, int flags) { } return syscall_no_intercept_wrapper(SYS_dup3, oldfd, newfd, flags); } +#endif +#if defined x86_64 int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { @@ -547,8 +567,10 @@ hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { } return syscall_no_intercept_wrapper(SYS_getdents, fd, dirp, count); } +#endif +#if defined x86_64 || defined ARM64 int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count) { @@ -920,5 +942,6 @@ hook_fsync(unsigned int fd) { return syscall_no_intercept_wrapper(SYS_fsync, fd); } +#endif } // namespace gkfs::hook diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index a403ddd05b0232b79a6519f244dc9f51823424b7..ae59676b5397cb167aa59ca9c69ae045e71c5c68 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -92,7 +92,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, syscall_number, args); switch(syscall_number) { - +#if defined x86_64 case SYS_open: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -120,7 +120,8 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - +#endif +#if defined x86_64 || defined ARM64 case SYS_openat: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -134,7 +135,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = -syserror; } break; - +#if defined x86_64 case SYS_epoll_create: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -147,6 +148,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif case SYS_epoll_create1: *result = syscall_no_intercept(syscall_number, @@ -171,7 +173,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif +#if defined x86_64 case SYS_dup2: *result = syscall_no_intercept(syscall_number, static_cast(arg0), @@ -183,7 +187,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif +#if defined x86_64 || defined ARM64 case SYS_dup3: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -198,7 +204,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif +#if defined x86_64 case SYS_inotify_init: *result = syscall_no_intercept(syscall_number); @@ -207,7 +215,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif +#if defined x86_64 || defined ARM64 case SYS_inotify_init1: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -229,7 +239,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; +#endif +#if defined x86_64 case SYS_signalfd: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -239,7 +251,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; +#endif +#if defined x86_64 || defined ARM64 case SYS_signalfd4: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -287,7 +301,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif +#if defined x86_64 case SYS_pipe: *result = syscall_no_intercept(syscall_number, reinterpret_cast(arg0)); @@ -300,7 +316,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif + +#if defined x86_64 || defined ARM64 case SYS_pipe2: *result = syscall_no_intercept(syscall_number, @@ -314,6 +333,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; +#endif + +#if defined x86_64 case SYS_eventfd: @@ -324,7 +346,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; +#endif + +#if defined x86_64 || defined ARM64 case SYS_eventfd2: *result = @@ -412,6 +437,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, CTX->unregister_internal_fd(arg0); } break; +#endif default: // ignore any other syscalls, i.e.: pass them on to the kernel @@ -452,6 +478,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, switch(syscall_number) { +#if defined x86_64 || defined ARM64 case SYS_execve: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -467,7 +494,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg3), arg4); break; #endif - +#endif +#if defined x86_64 case SYS_open: *result = gkfs::hook::hook_openat( AT_FDCWD, reinterpret_cast(arg0), @@ -479,7 +507,10 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, AT_FDCWD, reinterpret_cast(arg0), O_WRONLY | O_CREAT | O_TRUNC, static_cast(arg1)); break; +#endif + +#if defined x86_64 || defined ARM64 case SYS_openat: *result = gkfs::hook::hook_openat( static_cast(arg0), reinterpret_cast(arg1), @@ -490,12 +521,13 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_close(static_cast(arg0)); break; +#if defined x86_64 case SYS_stat: *result = gkfs::hook::hook_stat(reinterpret_cast(arg0), reinterpret_cast(arg1)); break; - +#endif #ifdef STATX_TYPE case SYS_statx: *result = gkfs::hook::hook_statx( @@ -504,13 +536,17 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg4)); break; #endif +#endif +#if defined x86_64 case SYS_lstat: *result = gkfs::hook::hook_lstat( reinterpret_cast(arg0), reinterpret_cast(arg1)); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_fstat: *result = gkfs::hook::hook_fstat( static_cast(arg0), @@ -582,16 +618,23 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg4)); break; +#endif + +#if defined x86_64 case SYS_unlink: *result = gkfs::hook::hook_unlinkat( AT_FDCWD, reinterpret_cast(arg0), 0); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_unlinkat: *result = gkfs::hook::hook_unlinkat( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; +#endif +#if defined x86_64 case SYS_rmdir: *result = gkfs::hook::hook_unlinkat( @@ -604,19 +647,26 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1)); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_symlinkat: *result = gkfs::hook::hook_symlinkat( reinterpret_cast(arg0), static_cast(arg1), reinterpret_cast(arg2)); break; +#endif + +#if defined x86_64 case SYS_access: *result = gkfs::hook::hook_access(reinterpret_cast(arg0), static_cast(arg1)); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_faccessat: *result = gkfs::hook::hook_faccessat( static_cast(arg0), reinterpret_cast(arg1), @@ -644,25 +694,33 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_dup: *result = gkfs::hook::hook_dup(static_cast(arg0)); break; +#endif +#if defined x86_64 case SYS_dup2: *result = gkfs::hook::hook_dup2(static_cast(arg0), static_cast(arg1)); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_dup3: *result = gkfs::hook::hook_dup3(static_cast(arg0), static_cast(arg1), static_cast(arg2)); break; +#endif +#if defined x86_64 case SYS_getdents: *result = gkfs::hook::hook_getdents( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; +#endif +#if defined x86_64 || defined ARM64 case SYS_getdents64: *result = gkfs::hook::hook_getdents64( static_cast(arg0), @@ -676,7 +734,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg1), static_cast(arg2)); break; - +#endif +#if defined x86_64 case SYS_mkdir: *result = gkfs::hook::hook_mkdirat( AT_FDCWD, reinterpret_cast(arg0), @@ -688,7 +747,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), static_cast(arg1)); break; - +#endif +#if defined x86_64 || defined ARM64 case SYS_fchmod: *result = gkfs::hook::hook_fchmod(static_cast(arg0), static_cast(arg1)); @@ -713,13 +773,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_getcwd(reinterpret_cast(arg0), static_cast(arg1)); break; - +#endif +#if defined x86_64 case SYS_readlink: *result = gkfs::hook::hook_readlinkat( AT_FDCWD, reinterpret_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; - +#endif +#if defined x86_64 || defined ARM64 case SYS_readlinkat: *result = gkfs::hook::hook_readlinkat( static_cast(arg0), reinterpret_cast(arg1), @@ -731,13 +793,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg1), static_cast(arg2)); break; - +#endif +#if defined x86_64 case SYS_rename: *result = gkfs::hook::hook_renameat( AT_FDCWD, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1), 0); break; - +#endif +#if defined x86_64 || defined ARM64 case SYS_renameat: *result = gkfs::hook::hook_renameat( static_cast(arg0), reinterpret_cast(arg1), @@ -767,7 +831,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_fsync: *result = gkfs::hook::hook_fsync(static_cast(arg0)); break; - +#endif default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in diff --git a/src/client/preload.cpp b/src/client/preload.cpp index ba3a87870f3993a708d98c9d6d428e6e241bb811..46cd21f5c8fe427d64c13c845b664486215c1f01 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -26,6 +26,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later */ +#include #include #include @@ -261,6 +262,7 @@ init_preload() { // The original errno value will be restored after initialization to not // leak internal error codes auto oerrno = errno; + int root_fd = dirfd(opendir("/")); CTX->enable_interception(); gkfs::preload::start_self_interception(); @@ -277,7 +279,7 @@ init_preload() { // [MAX_USER_FDS, MAX_OPEN_FDS) range. To prevent this for our internal // initialization code, we forcefully occupy the user fd range to force // such modules to create fds in our private range. - CTX->protect_user_fds(); + CTX->protect_user_fds(root_fd); log_prog_name(); gkfs::path::init_cwd(); diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 9a1f9f27dde268ad907421df3ef38e2804969957..17b6e3cfdae5e7c3935b5745c8b2ae2011009a11 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -386,11 +386,12 @@ PreloadContext::is_internal_fd(int fd) const { } void -PreloadContext::protect_user_fds() { +PreloadContext::protect_user_fds(int root_fd) { LOG(DEBUG, "Protecting application fds [{}, {}]", 0, MAX_USER_FDS - 1); - const int nullfd = ::syscall_no_intercept(SYS_open, "/dev/null", O_RDONLY); + const int nullfd = + ::syscall_no_intercept(SYS_openat, root_fd, "/dev/null", O_RDONLY); assert(::syscall_error_code(nullfd) == 0); protected_fds_.set(nullfd); diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e3703d73b50b0d824c219b47b78a9b85ada4d296..4f308da69640d4029e81c2b215957d0428b2a3d1 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -72,6 +72,7 @@ set(DAEMON_LINK_LIBRARIES # margo libs ${ABT_LIBRARIES} mercury + rocksdb ${MARGO_LIBRARIES} # others Threads::Threads