1 Star 0 Fork 39

几何途行 / kpatch

forked from src-openEuler / kpatch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0022-support-force-enable-disable-for-x86.patch 2.39 KB
一键复制 编辑 原始数据 按行查看 历史
谢志鹏 提交于 2020-09-12 05:45 . code optimization
From 11e57aa03ae87fa24028800851f34205a2aeb0d8 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 15 Apr 2020 06:37:59 -0400
Subject: [PATCH 22/23] support force enable/disable for x86
detect if the klp_func structure in vmlinux have force
member, if it has, export KLP_SUPPORT_FORCE=y.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
kpatch-build/kpatch-build | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index fd34812..523d5df 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -373,7 +373,7 @@ find_special_section_data() {
# shellcheck disable=SC2086
SPECIAL_VARS="$(readelf -wi "$VMLINUX" |
gawk --non-decimal-data $AWK_OPTIONS '
- BEGIN { a = b = p = e = o = j = 0 }
+ BEGIN { a = b = p = e = o = j = c = f = 0 }
# Set state if name matches
a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next}
@@ -382,6 +382,7 @@ find_special_section_data() {
e == 0 && /DW_AT_name.* exception_table_entry[[:space:]]*$/ {e = 1; next}
o == 0 && /DW_AT_name.* orc_entry[[:space:]]*$/ {o = 1; next}
j == 0 && /DW_AT_name.* jump_entry[[:space:]]*$/ {j = 1; next}
+ c == 0 && /DW_AT_name.* klp_func[[:space:]]*$/ {c = 1; next}
# Reset state unless this abbrev describes the struct size
a == 1 && !/DW_AT_byte_size/ { a = 0; next }
@@ -390,6 +391,8 @@ find_special_section_data() {
e == 1 && !/DW_AT_byte_size/ { e = 0; next }
o == 1 && !/DW_AT_byte_size/ { o = 0; next }
j == 1 && !/DW_AT_byte_size/ { j = 0; next }
+ c == 1 && /DW_TAG_structure_type/ { c = 3; next }
+ c == 1 && /DW_AT_name.* force[[:space:]]*$/ {f = 2; next}
# Now that we know the size, stop parsing for it
a == 1 {printf("export ALT_STRUCT_SIZE=%d\n", $4); a = 2}
@@ -398,9 +401,10 @@ find_special_section_data() {
e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2}
o == 1 {printf("export ORC_STRUCT_SIZE=%d\n", $4); o = 2}
j == 1 {printf("export JUMP_STRUCT_SIZE=%d\n", $4); j = 2}
+ f == 2 {printf("export KLP_SUPPORT_FORCE=y\n"); f = 3}
# Bail out once we have everything
- a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 && (o == 2 || skip_o) && (j == 2 || skip_j) {exit}')"
+ a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 && (o == 2 || skip_o) && (j == 2 || skip_j) && c == 3 {exit}')"
[[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS"
--
2.18.1
1
https://gitee.com/elimuzi/kpatch.git
git@gitee.com:elimuzi/kpatch.git
elimuzi
kpatch
kpatch
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891