From 1810010093c4997a94e815e834b4c4c650221d88 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Sat, 12 Dec 2020 11:32:40 +0100 Subject: [PATCH] Use default kernel export mechanism when symbol lookup is not available Since kernel 5.7 kallsyms_on_each_symbol() is not available. NOTE: This affects ability to perform upgrade in flight on kernels 5.7+. Signed-off-by: Robert Baldyga --- configure.d/1_kallsyms_on_each_symbol.conf | 31 ++++++++++++++++++++++ modules/cas_cache/main.c | 12 +++++++++ 2 files changed, 43 insertions(+) create mode 100644 configure.d/1_kallsyms_on_each_symbol.conf diff --git a/configure.d/1_kallsyms_on_each_symbol.conf b/configure.d/1_kallsyms_on_each_symbol.conf new file mode 100644 index 0000000..c4e3384 --- /dev/null +++ b/configure.d/1_kallsyms_on_each_symbol.conf @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Copyright(c) 2012-2020 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +. $(dirname $3)/conf_framework + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "kallsyms_on_each_symbol(NULL, NULL)" "linux/fs.h" + then + echo $cur_name "1" >> $config_file_path + else + echo $cur_name "2" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "SYMBOL_LOOKUP_SUPPORTED 1" ;; + "2") + ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/modules/cas_cache/main.c b/modules/cas_cache/main.c index b9850e5..af539f3 100644 --- a/modules/cas_cache/main.c +++ b/modules/cas_cache/main.c @@ -51,6 +51,8 @@ bool in_upgrade; ocf_ctx_t cas_ctx; struct casdsk_functions_mapper casdisk_functions; +#ifdef SYMBOL_LOOKUP_SUPPORTED + struct exported_symbol { char *name; unsigned long addr; @@ -74,6 +76,16 @@ int static cas_find_symbol(void *data, const char *namebuf, return -EINVAL; \ }) +#else + +#include "../cas_disk/cas_disk.h" +#include "../cas_disk/exp_obj.h" +#define cas_lookup_symbol(f) ({ \ + casdisk_functions.f = (void *)f; \ +}) + +#endif + int static cas_casdisk_lookup_funtions(void) { mutex_lock(&module_mutex);