Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2019-02-06 14:12:44 +0100
committerMiroslav Benes <mbenes@suse.cz>2019-02-13 13:00:05 +0100
commite3a42b78ba0dfd71fa8f3c430ca0bf3bf68f4061 (patch)
tree952c254879ec4fe3135bdf77d3c22792f532f85f
parent3efd3305217e72214db1cde3dbbae5c3704850e6 (diff)
Define macros to switch easily between klp-convert and kallsyms
Kallsyms trick does not have to be used for resolving undefined symbols when klp-convert is available. It would be great though to share live patches sources between both modes of operation. Define macros to help with the task. Their definitions depend on whether USE_KLP_CONVERT macro is defined. tar-up.sh script is responsible to decide. Signed-off-by: Miroslav Benes <mbenes@suse.cz> Reviewed-by: Nicolai Stange <nstange@suse.de>
-rw-r--r--klp_convert.h16
-rw-r--r--rpm/kernel-livepatch.spec2
-rwxr-xr-xscripts/register-patches.sh4
-rwxr-xr-xscripts/tar-up.sh2
4 files changed, 22 insertions, 2 deletions
diff --git a/klp_convert.h b/klp_convert.h
new file mode 100644
index 0000000..587c775
--- /dev/null
+++ b/klp_convert.h
@@ -0,0 +1,16 @@
+#ifndef _KLP_KLPCONVERT_H
+#define _KLP_KLPCONVERT_H
+
+#ifdef USE_KLP_CONVERT
+
+#define KLP_SYM_LINKAGE extern
+#define KLP_SYM(sym) sym
+
+#else
+
+#define KLP_SYM_LINKAGE static
+#define KLP_SYM(sym) (*klp_##sym)
+
+#endif
+
+#endif
diff --git a/rpm/kernel-livepatch.spec b/rpm/kernel-livepatch.spec
index 2f5d713..3ba0652 100644
--- a/rpm/kernel-livepatch.spec
+++ b/rpm/kernel-livepatch.spec
@@ -34,6 +34,7 @@ Source4: source-timestamp
Source5: shadow.h
Source6: kallsyms_relocs.h
Source7: kallsyms_relocs.c
+Source8: klp_convert.h
@@KLP_PATCHES_SOURCES@@
BuildRequires: kernel-syms kernel-livepatch-tools-devel libelf-devel
%if 0%{?use_klp_convert}
@@ -55,6 +56,7 @@ cp %_sourcedir/shadow.h .
cp %_sourcedir/kallsyms_relocs.h .
cp %_sourcedir/kallsyms_relocs.c .
cp %_sourcedir/Makefile .
+cp %_sourcedir/klp_convert.h .
%build
sed -i 's/@@RPMRELEASE@@/%module_num/g' Makefile
diff --git a/scripts/register-patches.sh b/scripts/register-patches.sh
index 1a53baa..ada6c7c 100755
--- a/scripts/register-patches.sh
+++ b/scripts/register-patches.sh
@@ -264,8 +264,8 @@ EOF
# Finish kernel-livepatch.spec:
## Enumerate the per subpatch source *.tar.bz2.
-## Note: Start with Source8
-S=8
+## Note: Start with Source9
+S=9
## First check that none of the to be occupied Source<n> slots has
## been used already.
for i in "${!livepatches[@]}"; do
diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh
index 422b369..fa3c328 100755
--- a/scripts/tar-up.sh
+++ b/scripts/tar-up.sh
@@ -76,6 +76,7 @@ install -m 644 livepatch_main.c $build_dir
install -m 644 shadow.h $build_dir
install -m 644 kallsyms_relocs.h $build_dir
install -m 644 kallsyms_relocs.c $build_dir
+install -m 644 klp_convert.h $build_dir
install -m 644 rpm/kernel-livepatch.spec $build_dir/kernel-livepatch-"$RELEASE".spec
scripts/register-patches.sh $build_dir/livepatch_main.c $build_dir/kernel-livepatch-"$RELEASE".spec
install -m 644 rpm/config.sh $build_dir/config.sh
@@ -115,6 +116,7 @@ parse_release() {
rel=($(parse_release $RELEASE))
if [[ -n "${rel[0]##*Test*}" && ${rel[0]} -eq 15 && ${rel[1]} -eq 1 ]]; then
sed -i "s/@@USE_KLP_CONVERT@@/%define use_klp_convert 1/" $build_dir/kernel-livepatch-"$RELEASE".spec
+ sed -i "/^KDIR/a ccflags-y := -DUSE_KLP_CONVERT" $build_dir/Makefile
else
sed -i "s/@@USE_KLP_CONVERT@@//" $build_dir/kernel-livepatch-"$RELEASE".spec
fi