Draft: Resolve "ARM support"

  • arm64 support
  • Better accommodation for other CPU architectures for scripts, profiles, and code
  • Investigate why tests fail

Closes #190

Edited by Marc Vef

Merge request reports

Loading
+1 −1
Changes for include/client/preload_context.hpp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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();
+148 −0
Changes for scripts/patches/syscall_intercept.patch.arm64: 148 added lines, 0 removed lines.
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
+1 −1
Changes for scripts/profiles/0.9.0/install/rocksdb.install: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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 \
+5 −1
Changes for scripts/profiles/0.9.0/install/syscall_intercept.install: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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 \
+2 −2
Changes for scripts/profiles/0.9.0/agios.specs: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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
Loading
Loading