1 Star 0 Fork 41

几何途行 / kpatch

forked from src-openEuler / kpatch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0019-create-diff-object-add-jump-label-support.patch 3.14 KB
一键复制 编辑 原始数据 按行查看 历史
谢志鹏 提交于 2020-09-12 05:45 . code optimization
From c0b20224cf1b081fba152cb4944d762515561d89 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Mon, 2 Mar 2020 04:35:07 -0500
Subject: [PATCH 19/23] 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 457d517..4fa4488 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2140,7 +2140,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);
@@ -2180,49 +2179,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
@@ -2659,8 +2615,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
1
https://gitee.com/elimuzi/kpatch.git
git@gitee.com:elimuzi/kpatch.git
elimuzi
kpatch
kpatch
master

搜索帮助