# This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Generic configuration AC_PREREQ(2.59) AC_INIT(lve-kmod, 1.1, umka@sevcity.net) AC_PREFIX_DEFAULT([/usr]) AC_CONFIG_HEADER([src/include/lve_kmod_c.h]) AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET AC_DEFUN([LVE_LINUX_INIT_CONFIG], [ rm -fr config > /dev/null 2>&1 mkdir config cat >config/Makefile <<_ACEOF obj-m := conftest.o modules: \$(MAKE) -C \$(KERNEL_OBJ) M=\`pwd\` KBUILD_MODPOST_WARN=yes KBUILD_MODPOST_NOFINAL=yes modules _ACEOF ]) SYMVERFILE="Module.symvers" MAPFILE="" sym_addr=0 AC_DEFUN([LVE_SYM_ADDR],[ sym_addr=`awk -v sym=$1 -v sym_addr=0 '{if (( \ ($ 2 == "T") || ($ 2 == "t") || ($ 2 == "D") || ($ 2 == "d") || \ ($ 2 == "b")) \ && ($ 3 == sym)) {sym_addr=$ 1;}}END {print "0x"sym_addr;}' $MAPFILE` ]) # New macros for checking various things AC_DEFUN([LVE_LINUX_SYMVER],[ AC_MSG_CHECKING([for symbols file]) if grep -q Modules.symvers $KERNEL/scripts/Makefile.modpost ; then SYMVERFILE=Modules.symvers fi AC_MSG_RESULT([$KERNEL/$SYMVERFILE]) ]) AC_DEFUN([LVE_LINUX_MAPFILE],[ AC_MSG_CHECKING([for map file]) if test -e "$KERNEL/System.map"; then MAPFILE="$KERNEL/System.map" else unm=`${MAKE-make} -s -C $KERNEL_OBJ kernelrelease` if test -e "/boot/System.map-$unm"; then MAPFILE="/boot/System.map-$unm" else # ubuntu unm=`cat ${KERNEL_OBJ}/include/config/kernel.release 2> /dev/null` if test -e "/boot/System.map-$unm"; then MAPFILE="/boot/System.map-$unm" fi fi fi if test -z "$MAPFILE"; then AC_MSG_ERROR([can not find an Mapfile!]) fi AC_MSG_RESULT([$MAPFILE]) ]) # New macros for checking various things AC_DEFUN([LVE_LINUX_CHECK_SYMBOL],[ AC_MSG_CHECKING([for symbol $1 exported]) grep -q -E '[[[:space:]]]$1[[[:space:]]]' $KERNEL/$SYMVERFILE 2>/dev/null rc=$? if test $rc -eq 0; then AC_MSG_RESULT([yes]) $2 else AC_MSG_RESULT([no]) $3 fi ]) AC_DEFUN([LVE_C_PROGRAM], [ #include #include $1 int main (void) { dnl Do *not* indent the following line: there may be CPP directives. dnl Don't move the `;' right after for the same reason. $2 ; return 0; } MODULE_LICENSE("GPL"); ]) AC_DEFUN([LVE_LINUX_COMPILE_IFELSE], [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])]) rm -f config/conftest.o config/conftest.mod.c config/conftest.ko AS_IF([AC_TRY_COMMAND([cp conftest.c config && cd config && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" KERNEL_OBJ=$KERNEL_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS"]) >/dev/null && AC_TRY_COMMAND([$3])], [$4], [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]) rm -f config/conftest.o config/conftest.mod.c config/conftest.mod.o config/conftest.ko m4_ifval([$1], [config/conftest.c conftest.c])[] ]) AC_DEFUN([LVE_LINUX_TRY_COMPILE],[ LVE_LINUX_COMPILE_IFELSE( [AC_LANG_SOURCE([LVE_C_PROGRAM([[$1]], [[$2]])])], [modules], [test -s config/conftest.o], [$3], [$4]) ]) AC_DEFUN([LVE_LINUX_CONFIG], [ LVE_LINUX_TRY_COMPILE([ #ifndef $1 #error $1 not defined #endif ],[ ],[ [$2] AC_MSG_RESULT([$1 defined on kernel config]) ],[ AC_MSG_RESULT([$1 not defined on kernel config]) ]) ]) AC_DEFUN([LVE_LINUX_INCLUDE], [ AC_MSG_CHECKING([$1 exist on kernel]) AS_IF([test -r $KERNEL/include/linux/$1], [ $2 AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) ]) ]) AC_DEFUN([LVE_CRED_EUID_IS_PLAIN],[ AC_MSG_CHECKING([cred->euid is integer]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct cred cred; cred.euid = 0; ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PLAIN_CRED_EUID, 1, [cred->euid is integer]) ],[ AC_MSG_RESULT(no) ]) ]) ### symbols # -- GROUP_KERNEL_ATTACH AC_DEFUN([LVE_SYM_CGROUP_KERNEL_ATTACH],[ AC_MSG_CHECKING([cgroup_kernel_attach exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include #include #include ],[ int (*lve_sym)(struct cgroup *cgrp, struct task_struct *tsk); lve_sym = cgroup_kernel_attach; ],[ LVE_SYM_ADDR(cgroup_kernel_attach) if test $sym_addr != "0x0"; then SYM_CGROUP_KERNEL_ATTACH="_lve_cgroup_kernel_attach = $sym_addr;" fi ],[ sym_addr=0 ]) AC_SUBST([SYM_CGROUP_KERNEL_ATTACH]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM___FPUT],[ AC_MSG_CHECKING([__fput exists in kernel]) LVE_SYM_ADDR(__fput) if test $sym_addr != "0x0"; then SYM___FPUT="__fput = $sym_addr;" AC_DEFINE([HAVE___FPUT], [], [use __fput]) fi AC_SUBST([SYM___FPUT]) AC_MSG_RESULT([$sym_addr]) ]) # -- FIND_TASK_BY_VPID AC_DEFUN([LVE_SYM_FIND_TASK_BY_VPID],[ AC_MSG_CHECKING([find_task_by_vpid exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ struct task_struct *(*lve_sym)(pid_t nr); lve_sym = find_task_by_vpid; ],[ LVE_SYM_ADDR(find_task_by_vpid) if test $sym_addr != "0x0"; then SYM_FIND_TASK_BY_VPID="lve_find_task_by_vpid = $sym_addr;" fi ],[ sym_addr=0 ]) AC_SUBST([SYM_FIND_TASK_BY_VPID]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_DO_EACH_THREAD_ALL],[ AC_MSG_CHECKING([do_each_thread_all in sched.h]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct task_struct *t, *p; do_each_thread_all(t, p) { } while_each_thread_all(t, p); ],[ AC_MSG_RESULT(yes) AC_DEFINE([HAVE_DO_EACH_THREAD_ALL], [], [have do_each_thread_all in sched.h]) ],[ AC_MSG_RESULT(no) ]) ]) # -- CGROUP_ATTACH_TASK AC_DEFUN([LVE_SYM_CGROUP_ATTACH_TASK],[ AC_MSG_CHECKING([cgroup_attach_task exists in kernel]) LVE_SYM_ADDR(cgroup_attach_task) if test $sym_addr != "0x0"; then SYM_CGROUP_ATTACH_TASK="lve_cgroup_attach_task = $sym_addr;" AC_DEFINE([HAVE_CGROUP_ATTACH_TASK], [], [cgroup_attach_task exists]) fi AC_SUBST([SYM_CGROUP_ATTACH_TASK]) AC_MSG_RESULT([$sym_addr]) ]) # -- CGROUP_ATTACH_TASK HAS 2 ARGC AC_DEFUN([LVE_2ARGS_CGROUP_ATTACH_TASK],[ AC_MSG_CHECKING([cgroup_attach_task has 2 args]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ int (*lve_sym)(struct cgroup *cg, struct task_struct *tsk); lve_sym = cgroup_attach_task; ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_2ARGS_CGROUP_ATTACH_TASK, 1, [cgroup_attach_task has 2 args]) ],[ AC_MSG_RESULT(no) ]) ]) # -- CGROUP_MUTEX AC_DEFUN([LVE_SYM_CGROUP_MUTEX],[ AC_MSG_CHECKING([cgroup_mutex exists in kernel]) LVE_SYM_ADDR(cgroup_mutex) if test $sym_addr != "0x0"; then SYM_CGROUP_MUTEX="lve_cgroup_mutex = $sym_addr;" AC_DEFINE(HAVE_CGROUP_MUTEX, [], [cgroup_mutex exists]) fi AC_SUBST([SYM_CGROUP_MUTEX]) AC_MSG_RESULT([$sym_addr]) ]) # -- FREEZER_CHANGE_STATE AC_DEFUN([LVE_SYM_FREEZER_CHANGE_STATE],[ AC_MSG_CHECKING([freezer_change_state exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ int (*lve_sym)(struct cgroup *c, enum freezer_state s); lve_sym = freezer_change_state; ],[ LVE_SYM_ADDR(freezer_change_state) if test $sym_addr != "0x0"; then SYM_FREEZER_CHANGE_STATE="lve_freezer_change_state = $sym_addr;" AC_DEFINE(HAVE_FREEZER_CHANGE_STATE, [], [freezer_change_state exists]) fi ],[ sym_addr=0 ]) AC_SUBST([SYM_FREEZER_CHANGE_STATE]) AC_MSG_RESULT([$sym_addr]) ]) # -- TRY_TO_FREE_MEM_CGROUP_PAGES AC_DEFUN([LVE_SYM_TRY_TO_FREE_MEM_CGROUP_PAGES],[ AC_MSG_CHECKING([try_to_free_mem_cgroup_pages exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ unsigned long (*lve_sym)(struct mem_cgroup *memcg, unsigned long nr_pages, gfp_t gfp_mask, bool noswap); lve_sym = try_to_free_mem_cgroup_pages; ],[ LVE_SYM_ADDR(try_to_free_mem_cgroup_pages) if test $sym_addr != "0x0"; then SYM_TRY_TO_FREE_MEM_CGROUP_PAGES="lve_try_to_free_mem_cgroup_pages = $sym_addr;" AC_DEFINE(HAVE_TRY_TO_FREE_MEM_CGROUP_PAGES, [], [try_to_free_mem_cgroup_pages exists]) fi ],[ sym_addr=0 ]) AC_SUBST([SYM_TRY_TO_FREE_MEM_CGROUP_PAGES]) AC_MSG_RESULT([$sym_addr]) ]) # -- MEM_CGROUP_FROM_CONT AC_DEFUN([LVE_SYM_MEM_CGROUP_FROM_CONT],[ AC_MSG_CHECKING([mem_cgroup_from_cont exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct mem_cgroup *(*lve_sym)(struct cgroup *cont); lve_sym = mem_cgroup_from_cont; ],[ LVE_SYM_ADDR(mem_cgroup_from_cont) if test $sym_addr != "0x0"; then SYM_MEM_CGROUP_FROM_CONT="lve_mem_cgroup_from_cont = $sym_addr;" AC_DEFINE(HAVE_MEM_CGROUP_FROM_CONT, [], [mem_cgroup_from_cont exists]) fi ],[ sym_addr=0 ]) AC_SUBST([SYM_MEM_CGROUP_FROM_CONT]) AC_MSG_RESULT([$sym_addr]) ]) # -- tasklist qwlock vs rwlock AC_DEFUN([LVE_TASKLIST_TYPE],[ AC_MSG_CHECKING([tasklist type]) tmp_flags="$EXTRA_CFLAGS" EXTRA_KCFLAGS="-Werror" LVE_LINUX_TRY_COMPILE([ #include ],[ qwrite_lock(&tasklist_lock); ],[ AC_MSG_RESULT(qrwlock) AC_DEFINE(HAVE_TASKLIST_QRWLOCK, 1, [tasklist is qrwlock]) ],[ AC_MSG_RESULT(rwlock) ]) EXTRA_KCFLAGS="$tmp_flags" ]) AC_DEFUN([LVE_CHECK_1ARG_CGROUP_POST_FORK],[ AC_MSG_CHECKING([cgroup_post_fork has 1 arg]) LVE_LINUX_TRY_COMPILE([ #include ],[ cgroup_post_fork(NULL); ],[ AC_DEFINE(HAVE_CGROUP_POST_FORK_WITH_1ARG, 1, [cgroup_post_fork has 1 arg]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([LVE_CHECK_2ARGS_CGROUP_POST_FORK],[ AC_MSG_CHECKING([cgroup_post_fork has 2 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ cgroup_post_fork(NULL, NULL); ],[ AC_DEFINE(HAVE_CGROUP_POST_FORK_WITH_2ARGS, 1, [cgroup_post_fork has 2 args]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([LVE_CHECK_CASE_PDE_DATA],[ AC_MSG_CHECKING([PDE_DATA has upper case naming]) LVE_LINUX_TRY_COMPILE([ #include ],[ PDE_DATA(NULL); ],[ AC_DEFINE(HAVE_PDE_DATA, 1, [PDE_DATA has upper case naming]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([LVE_SYM_USER_PTRACE_ENABLED],[ AC_MSG_CHECKING([user_ptrace_enabled exists in kernel]) LVE_SYM_ADDR(user_ptrace_enabled) if test $sym_addr != "0x0"; then AC_DEFINE(HAVE_USER_PTRACE_ENABLED, [], [user_ptrace_enabled exists]) fi AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_GET_EMPTY_FILP],[ AC_MSG_CHECKING([get_empty_filp exists in kernel]) LVE_SYM_ADDR(get_empty_filp) if test $sym_addr != "0x0"; then SYM_GET_EMPTY_FILP="lve_get_empty_filp = $sym_addr;" fi AC_SUBST([SYM_GET_EMPTY_FILP]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_FILENAME_LOOKUP],[ AC_MSG_CHECKING([filename_lookup exists in kernel]) LVE_SYM_ADDR(filename_lookup) if test $sym_addr != "0x0"; then SYM_FILENAME_LOOKUP="lve_filename_lookup = $sym_addr;" fi AC_SUBST([SYM_FILENAME_LOOKUP]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_GETNAME_KERNEL],[ AC_MSG_CHECKING([getname_kernel exists in kernel]) LVE_SYM_ADDR(getname_kernel) if test $sym_addr != "0x0"; then SYM_GETNAME_KERNEL="lve_getname_kernel = $sym_addr;" fi AC_SUBST([SYM_GETNAME_KERNEL]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_PUTNAME],[ AC_MSG_CHECKING([putname exists in kernel]) LVE_SYM_ADDR(putname) if test $sym_addr != "0x0"; then SYM_PUTNAME="lve_putname = $sym_addr;" fi AC_SUBST([SYM_PUTNAME]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_ALLOC_EMPTY_FILE_NOACCOUNT],[ AC_MSG_CHECKING([alloc_empty_file_noaccount exists in kernel]) LVE_SYM_ADDR(alloc_empty_file_noaccount) if test $sym_addr != "0x0"; then SYM_ALLOC_EMPTY_FILE_NOACCOUNT="lve_alloc_empty_file_noaccount = $sym_addr;" fi AC_SUBST([SYM_ALLOC_EMPTY_FILE_NOACCOUNT]) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_UNLAZY_WALK],[ AC_MSG_CHECKING([unlazy_walk exists in kernel]) LVE_SYM_ADDR(unlazy_walk) AC_MSG_RESULT([$sym_addr]) ]) AC_DEFUN([LVE_SYM_TRY_TO_UNLAZY],[ AC_MSG_CHECKING([try_to_unlazy replace an unlazy_walk in kernel]) LVE_SYM_ADDR(try_to_unlazy) if test "${sym_addr}" != "0x0" ; then AC_DEFINE(HAVE_TRY_TO_UNLAZY, 1, [try_to_unlazy replace a unlazy_walk]) fi AC_MSG_RESULT([$sym_addr]) ]) # resolve symbols into addresses # todo: add kernel<>symbol present verification, fail if symbol not present # templates for a symbols # symplify with other configure checks AC_DEFUN([LVE_SYMBOLS],[ #common LVE_SYM_FILENAME_LOOKUP LVE_SYM_USER_PTRACE_ENABLED LVE_SYM_GET_EMPTY_FILP LVE_SYM_GETNAME_KERNEL LVE_SYM_PUTNAME LVE_SYM_ALLOC_EMPTY_FILE_NOACCOUNT LVE_SYM_UNLAZY_WALK LVE_SYM_TRY_TO_UNLAZY #el6 LVE_SYM_FREEZER_CHANGE_STATE #el7 LVE_SYM_CGROUP_ATTACH_TASK LVE_2ARGS_CGROUP_ATTACH_TASK LVE_SYM_CGROUP_MUTEX LVE_SYM_TRY_TO_FREE_MEM_CGROUP_PAGES LVE_SYM_MEM_CGROUP_FROM_CONT LVE_SYM___FPUT #un-patched RH LVE_SYM_CGROUP_KERNEL_ATTACH LVE_TASKLIST_TYPE LVE_SYM_FIND_TASK_BY_VPID ]) # Checks for programs. AC_PROG_CC AC_PROG_MAKE_SET # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE # Checks for library functions. # Compiler settings # Other settings AC_MSG_CHECKING([for linux sources dir]) AC_ARG_WITH([kernel], [AC_HELP_STRING([--with-kernel=path], [set path to linux sources])], [KERNEL=$with_kernel], [KERNEL=/lib/modules/`uname -r`/build] ) AC_MSG_RESULT([$KERNEL]) AC_SUBST([KERNEL]) AC_MSG_CHECKING([for linux objects dir]) AC_ARG_WITH([kernel-obj], [AC_HELP_STRING([--with-kernel-obj=path], [set path to linux objects dir])], [KERNEL_OBJ=$with_kernel_obj], [KERNEL_OBJ=$KERNEL] ) AC_MSG_RESULT([$KERNEL_OBJ]) AC_SUBST([KERNEL_OBJ]) AC_MSG_CHECKING([for build id - ]) if test -f dkms.conf; then . ./dkms.conf SWV="$PACKAGE_VERSION" GIT="$PACKAGE_GIT" else BID=$(git describe --tags) SWV=${BID%-*} GIT=$(git log | awk '{print $2; exit}') fi AC_SUBST(SWV) AC_DEFINE_UNQUOTED(SWV, "$SWV", [nearest lve version tag]) AC_DEFINE_UNQUOTED(GIT_HASH, "$GIT", [git hash for build]) AC_SUBST(GIT) AC_MSG_RESULT([$SWV - $GIT]) PWD=$(pwd) PWD="${PWD}/src" if test -d "../common"; then COMMON=$(cd ../common; pwd) else #dkms case COMMON=$(cd common; pwd) fi AC_SUBST(PWD) AC_SUBST(COMMON) DEBUG_FL="-DSTRICT_LA -g" AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug], [enable debug features])], [DEBUG_FL="$DEBUG_FL -DLVE_DEBUG=-1"]) AC_SUBST(DEBUG_FL) LVE_PER_VE="" AC_ARG_ENABLE([lve-per-ve], [AC_HELP_STRING([--enable-lve-per-ve], [enable lve per ve support])], [LVE_PER_VE="-DLVE_PER_VE"]) AC_SUBST(LVE_PER_VE) LVE_LINUX_INIT_CONFIG LVE_LINUX_SYMVER LVE_LINUX_MAPFILE CGROUP=0 OPENVZ=0 rhver=$(awk '/RHEL_MAJOR =/ {print [$]3;}' $KERNEL/Makefile*) AC_MSG_RESULT([RH version $rhver]) LVE_LINUX_CONFIG(CONFIG_CGROUPS, CGROUP=1) LVE_LINUX_CONFIG(CONFIG_BEANCOUNTERS, OPENVZ=$rhver) SYSCTL=0 LVE_LINUX_CONFIG(CONFIG_SYSCTL, SYSCTL=1) AC_SUBST(CGROUP) AC_SUBST(OPENVZ) AC_DEFINE_UNQUOTED([OPENVZ_VERSION], [$OPENVZ], [OpenVZ kernel version]) LVE_DO_EACH_THREAD_ALL LVE_LINUX_CHECK_SYMBOL([proc_root], [AC_DEFINE([HAVE_PROC_ROOT], [], [proc_root exist on kernel])]) LVE_LINUX_CHECK_SYMBOL([loadavg_ptr_init], [AC_DEFINE([HAVE_LOADAVG_PTR], [], [new loadavg hook])]) # -- HAVE_DENTRY_OPEN_PATH AC_MSG_CHECKING([dentry_open uses path as parameter]) LVE_LINUX_TRY_COMPILE([ #include #include #include ],[ struct file *file; file = dentry_open((const struct path *)0, 0, NULL); ],[ AC_DEFINE(HAVE_DENTRY_OPEN_PATH, 1, [dentry_open has path parameter]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_VFS_RENAME_WITH_6ARGS AC_MSG_CHECKING([vfs_rename has 6 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ vfs_rename(NULL, NULL, NULL, NULL, NULL, 0); ],[ AC_DEFINE(HAVE_VFS_RENAME_WITH_6ARGS, 1, [vfs_rename has 6 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_VFS_RENAME_WITH_5ARGS AC_MSG_CHECKING([vfs_rename has 5 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ vfs_rename(NULL, NULL, NULL, NULL, NULL); ],[ AC_DEFINE(HAVE_VFS_RENAME_WITH_5ARGS, 1, [vfs_rename has 5 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_COPY_NS_WITH_2ARGS AC_MSG_CHECKING([copy_namespaces has 2 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ copy_namespaces(0UL, NULL); ],[ AC_DEFINE(HAVE_COPY_NS_WITH_2ARGS, 1, [copy_namespaces has 2 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_COPY_NS_WITH_3ARGS AC_MSG_CHECKING([copy_namespaces has 3 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ copy_namespaces(0UL, NULL, -1); ],[ AC_DEFINE(HAVE_COPY_NS_WITH_3ARGS, 1, [copy_namespaces has 3 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_WAIT_BIT_4ARGS AC_MSG_CHECKING([wait_on_bit have 4 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ wait_on_bit(NULL, 0, NULL, 0); ],[ AC_DEFINE(HAVE_WAIT_BIT_4ARGS, 1, [wait_on_bit have 4 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE_BSEARCH AC_MSG_CHECKING([bsearch exist in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ bsearch(NULL, NULL, 0, 0, NULL); ],[ AC_DEFINE(HAVE_BSEARCH, 1, [bsearch exist in kernel]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE PROC EXIT CONNECTOR AC_MSG_CHECKING([proc_exit_connector properly defined in kernel]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ struct task_struct *tsk = NULL; proc_exit_connector(tsk); ],[ AC_MSG_RESULT([yes]) ],[ AC_MSG_ERROR([no]) ]) # -- HAVE ATOMIC SET MASK AC_MSG_CHECKING([atomic_set_mask defined in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ atomic_t a; atomic_set_mask(0, &a); ],[ AC_DEFINE(HAVE_ATOMIC_SET_MASK, 1, [atomic_set_mask defined in kernel]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE INODE LOCK AC_MSG_CHECKING([inode_lock defined in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ inode_lock(NULL); ],[ AC_DEFINE(HAVE_INODE_LOCK, 1, [inode_lock defined in kernel]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) tmp_flags="$EXTRA_CFLAGS" EXTRA_KCFLAGS="-Werror" # -- HAVE KERNEL READ LAST POSP AC_MSG_CHECKING([kernel_read last arg is *pos]) LVE_LINUX_TRY_COMPILE([ #include ],[ loff_t pos = 0; kernel_read(NULL, NULL, 0, &pos); ],[ AC_DEFINE(HAVE_KERNEL_READ_LAST_POSP, 1, [kernel_read last arg is *pos]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE KERNEL WRITE LAST POSP AC_MSG_CHECKING([kernel_write last arg is *pos]) LVE_LINUX_TRY_COMPILE([ #include ],[ loff_t pos = 0; kernel_write(NULL, NULL, 0, &pos); ],[ AC_DEFINE(HAVE_KERNEL_WRITE_LAST_POSP, 1, [kernel_write last arg is *pos]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) EXTRA_KCFLAGS="$tmp_flags" # -- HAVE SMP MB AFTER CLEAR BIT AC_MSG_CHECKING([smp_mb__after_clear_bit defined in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ smp_mb__after_clear_bit(); ],[ AC_DEFINE(HAVE_SMP_MB__AFTER_CLEAR_BIT, 1, [smp_mb__after_clear_bit is defined]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) # -- HAVE GET USER PAGES REMOTE AC_MSG_CHECKING([get_user_pages_remote defined in kernel]) LVE_SYM_ADDR(get_user_pages_remote) if test $sym_addr != 0; then AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_GET_USER_PAGES_REMOTE, 1, [get_user_pages_remote is defined]) AC_MSG_CHECKING([get_user_pages_remote have 8 args]) LVE_LINUX_TRY_COMPILE([ #include ],[ get_user_pages_remote(NULL, NULL, 0, 0, 0, 0, NULL, NULL); ],[ AC_DEFINE(HAVE_GET_USER_PAGES_REMOTE8, 1, [get_user_pages_remote have 8 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) else AC_MSG_RESULT([no]) fi # -- HAVE_KGDB_GETSYMVAL AC_MSG_CHECKING([kdbgetsymval defined in kernel]) LVE_SYM_ADDR(kdbgetsymval) if test $sym_addr != 0; then AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_KGDB_GETSYMVAL, 1, [kdbgetsymval is defined]) else AC_MSG_ERROR([no]) fi # -- HAVE FSNOTIFY QSTR NAME AC_MSG_CHECKING([fsnotify() takes qstr* name]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct qstr name; memset(&name, 0, sizeof(name)); fsnotify(NULL, 0, NULL, 0, &name, 0); ],[ AC_DEFINE(HAVE_FSNOTIFY_QSTR_NAME, 1, [fsnotify takes qstr*]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) LVE_LINUX_INCLUDE([sched/loadavg.h], [AC_DEFINE(HAVE_SCHED_LOADAVG_H, 1, [sched/loadavg.h defined])] ) LVE_CRED_EUID_IS_PLAIN LVE_CHECK_1ARG_CGROUP_POST_FORK LVE_CHECK_2ARGS_CGROUP_POST_FORK LVE_CHECK_CASE_PDE_DATA AC_MSG_CHECKING([call_usermodehelper_fns exists in kernel]) LVE_LINUX_TRY_COMPILE([ #include ],[ int rc = call_usermodehelper_fns(NULL, NULL, NULL, 0, NULL, NULL, NULL); ],[ AC_DEFINE(HAVE_UMH_OLD, 1, [usermodehelper uses an old API]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([rwsem->owner is atomic]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct rw_semaphore *sem; void *owner; owner = atomic_long_read(&sem->owner); ],[ AC_DEFINE(HAVE_OWNER_ATOMIC, 1, [rwsem owner is atomic]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) LVE_LINUX_INCLUDE([sched/signal.h], [AC_DEFINE(HAVE_SCHED_SIGNAL_H, 1, [sched/signal.h defined])] ) AC_MSG_CHECKING([force_sig 2 args]) LVE_LINUX_TRY_COMPILE([ #include #ifdef HAVE_SCHED_SIGNAL_H #include #endif ],[ force_sig(0, NULL); ],[ AC_DEFINE(HAVE_FORCE_SIG, 1, [force_sig have a task argument]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([sched stat is pointer]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct task_struct *task = NULL; struct sched_statistics *stats = task->se.statistics; stats = NULL; ],[ AC_DEFINE(HAVE_SCHED_STAT_PTR, 1, [sched stats is pointer]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([cgroup root have actual_subsys_mask]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct cgroup_root *root; root->actual_subsys_mask = 0; ],[ AC_DEFINE(HAVE_CGROUP_ACTUAL_SUBSYS_MASK, 1, [cgroup root have actual_subsys_mask]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([inode lock is rwsem]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct inode *i; down_write(&i->i_rwsem); ],[ AC_DEFINE(HAVE_I_RWSEM, 1, [inode have an i_rwsem]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([fsnotify_nameremove present]) LVE_LINUX_TRY_COMPILE([ #include ],[ fsnotify_nameremove(NULL, 0); ],[ AC_DEFINE(HAVE_FSNOTIFY_NAMEREMOTE, 1, [fsnotify_nameremove present]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([cgroupfs exist]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct cgroupfs_root root; ],[ AC_DEFINE(HAVE_CGOUPFS, 1, [cgroupfs_root exist]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([vfs_rmdir want a usernamespace argument]) LVE_LINUX_TRY_COMPILE([ #include ],[ vfs_rmdir(NULL, NULL, NULL); ],[ AC_DEFINE(HAVE_VFS_RMDIR_3ARG, 1, [vfs_rmdir have a namespace arg]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([renamedata present]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct renamedata data; ],[ AC_DEFINE(HAVE_RENAMEDATA, 1, [renamedata present]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([fstrace_regs present]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct ftrace_regs data; ],[ AC_DEFINE(HAVE_FTRACE_REGS, 1, [ftrace_regs present]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([FTRACE_OPS_FL_RECURSION exists]) LVE_LINUX_TRY_COMPILE([ #include ],[ int a = FTRACE_OPS_FL_RECURSION; ],[ AC_DEFINE(HAVE_FTRACE_OPS_FL_RECURSION, 1, [new name]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([proc_ops exists]) LVE_LINUX_TRY_COMPILE([ #include #include ],[ struct proc_ops name; name.proc_open = NULL; ],[ AC_DEFINE(HAVE_PROC_OPS, 1, [proc_ops exist]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([schedstats in task]) LVE_LINUX_TRY_COMPILE([ #include ],[ struct task_struct *task = NULL; struct sched_statistics *stat = &task->stats; ],[ AC_DEFINE(HAVE_TASK_STAT, 1, [schedstats in stat]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([fsnotify() 7args]) LVE_LINUX_TRY_COMPILE([ #include ],[ fsnotify(0, NULL, 0, NULL, NULL, NULL, 0); ],[ AC_DEFINE(HAVE_FSNOTIFY_7ARGS, 1, [fsnotify have 7 args]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([LOOKUP_JUMPED exist]) LVE_LINUX_TRY_COMPILE([ #include ],[ #ifndef LOOKUP_JUMPED #error "new flags" #endif ],[ AC_DEFINE(HAVE_LOOKUP_FLAGS, 1, [LOOKUP_JUMPED is public]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([ktime_get_seconds() exist]) LVE_LINUX_TRY_COMPILE([ #include ],[ ktime_get_seconds(); ],[ AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1, [ktime_get_seconds exists]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([compat_alloc_user_space exist]) LVE_LINUX_TRY_COMPILE([ #include ],[ void *a = compat_alloc_user_space(10); ],[ AC_DEFINE(HAVE_COMPAT_ALLOC, 1, [compat_alloc_user_space exist]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([iomap_dio_rw is exported]) LVE_LINUX_TRY_COMPILE([ #include ],[ ssize_t (*i_d_rw)(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, unsigned int dio_flags, size_t done_before); i_d_rw = iomap_dio_rw; ],[ AC_DEFINE(HAVE_IOMAP_DIO_RW, 1, [iomap_dio_rw is exported]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([trace_block_rq_issue has 1 arg]) LVE_LINUX_TRY_COMPILE([ #include ],[ trace_block_rq_issue(NULL); ],[ AC_DEFINE(HAVE_RQ_ISSUE_1ARG, 1, [trace_block_rq_issue has 1 arg]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) AC_MSG_CHECKING([trace_writeback_dirty_folio is defined]) LVE_LINUX_TRY_COMPILE([ #include ],[ trace_writeback_dirty_folio(NULL, NULL); ],[ AC_DEFINE(HAVE_WRITEBACK_DIRTY_FOLIO, 1, [trace_writeback_dirty_folio is defined]) AC_MSG_RESULT([yes]) ],[ AC_MSG_RESULT([no]) ]) LVE_SYMBOLS if test "${OPENVZ}" -ne 0; then LVE_OPENVZ fi LVE_LSM AC_DEFINE_UNQUOTED(FEAT_SYSCTL, $SYSCTL, [sysctl settings support in module]) AC_DEFINE(FEAT_IOLIMIT, 1, [iolimit enabled]) AC_DEFINE(FEAT_LINK_PROT, 1, [syslink protect enabled]) AC_MSG_CHECKING([do last/open_last addr ]) LVE_SYM_ADDR(do_last) do_last_addr=$sym_addr if test "${sym_addr}" == "0x0" ; then LVE_SYM_ADDR(open_last_lookups) do_last_addr=$sym_addr if test "${sym_addr}" != "0x0" ; then AC_DEFINE(HAVE_OPEN_LAST, 1, [open_last_lookups present]) fi fi AC_MSG_RESULT([$symaddr]) # rhel7 don't have a special features enabled if test "0${rhver}" -eq 7; then AC_DEFINE(IMPL_LINK_PROT_OLD, 1, [syslink protect: implementation for older kernels up to 3.10]) fi if test "0${rhver}" -eq 8; then AC_DEFINE(FEAT_DC, 1, [have a DC connected to enable]) AC_DEFINE(FEAT_PROC_PROT, 1, [procfs filter enabled]) AC_DEFINE(FEAT_XFS_QUOTA, 1, [have an XFS CAP_RESOURCE hack]) #### The condition is commented out due to it breaks the kmodlve for cl8 gcov kernel. ## Supposedly we expected that if the kernel has do_last or open_last_lookups symbols ## its version is around 5.* and it needs the EXPERIMENTAL SP implementation that was ## initially implemented for the 5.* kernel in Ubuntu. ## Now we got the 5.* kernel in CL9 and the do_last symbol not optimized out ## in CL8 gcov 4.* kernel (so it falsely thinks we deal with CL9/Ubuntu/5.* kernels). ## So we have to actualize the description of the SP implementations macros and check if ## it's possible that the EXPERIMENTAL implementation will be needed for CL8. ## ## https://cloudlinux.atlassian.net/browse/CLKRN-1355 - the task for the investigation / fix CL9 #if test $do_last_addr != "0x0"; then # AC_DEFINE(IMPL_LINK_PROT_EXPERIMENTAL, 1, [syslink protect: experimental implementation for Ubuntu only]) #else AC_DEFINE(IMPL_LINK_PROT_NEW, 1, [syslink protect: implementation for newer kernels starting from 4.x]) #fi fi if test "0${rhver}" -eq 9; then AC_DEFINE(FEAT_DC, 1, [have a DC connected to enable]) AC_DEFINE(FEAT_PROC_PROT, 1, [procfs filter enabled]) AC_DEFINE(FEAT_XFS_QUOTA, 1, [have an XFS CAP_RESOURCE hack]) if test $do_last_addr != "0x0"; then AC_DEFINE(IMPL_LINK_PROT_EXPERIMENTAL, 1, [syslink protect: experimental implementation for Ubuntu only]) else AC_DEFINE(FEAT_LINK_PROT, 0, [syslink protect disabled]) fi fi # let's identify Ubuntu case here (anything non-RH is considered Ubuntu) if test "0${rhver}" -eq 0; then AC_DEFINE(FEAT_DC, 1, [have a DC connected to enable]) AC_DEFINE(FEAT_PROC_PROT, 1, [procfs filter enabled]) AC_DEFINE(FEAT_XFS_QUOTA, 1, [have an XFS CAP_RESOURCE hack]) if test $do_last_addr != "0x0"; then AC_DEFINE(IMPL_LINK_PROT_EXPERIMENTAL, 1, [syslink protect: experimental implementation for Ubuntu only]) fi fi # Output AC_CONFIG_FILES([src/Makefile src/mod_info.h]) AC_OUTPUT