summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-kernel
diff options
context:
space:
mode:
authorRuslan Bilovol <rbilovol@cisco.com>2018-02-01 18:34:18 +0200
committerArmin Kuster <akuster808@gmail.com>2018-02-11 11:52:54 -0800
commit6cb84a77bbf537651838bef88f84a55e239c2881 (patch)
treef7400071525ed66e0a33ba0071eb10875a07901f /meta-oe/recipes-kernel
parentf75e11225f5f424abfb672d09728c60c61cd801f (diff)
downloadmeta-openembedded-6cb84a77bbf537651838bef88f84a55e239c2881.tar.gz
recipes-kernel: add kpatch dynamic kernel patching infrastructure
kpatch is a Linux dynamic kernel patching infrastructure which allows you to patch a running kernel without rebooting or restarting any processes Currently it is enabled and tested on x86-64 systems, although can be extended to PPC64 as well. Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-oe/recipes-kernel')
-rw-r--r--meta-oe/recipes-kernel/kpatch/kpatch.inc49
-rw-r--r--meta-oe/recipes-kernel/kpatch/kpatch/0001-kpatch-build-add-cross-compilation-support.patch103
-rw-r--r--meta-oe/recipes-kernel/kpatch/kpatch/0002-kpatch-build-allow-overriding-of-distro-name.patch62
-rw-r--r--meta-oe/recipes-kernel/kpatch/kpatch_git.bb11
4 files changed, 225 insertions, 0 deletions
diff --git a/meta-oe/recipes-kernel/kpatch/kpatch.inc b/meta-oe/recipes-kernel/kpatch/kpatch.inc
new file mode 100644
index 000000000..b1e73e954
--- /dev/null
+++ b/meta-oe/recipes-kernel/kpatch/kpatch.inc
@@ -0,0 +1,49 @@
1SUMMARY = "Linux dynamic kernel patching infrastructure"
2DESCRIPTION = "kpatch is a Linux dynamic kernel patching infrastructure which allows you to patch a running kernel without rebooting or restarting any processes."
3LICENSE = "GPLv2 & LGPLv2"
4DEPENDS = "elfutils bash"
5
6SRC_URI = "git://github.com/dynup/kpatch.git;protocol=https \
7 file://0001-kpatch-build-add-cross-compilation-support.patch \
8 file://0002-kpatch-build-allow-overriding-of-distro-name.patch \
9 "
10
11EXTRA_OEMAKE = " \
12 PREFIX=${prefix} \
13 BINDIR=${D}${bindir} \
14 SBINDIR=${D}${sbindir} \
15 LIBDIR=${D}${libdir} \
16 MANDIR=${D}${mandir}/man1 \
17 SYSTEMDDIR=${D}${systemd_system_unitdir} \
18 DESTDIR=${D} \
19 BUILDMOD=no \
20 CC='${CC}' \
21 "
22
23S = "${WORKDIR}/git"
24
25do_install () {
26 oe_runmake install
27}
28
29PACKAGES =+ "kpatch-build"
30PROVIDES += "kpatch-build"
31
32COMPATIBLE_HOST = "(x86_64).*-linux"
33
34RDEPENDS_${PN} = "bash binutils"
35RDEPENDS_kpatch-build = "bash glibc-utils"
36
37FILES_${PN} = " \
38 ${sbindir}/kpatch \
39 ${systemd_system_unitdir}/kpatch.service \
40 ${mandir}/man1/kpatch.1.gz \
41 "
42FILES_kpatch-build = " \
43 ${bindir}/kpatch-build \
44 ${libexecdir}/* \
45 ${datadir}/kpatch \
46 ${mandir}/man1/kpatch-build.1.gz \
47 "
48
49SYSTEMD_SERVICE_${PN} = "kpatch.service"
diff --git a/meta-oe/recipes-kernel/kpatch/kpatch/0001-kpatch-build-add-cross-compilation-support.patch b/meta-oe/recipes-kernel/kpatch/kpatch/0001-kpatch-build-add-cross-compilation-support.patch
new file mode 100644
index 000000000..459fb2197
--- /dev/null
+++ b/meta-oe/recipes-kernel/kpatch/kpatch/0001-kpatch-build-add-cross-compilation-support.patch
@@ -0,0 +1,103 @@
1From a9a80a1f4df65892a0269295ce8a64b06f2ff61d Mon Sep 17 00:00:00 2001
2From: Ruslan Bilovol <rbilovol@cisco.com>
3Date: Tue, 19 Dec 2017 15:59:04 +0200
4Subject: [PATCH] kpatch-build: add cross-compilation support
5
6This patch introduces new option for kpatch-build
7script "--cross-compile" which can be used for
8specifying cross-complier prefix.
9It allows to build live patches not only on
10target system, but also on hosts for a target other
11than the one on which the compiler is running
12
13Also removed quotes in exec lines, so it is
14possible to pass multy-component strings like
15"ccache x86_64-xelinux-linux-" as cross-compiler
16
17Upstream-Status: Pending
18
19Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
20---
21 kpatch-build/kpatch-build | 13 +++++++++++--
22 kpatch-build/kpatch-gcc | 4 ++--
23 2 files changed, 13 insertions(+), 4 deletions(-)
24
25diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
26index 166ecbd..af24cc4 100755
27--- a/kpatch-build/kpatch-build
28+++ b/kpatch-build/kpatch-build
29@@ -195,7 +195,7 @@ gcc_version_check() {
30 # gcc --version varies between distributions therefore extract version
31 # by compiling a test file and compare it to vmlinux's version.
32 echo 'void main(void) {}' > "$c"
33- out="$(gcc -c -pg -ffunction-sections -o "$o" "$c" 2>&1)"
34+ out="$(${KPATCH_CROSS_COMPILE}gcc -c -pg -ffunction-sections -o "$o" "$c" 2>&1)"
35 gccver="$(gcc_version_from_file "$o")"
36 kgccver="$(gcc_version_from_file "$VMLINUX")"
37 rm -f "$c" "$o"
38@@ -381,12 +381,14 @@ usage() {
39 echo " -d, --debug Enable 'xtrace' and keep scratch files" >&2
40 echo " in <CACHEDIR>/tmp" >&2
41 echo " (can be specified multiple times)" >&2
42+ echo " --cross-compile Specify the prefix used for all executables" >&2
43+ echo " used during compilation" >&2
44 echo " --skip-cleanup Skip post-build cleanup" >&2
45 echo " --skip-gcc-check Skip gcc version matching check" >&2
46 echo " (not recommended)" >&2
47 }
48
49-options="$(getopt -o ha:r:s:c:v:j:t:n:o:d -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,debug,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
50+options="$(getopt -o ha:r:s:c:v:j:t:n:o:d -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,debug,cross-compile:,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
51
52 eval set -- "$options"
53
54@@ -444,6 +446,10 @@ while [[ $# -gt 0 ]]; do
55 echo "DEBUG mode enabled"
56 fi
57 ;;
58+ --cross-compile)
59+ KPATCH_CROSS_COMPILE="$2"
60+ shift
61+ ;;
62 --skip-cleanup)
63 echo "Skipping cleanup"
64 SKIPCLEANUP=1
65@@ -691,6 +697,8 @@ if [[ $DEBUG -ge 4 ]]; then
66 export KPATCH_GCC_DEBUG=1
67 fi
68
69+export KPATCH_CROSS_COMPILE
70+
71 echo "Building original kernel"
72 ./scripts/setlocalversion --save-scmversion || die
73 make mrproper 2>&1 | logger || die
74@@ -840,6 +848,7 @@ cd "$TEMPDIR/patch" || die
75 KPATCH_BUILD="$SRCDIR" KPATCH_NAME="$MODNAME" \
76 KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS" \
77 KPATCH_LDFLAGS="$KPATCH_LDFLAGS" \
78+CROSS_COMPILE="$KPATCH_CROSS_COMPILE" \
79 make 2>&1 | logger || die
80
81 if ! "$KPATCH_MODULE"; then
82diff --git a/kpatch-build/kpatch-gcc b/kpatch-build/kpatch-gcc
83index 6ba133c..3937948 100755
84--- a/kpatch-build/kpatch-gcc
85+++ b/kpatch-build/kpatch-gcc
86@@ -8,7 +8,7 @@ TOOLCHAINCMD="$1"
87 shift
88
89 if [[ -z "$KPATCH_GCC_TEMPDIR" ]]; then
90- exec "$TOOLCHAINCMD" "$@"
91+ exec ${KPATCH_CROSS_COMPILE}${TOOLCHAINCMD} "$@"
92 fi
93
94 declare -a args=("$@")
95@@ -80,4 +80,4 @@ elif [[ "$TOOLCHAINCMD" = "ld" ]] ; then
96 done
97 fi
98
99-exec "$TOOLCHAINCMD" "${args[@]}"
100+exec ${KPATCH_CROSS_COMPILE}${TOOLCHAINCMD} "${args[@]}"
101--
1021.9.1
103
diff --git a/meta-oe/recipes-kernel/kpatch/kpatch/0002-kpatch-build-allow-overriding-of-distro-name.patch b/meta-oe/recipes-kernel/kpatch/kpatch/0002-kpatch-build-allow-overriding-of-distro-name.patch
new file mode 100644
index 000000000..a9d8a7f2c
--- /dev/null
+++ b/meta-oe/recipes-kernel/kpatch/kpatch/0002-kpatch-build-allow-overriding-of-distro-name.patch
@@ -0,0 +1,62 @@
1From d418d716dae1e2a05131dfb42a19a4da2fc8a85d Mon Sep 17 00:00:00 2001
2From: Ruslan Bilovol <rbilovol@cisco.com>
3Date: Tue, 2 Jan 2018 14:50:03 +0200
4Subject: [PATCH] kpatch-build: allow overriding of distro name
5
6It is sometimes useful to have ability to override
7distro name, for example during cross-compilation
8build when livepatch modules will be ran on the
9target which differs from host.
10
11This patch adds a new --distro option which
12implements all needed functionality
13
14Upstream-Status: Pending
15
16Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
17---
18 kpatch-build/kpatch-build | 9 +++++++--
19 1 file changed, 7 insertions(+), 2 deletions(-)
20
21diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
22index af24cc4..4f9f78d 100755
23--- a/kpatch-build/kpatch-build
24+++ b/kpatch-build/kpatch-build
25@@ -383,12 +383,13 @@ usage() {
26 echo " (can be specified multiple times)" >&2
27 echo " --cross-compile Specify the prefix used for all executables" >&2
28 echo " used during compilation" >&2
29+ echo " --distro Override distro name" >&2
30 echo " --skip-cleanup Skip post-build cleanup" >&2
31 echo " --skip-gcc-check Skip gcc version matching check" >&2
32 echo " (not recommended)" >&2
33 }
34
35-options="$(getopt -o ha:r:s:c:v:j:t:n:o:d -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,debug,cross-compile:,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
36+options="$(getopt -o ha:r:s:c:v:j:t:n:o:d -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,debug,cross-compile:,distro:,skip-gcc-check,skip-cleanup" -- "$@")" || die "getopt failed"
37
38 eval set -- "$options"
39
40@@ -450,6 +451,10 @@ while [[ $# -gt 0 ]]; do
41 KPATCH_CROSS_COMPILE="$2"
42 shift
43 ;;
44+ --distro)
45+ DISTRO="$2"
46+ shift
47+ ;;
48 --skip-cleanup)
49 echo "Skipping cleanup"
50 SKIPCLEANUP=1
51@@ -526,7 +531,7 @@ fi
52 # Don't check external file.
53 # shellcheck disable=SC1091
54 source /etc/os-release
55-DISTRO="$ID"
56+DISTRO="${DISTRO:-${ID}}"
57 if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]]; then
58 [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"
59 [[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed"
60--
611.9.1
62
diff --git a/meta-oe/recipes-kernel/kpatch/kpatch_git.bb b/meta-oe/recipes-kernel/kpatch/kpatch_git.bb
new file mode 100644
index 000000000..e495e2882
--- /dev/null
+++ b/meta-oe/recipes-kernel/kpatch/kpatch_git.bb
@@ -0,0 +1,11 @@
1require kpatch.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
4
5SRCREV = "db6efbb8c7e90d2b761272cf563047119072768f"
6
7PV = "0.5.0+git${SRCPV}"
8
9S = "${WORKDIR}/git"
10
11BBCLASSEXTEND = "native nativesdk"