sync code to openeuler
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
This commit is contained in:
parent
09358d6bf1
commit
db78750c1a
@ -7,7 +7,7 @@ support GNU_UNIQUE type symbols.
|
||||
support .group section corelation.
|
||||
ignore compile warning for third party modules.
|
||||
|
||||
Signed-off-by: Zhipeng Xie <root@localhost.localdomain>
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/create-diff-object.c | 62 ++++++++++++++++++++-----------
|
||||
kpatch-build/kpatch-build | 2 +-
|
||||
|
||||
@ -8,7 +8,7 @@ differ from .orc_unwind_ip
|
||||
|
||||
Don't correlate .orc_unwind sections and symbols
|
||||
|
||||
Signed-off-by: root <root@localhost.localdomain>
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/create-diff-object.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
33
0018-use-orignal-reloc-for-symbols-from-modules.patch
Normal file
33
0018-use-orignal-reloc-for-symbols-from-modules.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 4d13c1b29b2172e6758d18b153f149e461c6d9c3 Mon Sep 17 00:00:00 2001
|
||||
From: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
Date: Thu, 12 Mar 2020 05:10:55 -0400
|
||||
Subject: [PATCH] use orignal reloc for symbols from modules
|
||||
|
||||
symbols exported in a patch will generate a symbol version with
|
||||
object module name in Module.symvers, but the symbol is actually
|
||||
in patch module which cause livepatch symbol lookup failed.
|
||||
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/create-diff-object.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
|
||||
index 320b239..64e5686 100644
|
||||
--- a/kpatch-build/create-diff-object.c
|
||||
+++ b/kpatch-build/create-diff-object.c
|
||||
@@ -3117,10 +3117,8 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
|
||||
if (!strcmp(sym_objname, "vmlinux"))
|
||||
continue;
|
||||
|
||||
- if (!strcmp(sym_objname, objname))
|
||||
- continue;
|
||||
-
|
||||
external = 1;
|
||||
+ continue;
|
||||
}
|
||||
}
|
||||
log_debug("lookup for %s @ 0x%016lx len %lu\n",
|
||||
--
|
||||
2.18.1
|
||||
|
||||
91
0019-create-diff-object-add-jump-label-support.patch
Normal file
91
0019-create-diff-object-add-jump-label-support.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From b3b20140aa243b371f478f325420ecbffd3ee3d6 Mon Sep 17 00:00:00 2001
|
||||
From: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
Date: Mon, 2 Mar 2020 04:35:07 -0500
|
||||
Subject: [PATCH] create-diff-object: add jump label support
|
||||
|
||||
This patch processes the __jump_table special section, and
|
||||
only the jump_lable used by the changed functions will be
|
||||
included in __jump_table section and solve this limitation.
|
||||
(The livepatch in kernel should also be modified that processing
|
||||
the tracepoint again after the dynamic relocation by livepatch.)
|
||||
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/create-diff-object.c | 47 +------------------------------
|
||||
1 file changed, 1 insertion(+), 46 deletions(-)
|
||||
|
||||
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
|
||||
index 7230e93..18d6c7f 100644
|
||||
--- a/kpatch-build/create-diff-object.c
|
||||
+++ b/kpatch-build/create-diff-object.c
|
||||
@@ -2116,7 +2116,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
|
||||
struct rela *rela, *safe;
|
||||
char *src, *dest;
|
||||
unsigned int group_size, src_offset, dest_offset, include;
|
||||
- int jump_table = !strcmp(special->name, "__jump_table");
|
||||
|
||||
LIST_HEAD(newrelas);
|
||||
|
||||
@@ -2156,49 +2155,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
|
||||
if (!include)
|
||||
continue;
|
||||
|
||||
- /*
|
||||
- * Jump labels (aka static keys or static branches) aren't
|
||||
- * actually supported for the time being. Warn on all
|
||||
- * non-tracepoint jump labels when they occur in a replacement
|
||||
- * function. An inert tracepoint is harmless enough, but a
|
||||
- * broken static key can cause unexpected behavior.
|
||||
- *
|
||||
- * Here we hard-code knowledge about the contents of the
|
||||
- * jump_label struct. It has three fields: code, target, and
|
||||
- * key.
|
||||
- */
|
||||
- if (jump_table) {
|
||||
- struct rela *code, *key;
|
||||
- int i = 0;
|
||||
-
|
||||
- list_for_each_entry(rela, &sec->relas, list) {
|
||||
- if (rela->offset >= src_offset &&
|
||||
- rela->offset < src_offset + group_size) {
|
||||
- if (i == 0)
|
||||
- code = rela;
|
||||
- else if (i == 2)
|
||||
- key = rela;
|
||||
- i++;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (i != 3)
|
||||
- ERROR("BUG: __jump_table has an unexpected format");
|
||||
-
|
||||
- /* inert tracepoints are harmless */
|
||||
- if (!strncmp(key->sym->name, "__tracepoint_", 13))
|
||||
- continue;
|
||||
-
|
||||
- /* inert dynamic debug printks are harmless */
|
||||
- if (is_dynamic_debug_symbol(key->sym))
|
||||
- continue;
|
||||
-
|
||||
- ERROR("Found a jump label at %s()+0x%lx, using key %s. Jump labels aren't currently supported. Use static_key_enabled() instead.",
|
||||
- code->sym->name, code->addend, key->sym->name);
|
||||
-
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
/*
|
||||
* Copy all relas in the group. It's possible that the relas
|
||||
* aren't sorted (e.g. .rela.fixup), so go through the entire
|
||||
@@ -2635,8 +2591,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf)
|
||||
* jump labels and enable tracepoints in a patched function.
|
||||
*/
|
||||
list_for_each_entry(sec, &kelf->sections, list) {
|
||||
- if (strcmp(sec->name, "__jump_table") &&
|
||||
- strcmp(sec->name, "__tracepoints") &&
|
||||
+ if (strcmp(sec->name, "__tracepoints") &&
|
||||
strcmp(sec->name, "__tracepoints_ptrs") &&
|
||||
strcmp(sec->name, "__tracepoints_strings"))
|
||||
continue;
|
||||
--
|
||||
2.18.1
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
From 65a3ae0c692a22d097f7257ae88bbe6bc2b73de8 Mon Sep 17 00:00:00 2001
|
||||
From: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
Date: Thu, 12 Mar 2020 06:56:21 -0400
|
||||
Subject: [PATCH] kpatch-build: add compile flag -fno-reorder-functions
|
||||
|
||||
Sometimes function foo with static variables can be put in
|
||||
.text.foo section in original binary and be put in
|
||||
.text.unlikely.foo section in patched binary. This will result
|
||||
in "reference to static local variable xxx in foo was removed"
|
||||
problem because the .text.foo section can not be correlated
|
||||
to .text.unlikely.foo section by create-diff-object.
|
||||
|
||||
gcc just put the function in .text.unlikely.xxx section,the
|
||||
symbol name doesn't change which is different with other
|
||||
optimization such as ".constprop/.isra/.part". So disable the
|
||||
optimization with -fno-reorder-functions just make sure the
|
||||
function is placed in .text.xxx section, kernel can still find
|
||||
the symbol name to patch or relocate.
|
||||
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/kpatch-build | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
||||
index de448dc..ad7ab71 100755
|
||||
--- a/kpatch-build/kpatch-build
|
||||
+++ b/kpatch-build/kpatch-build
|
||||
@@ -887,7 +887,7 @@ if [[ "$ARCH" = "ppc64le" ]]; then
|
||||
ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so"
|
||||
fi
|
||||
|
||||
-export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections \
|
||||
+export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections -fno-reorder-functions\
|
||||
$ARCH_KCFLAGS $DEBUG_KCFLAGS ${GCC_ADD_OPTION}"
|
||||
|
||||
echo "Reading special section data"
|
||||
--
|
||||
2.18.1
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From 1155b58be699eb2e55af7757e6b0d0ce03356d63 Mon Sep 17 00:00:00 2001
|
||||
From: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
Date: Thu, 12 Mar 2020 07:37:00 -0400
|
||||
Subject: [PATCH] kpatch-build: don't copy .config for out of tree module
|
||||
|
||||
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
|
||||
---
|
||||
kpatch-build/kpatch-build | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
||||
index ad7ab71..fd34812 100755
|
||||
--- a/kpatch-build/kpatch-build
|
||||
+++ b/kpatch-build/kpatch-build
|
||||
@@ -828,7 +828,7 @@ fi
|
||||
|
||||
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$SRCDIR"/.config
|
||||
[[ ! -e "$CONFIGFILE" ]] && die "can't find config file"
|
||||
-[[ ! "$CONFIGFILE" -ef "$SRCDIR"/.config ]] && cp -f "$CONFIGFILE" "$SRCDIR/.config"
|
||||
+[[ -z "$OOT_MODULE" ]] && [[ ! "$CONFIGFILE" -ef "$SRCDIR"/.config ]] && cp -f "$CONFIGFILE" "$SRCDIR/.config"
|
||||
|
||||
# Build variables - Set some defaults, then adjust features
|
||||
# according to .config and kernel version
|
||||
--
|
||||
2.18.1
|
||||
|
||||
24
kpatch.spec
24
kpatch.spec
@ -2,7 +2,7 @@
|
||||
|
||||
Name: kpatch
|
||||
Version: 2.0
|
||||
Release: 3.1.24
|
||||
Release: 3.1.26
|
||||
Summary: A Linux dynamic kernel patching infrastructure
|
||||
|
||||
License: GPLv2
|
||||
@ -30,6 +30,10 @@ Patch0014:0014-livepatch-patch-hook-support-force-enable-disable.patch
|
||||
Patch0015:0015-kpatch-build-ignore-debuginfo-in-patch.patch
|
||||
Patch0016:0016-add-object-in-kpatch.patch
|
||||
Patch0017:0017-create-diff-object-fix-.orc_unwind_ip-error.patch
|
||||
Patch0018:0018-use-orignal-reloc-for-symbols-from-modules.patch
|
||||
Patch0019:0019-create-diff-object-add-jump-label-support.patch
|
||||
Patch0020:0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch
|
||||
Patch0021:0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch
|
||||
|
||||
BuildRequires: gcc elfutils-libelf-devel uname-build-checks kernel kernel-devel
|
||||
Requires: bc
|
||||
@ -60,7 +64,7 @@ export CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
|
||||
%install
|
||||
%make_install PREFIX=%{_prefix}
|
||||
|
||||
install -Dm 0750 -t %{buildroot}/%{_bindir} %{SOURCE1} %{SOURCE2}
|
||||
install -Dm 0500 -t %{buildroot}/%{_bindir} %{SOURCE1} %{SOURCE2}
|
||||
install -Dm 0500 -t %{buildroot}/opt/patch_workspace/ %{SOURCE3}
|
||||
pushd %{buildroot}/opt/patch_workspace
|
||||
mkdir hotpatch package
|
||||
@ -76,6 +80,8 @@ popd
|
||||
%{_datadir}/%{name}/*
|
||||
%{_sysconfdir}/init/*
|
||||
/opt/patch_workspace/*
|
||||
%exclude %{_bindir}/livepatch
|
||||
%exclude %{_bindir}/os_hotpatch
|
||||
|
||||
%files runtime
|
||||
%defattr(-,root,root)
|
||||
@ -86,7 +92,19 @@ popd
|
||||
%{_mandir}/man1/*.1.gz
|
||||
|
||||
%changelog
|
||||
* Wed Feb 26 2020 Zhipeng Xie<kangenbo@huawei.com> -2.0-3.1.24
|
||||
* Thu Mar 12 2020 Zhipeng Xie<xiezhipeng1@huawei.com> -2.0-3.1.26
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:use orignal reloc for export symbols in all modules
|
||||
|
||||
* Thu Mar 12 2020 Zhipeng Xie<xiezhipeng1@huawei.com> -2.0-3.1.25
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:change livepatch and os_hotpatch to permission and exclude in main package
|
||||
|
||||
* Wed Feb 26 2020 Zhipeng Xie<xiezhipeng1@huawei.com> -2.0-3.1.24
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user