Verified Commit 4f27316d authored by Ramon Nou's avatar Ramon Nou Committed by Marc Vef
Browse files

Added arm profile

parent 339ae3bd
Loading
Loading
Loading
Loading
+148 −0
Original line number Diff line number Diff line
From dc462223c52f97e94464eb597e1af9ab961aa781 Mon Sep 17 00:00:00 2001
From: sktzwhj <whj_nudt@foxmail.com>
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
+83 −0
Original line number Diff line number Diff line
################################################################################
# Copyright 2018-2021, Barcelona Supercomputing Center (BSC), Spain            #
# Copyright 2015-2021, 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 <https://www.gnu.org/licenses/>.            #
#                                                                              #
# 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="Dependencies for PowerPC supercomputer"

# Dependencies that must be downloaded directly
wgetdeps=(
    ["lz4"]="1.9.3"
    ["capstone"]="4.0.2"
    ["argobots"]="1.1"
    ["rocksdb"]="6.26.1"
    ["psm2"]="11.2.185"
    ["json-c"]="0.15-20200726"
)

# Dependencies that must be cloned
clonedeps=(
    ["libfabric"]="HEAD@v1.13.2"
    ["mercury"]="v2.1.0"
    ["margo"]="v0.9.6"
    ["syscall_intercept"]="fb73c3924b502e2840a5dc8a18746e395b06a8a6"
    ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155"
)

# Extra arguments for git clone
clonedeps_args=(
    ["mercury"]="--recurse-submodules"
)

# Patches that should be applied post-clone
clonedeps_patches=(
    ["syscall_intercept"]="syscall_intercept.patch.arm64"
)

# Ordering that MUST be followed when downloading
order=(
    "lz4" "capstone" "json-c" "psm2" "libfabric" "mercury" "argobots" "margo" "rocksdb" "syscall_intercept" "date" 
)

# 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=(
    ["libfabric"]="--enable-psm2=no --enable-sockets=yes"
    ["syscall_intercept"]="ARM"
)
+11 −1
Original line number Diff line number Diff line
@@ -46,14 +46,24 @@
pkg_install() {
    ID="syscall_intercept"
    CURR="${SOURCE_DIR}/${ID}"
    EXTRA_INSTALL_ARGS="${PROFILE_EXTRA_INSTALL_ARGS[${ID}]}"
    prepare_build_dir "${CURR}"
    if [[ ${EXTRA_INSTALL_ARGS} == "ARM" ]]; then
        cd "${CURR}"/arch/aarch64/
        mkdir -p build
        cd build
    else    
        cd "${CURR}"/build
    fi
    $CMAKE -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" \
    -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
    -DCMAKE_BUILD_TYPE:STRING=Debug \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTS:BOOK=OFF ..
    make -j"${CORES}" install
    if [[ ${EXTRA_INSTALL_ARGS} == "ARM" ]]; then
        cp "${CURR}"/arch/aarch64/include/libsyscall_intercept_hook_point.h ${INSTALL_DIR}/include
    fi
}

pkg_check() {
+12 −0
Original line number Diff line number Diff line
######## Installing:  lz4 ###############################
######## Installing:  capstone ###############################
######## Installing:  json-c ###############################
######## Installing:  psm2 ###############################
WARNING: Install script for 'psm2' not found. Skipping.
######## Installing:  libfabric ###############################
######## Installing:  mercury ###############################
######## Installing:  argobots ###############################
######## Installing:  margo ###############################
######## Installing:  rocksdb ###############################
######## Installing:  syscall_intercept ###############################
######## Installing:  date ###############################
+12 −0
Original line number Diff line number Diff line
Downloaded 'https://github.com/lz4/lz4/archive/v1.9.3.tar.gz' to 'lz4'
Downloaded 'https://github.com/aquynh/capstone/archive/4.0.2.tar.gz' to 'capstone'
Downloaded 'https://github.com/json-c/json-c/archive/json-c-0.15-20200726.tar.gz' to 'json-c'
Downloaded 'https://github.com/intel/opa-psm2/archive/PSM2_11.2.185.tar.gz' to 'psm2'
Cloned 'https://github.com/ofiwg/libfabric.git' to 'libfabric' with commit '[HEAD]' and flags '--branch=v1.13.2'
Cloned 'https://github.com/mercury-hpc/mercury' to 'mercury' with commit '[v2.1.0]' and flags '--recurse-submodules'
Downloaded 'https://github.com/pmodels/argobots/archive/v1.1.tar.gz' to 'argobots'
Cloned 'https://github.com/mochi-hpc/mochi-margo' to 'margo' with commit '[v0.9.6]' and flags ''
Downloaded 'https://github.com/facebook/rocksdb/archive/v6.26.1.tar.gz' to 'rocksdb'
Cloned 'https://github.com/GekkoFS/syscall_intercept.git' to 'syscall_intercept' with commit '[fb73c3924b502e2840a5dc8a18746e395b06a8a6]' and flags ''
Cloned 'https://github.com/HowardHinnant/date.git' to 'date' with commit '[e7e1482087f58913b80a20b04d5c58d9d6d90155]' and flags ''
Done