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

architecture compilation for syscall_intercept

parent fd5d2a19
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -41,12 +41,14 @@ to I/O, which reduces interferences and improves performance."""
    variant('guided_distributor', default=False, description='Enables the guided distributor.')
    # variant('prometheus', default=False, description='Enables Prometheus support for statistics.')
    variant('dedicated_psm2', default=False, description='Use dedicated _non-system_ opa-psm2 version 11.2.185.')

    variant('compile', default='x86', multi=False, values=('x86','powerpc','arm'), description='Architecture to compile syscall intercept.')
    # general dependencies
    depends_on('cmake@3.6.0:', type='build')
    depends_on('lz4', when='@0.8:')
    depends_on('argobots')
    depends_on('syscall-intercept')
    depends_on('syscall-intercept@arm', when='compile=arm')
    depends_on('syscall-intercept@powerpc', when='compile=powerpc')
    depends_on('syscall-intercept@x86', when='compile=x86')
    depends_on('date cxxstd=14 +shared +tz tzdb=system')
    depends_on('opa-psm2@11.2.185', when='+dedicated_psm2')
    # 0.8.0 specific
+17 −3
Original line number Diff line number Diff line
@@ -9,13 +9,27 @@ from spack import *
class SyscallIntercept(CMakePackage):
    """FIXME: Put a proper description of your package here."""

    homepage = "https://github.com/pmem/syscall_intercept"
    git      = "https://github.com/pmem/syscall_intercept.git"
    homepage = "https://github.com/GekkoFS/syscall_intercept"
    git      = "https://github.com/GekkoFS/syscall_intercept.git"

    maintainers = ['jeanbez']

    version('304404', commit='304404581c57d43478438d175099d20260bae74e')
    version('x86', branch='master')
    version('powerpc', branch='powerpc')
    version('arm', branch='arm')

    depends_on('capstone@4.0.1')

    with when('@arm'):
        patch('syscall-intercept-arm.patch')

    with when('@x86'):
        patch('syscall-intercept.patch')

    @property
    def root_cmakelists_dir(self):
        if self.version==Version('arm'):
            return "arch/aarch64"
        else:
            return self.stage.source_path
+107 −0
Original line number Diff line number Diff line
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 };