Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2019-02-13 15:40:50 +0100
committerMiroslav Benes <mbenes@suse.cz>2019-02-13 15:40:50 +0100
commit7c613c395877b3ee09a9fbfaa7fba88c09f99805 (patch)
tree999063627ebea4a354e59ed71d3d49543f583231
parent4750a48b8af0f8700c57c951cd89147871a4a9a0 (diff)
parent4c9eb70c86cceee420856573ea1e21835c92980b (diff)
Merge branch 'master-livepatch' into master-livepatch-sle12
Conflicts: rpm/kgraft-patch.spec scripts/tar-up.sh
-rw-r--r--klp_convert.h16
-rw-r--r--rpm/kgraft-patch.spec14
-rwxr-xr-xscripts/register-patches.sh4
-rwxr-xr-xscripts/tar-up.sh16
-rw-r--r--uname_patch/livepatch_uname.c10
-rw-r--r--uname_patch/livepatch_uname.h5
6 files changed, 60 insertions, 5 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/kgraft-patch.spec b/rpm/kgraft-patch.spec
index d696bc0..d2c4e47 100644
--- a/rpm/kgraft-patch.spec
+++ b/rpm/kgraft-patch.spec
@@ -17,6 +17,8 @@
# needssslcertforbuild
+@@USE_KLP_CONVERT@@
+
Name: kgraft-patch-@@RELEASE@@
Version: 1
Release: 1
@@ -32,8 +34,12 @@ Source4: source-timestamp
Source5: shadow.h
Source6: kallsyms_relocs.h
Source7: kallsyms_relocs.c
+Source8: klp_convert.h
@@KLP_PATCHES_SOURCES@@
BuildRequires: kernel-syms kgraft-devel libelf-devel
+%if 0%{?use_klp_convert}
+BuildRequires: kernel-default-kgraft-devel
+%endif
ExclusiveArch: ppc64le x86_64
%kgraft_module_package
@@ -50,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
@@ -64,6 +71,13 @@ for flavor in %flavors_to_build; do
mkdir -p "obj/$flavor"
cp -r "$@" "obj/$flavor"
make -C %{kernel_source $flavor} M="$PWD/obj/$flavor" modules
+
+ %if 0%{?use_klp_convert}
+ module=$(find "obj/$flavor" -name 'kgraft[-_]patch*.ko' -printf '%f')
+ klp-convert /usr/src/linux-obj/%_target_cpu/$flavor/Symbols.list \
+ obj/$flavor/$module obj/$flavor/${module}_converted
+ mv obj/$flavor/${module}_converted obj/$flavor/$module
+ %endif
done
%install
diff --git a/scripts/register-patches.sh b/scripts/register-patches.sh
index 62e5370..a827068 100755
--- a/scripts/register-patches.sh
+++ b/scripts/register-patches.sh
@@ -264,8 +264,8 @@ EOF
# Finish kgraft-patch.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 5a07ad9..6c7a0ed 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/kgraft-patch.spec $build_dir/kgraft-patch-"$RELEASE".spec
scripts/register-patches.sh $build_dir/livepatch_main.c $build_dir/kgraft-patch-"$RELEASE".spec
install -m 644 rpm/config.sh $build_dir/config.sh
@@ -104,3 +105,18 @@ sed -i \
# changelog
changelog=$build_dir/kgraft-patch-"$RELEASE".changes
scripts/gitlog2changes.pl HEAD -- > "$changelog"
+
+# klp-convert
+parse_release() {
+ echo "$1" | \
+ sed 's/SLE\([0-9]\+\)\(-SP\([0-9]\+\)\)\?_Update_\([0-9]\+\)/\1,\3,\4/' | \
+ awk -F, '{ print $1 " " ($2 ? $2 : 0) " " $3 }'
+}
+
+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/kgraft-patch-"$RELEASE".spec
+ sed -i "/^KDIR/a ccflags-y := -DUSE_KLP_CONVERT" $build_dir/Makefile
+else
+ sed -i "s/@@USE_KLP_CONVERT@@//" $build_dir/kgraft-patch-"$RELEASE".spec
+fi
diff --git a/uname_patch/livepatch_uname.c b/uname_patch/livepatch_uname.c
index 4ca603a..84a12f4 100644
--- a/uname_patch/livepatch_uname.c
+++ b/uname_patch/livepatch_uname.c
@@ -33,6 +33,8 @@
#include <linux/string.h>
#include <asm/uaccess.h>
+#include "klp_convert.h"
+
#ifdef COMPAT_UTS_MACHINE
#define override_architecture(name) \
(personality(current->personality) == PER_LINUX32 && \
@@ -76,7 +78,7 @@ static int override_release(char __user *release, size_t len)
char *klp_tag="/lp-@@GITREV@@";
-static struct rw_semaphore *klp_uts_sem;
+KLP_SYM_LINKAGE struct rw_semaphore KLP_SYM(uts_sem);
static int override_version(char __user *version, size_t len, char *klp_version)
{
@@ -111,10 +113,10 @@ asmlinkage long klp_sys_newuname(struct new_utsname __user *name)
struct new_utsname tmp;
char klp_version[65] = { 0 };
- down_read(klp_uts_sem);
+ down_read(&KLP_SYM(uts_sem));
memcpy(&tmp, utsname(), sizeof(tmp));
memcpy(klp_version, utsname()->version, sizeof(utsname()->version));
- up_read(klp_uts_sem);
+ up_read(&KLP_SYM(uts_sem));
if (copy_to_user(name, &tmp, sizeof(tmp)))
return -EFAULT;
@@ -127,6 +129,7 @@ asmlinkage long klp_sys_newuname(struct new_utsname __user *name)
return 0;
}
+#ifndef USE_KLP_CONVERT
int klp_patch_uname_init(void)
{
unsigned long addr;
@@ -140,3 +143,4 @@ int klp_patch_uname_init(void)
return 0;
}
+#endif
diff --git a/uname_patch/livepatch_uname.h b/uname_patch/livepatch_uname.h
index ccfd6c5..eecbcac 100644
--- a/uname_patch/livepatch_uname.h
+++ b/uname_patch/livepatch_uname.h
@@ -3,7 +3,12 @@
#include <linux/utsname.h>
+#ifdef USE_KLP_CONVERT
+static inline int klp_patch_uname_init(void) { return 0; }
+#else
extern int klp_patch_uname_init(void);
+#endif
+
extern asmlinkage long klp_sys_newuname(struct new_utsname __user *name);
#endif