From fb321206590906d04a4158edeb96d9896fd0621a Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Sat, 2 Apr 2016 15:43:35 -0400 Subject: [PATCH] make mcoverlayfs optional (default: enabled) --- arch/x86/tools/mcreboot-smp-x86.sh.in | 3 ++- configure | 23 +++++++++++++++++++++++ configure.ac | 14 ++++++++++++++ executer/config.h.in | 3 +++ executer/kernel/mcoverlayfs/Makefile.in | 9 +++++++-- executer/user/mcexec.c | 6 +++++- 6 files changed, 54 insertions(+), 4 deletions(-) diff --git a/arch/x86/tools/mcreboot-smp-x86.sh.in b/arch/x86/tools/mcreboot-smp-x86.sh.in index 74ce951d..27abe1a8 100644 --- a/arch/x86/tools/mcreboot-smp-x86.sh.in +++ b/arch/x86/tools/mcreboot-smp-x86.sh.in @@ -17,6 +17,7 @@ BINDIR="@BINDIR@" SBINDIR="@SBINDIR@" KMODDIR="@KMODDIR@" KERNDIR="@KERNDIR@" +ENABLE_MCOVERLAYFS="@ENABLE_MCOVERLAYFS@" INTERVAL=1 LOGMODE=0 @@ -59,7 +60,7 @@ cpus="" ihk_ikc_irq_core=0 kernel_release=`uname -r` -enable_mcoverlay=`if [[ ${kernel_release} =~ ^4.* ]]; then echo "yes"; fi` +enable_mcoverlay=`if [[ ${kernel_release} =~ ^4.* && "${ENABLE_MCOVERLAYFS}" == "yes" ]]; then echo "yes"; fi` if [ "$cpus" == "" ]; then diff --git a/configure b/configure index 13ebef98..7aa92998 100755 --- a/configure +++ b/configure @@ -628,6 +628,7 @@ IHK_RELEASE_DATE DCFA_VERSION MCKERNEL_VERSION IHK_VERSION +ENABLE_MCOVERLAYFS MANDIR KERNDIR KMODDIR @@ -693,6 +694,7 @@ with_target with_system_map enable_dcfa enable_memdump +enable_mcoverlayfs ' ac_precious_vars='build_alias host_alias @@ -1314,6 +1316,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-dcfa Enable DCFA modules --enable-memdump enable dumping memory and analyzing a dump + --enable-mcoverlayfs enable mcoverlayfs implementation Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -2100,6 +2103,14 @@ else fi +# Check whether --enable-mcoverlayfs was given. +if test "${enable_mcoverlayfs+set}" = set; then : + enableval=$enable_mcoverlayfs; ENABLE_MCOVERLAYFS=$enableval +else + ENABLE_MCOVERLAYFS=yes +fi + + case "X$WITH_KERNELSRC" in Xyes | Xno | X) WITH_KERNELSRC='/lib/modules/`uname -r`/build' @@ -3817,6 +3828,18 @@ $as_echo "$as_me: memdump feature is disabled" >&6;} uncomment_if_ENABLE_MEMDUMP='#' fi +if test "x$ENABLE_MCOVERLAYFS" = "xyes" ; then + +$as_echo "#define ENABLE_MCOVERLAYFS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: mcoverlayfs is enabled" >&5 +$as_echo "$as_me: mcoverlayfs is enabled" >&6;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: mcoverlayfs is disabled" >&5 +$as_echo "$as_me: mcoverlayfs is disabled" >&6;} +fi + + diff --git a/configure.ac b/configure.ac index 78b011c6..d6c773d6 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,12 @@ AC_ARG_ENABLE([memdump], [ENABLE_MEMDUMP=$enableval], [ENABLE_MEMDUMP=default]) +AC_ARG_ENABLE([mcoverlayfs], + AC_HELP_STRING([--enable-mcoverlayfs], + [enable mcoverlayfs implementation]), + [ENABLE_MCOVERLAYFS=$enableval], + [ENABLE_MCOVERLAYFS=yes]) + case "X$WITH_KERNELSRC" in Xyes | Xno | X) WITH_KERNELSRC='/lib/modules/`uname -r`/build' @@ -257,6 +263,13 @@ else uncomment_if_ENABLE_MEMDUMP='#' fi +if test "x$ENABLE_MCOVERLAYFS" = "xyes" ; then + AC_DEFINE([ENABLE_MCOVERLAYFS],[1],[whether mcoverlayfs is enabled]) + AC_MSG_NOTICE([mcoverlayfs is enabled]) +else + AC_MSG_NOTICE([mcoverlayfs is disabled]) +fi + AC_SUBST(CC) AC_SUBST(XCC) AC_SUBST(ARCH) @@ -267,6 +280,7 @@ AC_SUBST(SBINDIR) AC_SUBST(KMODDIR) AC_SUBST(KERNDIR) AC_SUBST(MANDIR) +AC_SUBST(ENABLE_MCOVERLAYFS) AC_SUBST(IHK_VERSION) AC_SUBST(MCKERNEL_VERSION) diff --git a/executer/config.h.in b/executer/config.h.in index f0154b3f..03471096 100644 --- a/executer/config.h.in +++ b/executer/config.h.in @@ -1,5 +1,8 @@ /* executer/config.h.in. Generated from configure.ac by autoheader. */ +/* whether mcoverlayfs is enabled */ +#undef ENABLE_MCOVERLAYFS + /* whether memdump feature is enabled */ #undef ENABLE_MEMDUMP diff --git a/executer/kernel/mcoverlayfs/Makefile.in b/executer/kernel/mcoverlayfs/Makefile.in index ce711014..13c9236b 100644 --- a/executer/kernel/mcoverlayfs/Makefile.in +++ b/executer/kernel/mcoverlayfs/Makefile.in @@ -2,9 +2,14 @@ KDIR ?= @KDIR@ ARCH ?= @ARCH@ KMODDIR=@KMODDIR@ src = @abs_srcdir@ +ENABLE_MCOVERLAYFS=@ENABLE_MCOVERLAYFS@ -RELEASE=$(shell uname -r) -ENABLE_BUILD=$(shell if [[ ${RELEASE} =~ ^4.* ]]; then echo "yes"; fi) +RELEASE=$(shell uname -r | cut -d"." -f1) +ifeq ($(ENABLE_MCOVERLAYFS),yes) +ENABLE_BUILD=$(shell if [ "${RELEASE}" == "4" ]; then echo "yes"; fi) +else +ENABLE_BUILD=no +endif obj-m += mcoverlay.o diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index a49ccf54..fd40612b 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -1089,6 +1089,7 @@ void init_worker_threads(int fd) pthread_barrier_wait(&init_ready); } +#ifdef ENABLE_MCOVERLAYFS #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) #define READ_BUFSIZE 1024 static int isunshare(void) @@ -1162,6 +1163,7 @@ static int isunshare(void) return err; } #endif +#endif // ENABLE_MCOVERLAYFS #define MCK_RLIMIT_AS 0 #define MCK_RLIMIT_CORE 1 @@ -1349,6 +1351,7 @@ int main(int argc, char **argv) return 1; } +#ifdef ENABLE_MCOVERLAYFS #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) __dprintf("mcoverlay enable\n"); char mcos_procdir[PATH_MAX]; @@ -1397,9 +1400,10 @@ int main(int argc, char **argv) } else if (error == -1) { return 1; } +#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) #else __dprintf("mcoverlay disable\n"); -#endif +#endif // ENABLE_MCOVERLAYFS if (lookup_exec_path(argv[optind], path, sizeof(path)) != 0) { fprintf(stderr, "error: finding file: %s\n", argv[optind]);