upgrade kpatch to version 0.9.7

Signed-off-by: hubin <hubin73@huawei.com>
This commit is contained in:
hubin 2023-01-30 16:10:43 +08:00
parent 2367b476e4
commit 6ac6af8b27
50 changed files with 695 additions and 1117 deletions

View File

@ -1,7 +1,7 @@
From 821e6cb24778bd063d1e8ad097d4bd4c81973091 Mon Sep 17 00:00:00 2001 From af8c2cebd046dd3833cba8daac26e4d8109f7ff3 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 20 Dec 2018 04:55:38 +0000 Date: Thu, 20 Dec 2018 04:55:38 +0000
Subject: [PATCH 01/24] kpatch: add aarch64 support Subject: [PATCH 01/37] kpatch: add aarch64 support
1.use R_AARCH64_ABS64 for aarch64 1.use R_AARCH64_ABS64 for aarch64
2.add find_special_section_data_arm64 for arm64: 2.add find_special_section_data_arm64 for arm64:
@ -10,68 +10,109 @@ in vmlinux, we don't need to check these two struct for arm64.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
--- ---
kpatch-build/Makefile | 4 +++ kpatch-build/Makefile | 2 +-
kpatch-build/create-diff-object.c | 14 ++++++---- kpatch-build/create-diff-object.c | 32 ++++++++++++++++++-------------
kpatch-build/kpatch-build | 46 +++++++++++++++++++++++++++++++ kpatch-build/kpatch-build | 5 +++++
kpatch-build/kpatch-elf.c | 2 +- kpatch-build/kpatch-elf.c | 7 +++++++
4 files changed, 60 insertions(+), 6 deletions(-) kpatch-build/kpatch-elf.h | 1 +
5 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile
index 50899b6..423c32a 100644 index bebf3cd..5037677 100644
--- a/kpatch-build/Makefile --- a/kpatch-build/Makefile
+++ b/kpatch-build/Makefile +++ b/kpatch-build/Makefile
@@ -14,6 +14,10 @@ ifeq ($(ARCH),x86_64) @@ -22,7 +22,7 @@ PLUGIN_CFLAGS := $(filter-out -Wconversion, $(CFLAGS))
SOURCES += insn/insn.c insn/inat.c PLUGIN_CFLAGS += -shared -I$(GCC_PLUGINS_DIR)/include \
INSN = insn/insn.o insn/inat.o -Igcc-plugins -fPIC -fno-rtti -O2 -Wall
insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) endif
+else ifeq ($(ARCH),aarch64) -ifeq ($(filter $(ARCH),s390x x86_64 ppc64le),)
+SOURCES += insn/insn.c insn/inat.c +ifeq ($(filter $(ARCH),s390x x86_64 ppc64le aarch64),)
+INSN = insn/insn.o insn/inat.o $(error Unsupported architecture ${ARCH}, check https://github.com/dynup/kpatch/#supported-architectures)
+insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) endif
else ifeq ($(ARCH),ppc64le)
SOURCES += gcc-plugins/ppc64le-plugin.c
PLUGIN = gcc-plugins/ppc64le-plugin.so
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6a4848a..ca55180 100644 index 3604411..0b0b06b 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -62,6 +62,8 @@ @@ -175,6 +175,8 @@ static bool is_gcc6_localentry_bundled_sym(struct kpatch_elf *kelf,
return false;
#ifdef __powerpc64__ case S390:
#define ABSOLUTE_RELA_TYPE R_PPC64_ADDR64 return false;
+#elif __aarch64__ + case ARM64:
+#define ABSOLUTE_RELA_TYPE R_AARCH64_ABS64 + return false;
#else default:
#define ABSOLUTE_RELA_TYPE R_X86_64_64 ERROR("unsupported arch");
#endif }
@@ -1536,7 +1538,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf) @@ -2186,57 +2188,57 @@ static int fixup_group_size(struct kpatch_elf *kelf, int offset)
continue; static struct special_section special_sections[] = {
} {
.name = "__bug_table",
-#ifdef __powerpc64__ - .arch = X86_64 | PPC64 | S390,
+#if defined(__powerpc64__) || defined(__aarch64__) + .arch = X86_64 | PPC64 | S390 | ARM64,
add_off = 0; .group_size = bug_table_group_size,
#else },
if (rela->type == R_X86_64_PC32 || {
@@ -2028,7 +2030,7 @@ static int printk_index_group_size(struct kpatch_elf *kelf, int offset) .name = ".fixup",
return size; - .arch = X86_64 | PPC64 | S390,
} + .arch = X86_64 | PPC64 | S390 | ARM64,
.group_size = fixup_group_size,
-#ifdef __x86_64__ },
+#if defined(__x86_64__) || defined(__aarch64__) {
static int parainstructions_group_size(struct kpatch_elf *kelf, int offset) .name = "__ex_table", /* must come after .fixup */
{ - .arch = X86_64 | PPC64 | S390,
static int size = 0; + .arch = X86_64 | PPC64 | S390 | ARM64,
@@ -2177,7 +2179,7 @@ static struct special_section special_sections[] = { .group_size = ex_table_group_size,
},
{
.name = "__jump_table",
- .arch = X86_64 | PPC64 | S390,
+ .arch = X86_64 | PPC64 | S390 | ARM64,
.group_size = jump_table_group_size,
},
{
.name = ".printk_index", .name = ".printk_index",
- .arch = X86_64 | PPC64 | S390,
+ .arch = X86_64 | PPC64 | S390 | ARM64,
.group_size = printk_index_group_size, .group_size = printk_index_group_size,
}, },
-#ifdef __x86_64__
+#if defined(__x86_64__) || defined(__aarch64__)
{ {
.name = ".smp_locks", .name = ".smp_locks",
- .arch = X86_64,
+ .arch = X86_64 | ARM64,
.group_size = smp_locks_group_size, .group_size = smp_locks_group_size,
@@ -2990,7 +2992,9 @@ static int function_ptr_rela(const struct rela *rela) },
{
.name = ".parainstructions",
- .arch = X86_64,
+ .arch = X86_64 | ARM64,
.group_size = parainstructions_group_size,
},
{
.name = ".altinstructions",
- .arch = X86_64 | S390,
+ .arch = X86_64 | S390 | ARM64,
.group_size = altinstructions_group_size,
},
{
.name = ".static_call_sites",
- .arch = X86_64,
+ .arch = X86_64 | ARM64,
.group_size = static_call_sites_group_size,
},
{
.name = ".retpoline_sites",
- .arch = X86_64,
+ .arch = X86_64 | ARM64,
.group_size = retpoline_sites_group_size,
},
{
.name = ".return_sites",
- .arch = X86_64,
+ .arch = X86_64 | ARM64,
.group_size = return_sites_group_size,
},
{
@@ -3097,7 +3099,9 @@ static int function_ptr_rela(const struct rela *rela)
rela_toc->addend == (int)rela_toc->sym->sym.st_value && rela_toc->addend == (int)rela_toc->sym->sym.st_value &&
(rela->type == R_X86_64_32S || (rela->type == R_X86_64_32S ||
rela->type == R_PPC64_TOC16_HA || rela->type == R_PPC64_TOC16_HA ||
@ -81,92 +122,99 @@ index 6a4848a..ca55180 100644
+ rela->type == R_AARCH64_ADD_ABS_LO12_NC)); + rela->type == R_AARCH64_ADD_ABS_LO12_NC));
} }
static bool need_dynrela(struct lookup_table *table, struct section *sec, const struct rela *rela) static bool need_dynrela(struct kpatch_elf *kelf, struct lookup_table *table,
@@ -3479,7 +3483,7 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) @@ -3570,7 +3574,8 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
rela->type = R_X86_64_PC32;
} }
-#else /* __powerpc64__ */ switch(kelf->arch) {
+#else /* __powerpc64__ || __aarch64__ */ - case PPC64: {
{ + case PPC64:
bool found = false; + case ARM64: {
bool found = false;
list_for_each_entry(rela, &sym->sec->rela->relas, list)
@@ -3806,6 +3811,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf)
switch(kelf->arch) {
case PPC64:
+ case ARM64:
list_for_each_entry(rela, &sym->sec->rela->relas, list) {
if (!strcmp(rela->sym->name, "_mcount")) {
sym->has_func_profiling = 1;
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index eedf383..ad3a079 100755 index 296fa48..73f8976 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -375,12 +375,58 @@ find_special_section_data_ppc64le() { @@ -354,6 +354,9 @@ find_special_section_data() {
return "s390x")
} check[a]=true # alt_instr
;;
+ "aarch64")
+ check[a]=true # alt_instr
+ ;;
esac
+find_special_section_data_aarch64() { # Kernel CONFIG_ features
+ @@ -362,6 +365,8 @@ find_special_section_data() {
+ [[ "$CONFIG_JUMP_LABEL" -eq 0 ]] && AWK_OPTIONS="$AWK_OPTIONS -vskip_j=1" [[ -n "$CONFIG_UNWINDER_ORC" ]] && check[o]=true # orc_entry
+ [[ -n "$CONFIG_PARAVIRT" ]] && check[p]=true # paravirt_patch_site
+ # If $AWK_OPTIONS are blank gawk would treat "" as a blank script
+ # shellcheck disable=SC2086
+ SPECIAL_VARS="$(readelf -wi "$VMLINUX" |
+ gawk --non-decimal-data $AWK_OPTIONS '
+ BEGIN { a = b = e = j = 0 }
+
+ # Set state if name matches
+ a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next}
+ b == 0 && /DW_AT_name.* bug_entry[[:space:]]*$/ {b = 1; next}
+ e == 0 && /DW_AT_name.* exception_table_entry[[:space:]]*$/ {e = 1; next}
+ j == 0 && /DW_AT_name.* jump_entry[[:space:]]*$/ {j = 1; next}
+
+ # Reset state unless this abbrev describes the struct size
+ a == 1 && !/DW_AT_byte_size/ { a = 0; next }
+ b == 1 && !/DW_AT_byte_size/ { b = 0; next }
+ e == 1 && !/DW_AT_byte_size/ { e = 0; next }
+ j == 1 && !/DW_AT_byte_size/ { j = 0; next }
+
+ # Now that we know the size, stop parsing for it
+ a == 1 {printf("export ALT_STRUCT_SIZE=%d\n", $4); a = 2}
+ b == 1 {printf("export BUG_STRUCT_SIZE=%d\n", $4); b = 2}
+ e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2}
+ j == 1 {printf("export JUMP_STRUCT_SIZE=%d\n", $4); j = 2}
+
+ # Bail out once we have everything
+ a == 2 && b == 2 && e == 2 && (j == 2 || skip_j) {exit}')"
+
+ [[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS"
+
+ [[ -z "$ALT_STRUCT_SIZE" ]] && die "can't find special struct alt_instr size"
+ [[ -z "$BUG_STRUCT_SIZE" ]] && die "can't find special struct bug_entry size"
+ [[ -z "$EX_STRUCT_SIZE" ]] && die "can't find special struct exception_table_entry size"
+ [[ -z "$JUMP_STRUCT_SIZE" && "$CONFIG_JUMP_LABEL" -ne 0 ]] && die "can't find special struct jump_entry size"
+
+ return
+}
+
find_special_section_data() {
if [[ "$ARCH" = "ppc64le" ]]; then
find_special_section_data_ppc64le
return
fi
+ if [[ "$ARCH" = "aarch64" ]]; then + [[ "$ARCH" == "aarch64" ]] && unset check[p]
+ find_special_section_data_aarch64
+ return
+ fi
+ +
[[ "$CONFIG_PARAVIRT" -eq 0 ]] && AWK_OPTIONS="-vskip_p=1" local c AWK_OPTIONS
[[ "$CONFIG_UNWINDER_ORC" -eq 0 ]] && AWK_OPTIONS="$AWK_OPTIONS -vskip_o=1" for c in "${!check[@]}"; do
[[ "$CONFIG_JUMP_LABEL" -eq 0 ]] && AWK_OPTIONS="$AWK_OPTIONS -vskip_j=1" AWK_OPTIONS+=" -vcheck_${c}=1"
diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c
index 7e272e2..68d5c86 100644 index 58dbe1a..069e102 100644
--- a/kpatch-build/kpatch-elf.c --- a/kpatch-build/kpatch-elf.c
+++ b/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c
@@ -325,7 +325,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf) @@ -142,6 +142,8 @@ unsigned int absolute_rela_type(struct kpatch_elf *kelf)
list_for_each_entry(sym, &kelf->symbols, list) { return R_X86_64_64;
if (sym->type != STT_FUNC || !sym->sec || !sym->sec->rela) case S390:
continue; return R_390_64;
-#ifdef __powerpc64__ + case ARM64:
+#if defined(__powerpc64__) || defined(__aarch64__) + return R_AARCH64_ABS64;
list_for_each_entry(rela, &sym->sec->rela->relas, list) { default:
if (!strcmp(rela->sym->name, "_mcount")) { ERROR("unsupported arch");
sym->has_func_profiling = 1; }
@@ -206,6 +208,7 @@ long rela_target_offset(struct kpatch_elf *kelf, struct section *relasec,
switch(kelf->arch) {
case PPC64:
+ case ARM64:
add_off = 0;
break;
case X86_64:
@@ -261,6 +264,7 @@ unsigned int insn_length(struct kpatch_elf *kelf, void *addr)
return decoded_insn.length;
case PPC64:
+ case ARM64:
return 4;
case S390:
@@ -501,6 +505,9 @@ struct kpatch_elf *kpatch_elf_open(const char *name)
case EM_S390:
kelf->arch = S390;
break;
+ case EM_AARCH64:
+ kelf->arch = ARM64;
+ break;
default:
ERROR("Unsupported target architecture");
}
diff --git a/kpatch-build/kpatch-elf.h b/kpatch-build/kpatch-elf.h
index 3bc6e76..d887812 100644
--- a/kpatch-build/kpatch-elf.h
+++ b/kpatch-build/kpatch-elf.h
@@ -113,6 +113,7 @@ enum architecture {
PPC64 = 0x1 << 0,
X86_64 = 0x1 << 1,
S390 = 0x1 << 2,
+ ARM64 = 0x1 << 3,
};
struct kpatch_elf {
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 72d28d667f8f6baa88882abfc1590cce3e9e2b1f Mon Sep 17 00:00:00 2001 From cc0e2fd24f623c617ae2c171105ae2924c818007 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sun, 14 Nov 2021 15:57:55 +0800 Date: Sun, 14 Nov 2021 15:57:55 +0800
Subject: [PATCH 02/24] create-diff-object: fix symbol changed sections error Subject: [PATCH 02/37] create-diff-object: fix symbol changed sections error
on aarch64 on aarch64
$d is reserved symbols in aarch64, we met following error when $d is reserved symbols in aarch64, we met following error when
@ -14,10 +14,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 2 insertions(+) 1 file changed, 2 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index ca55180..6c28280 100644 index 0b0b06b..3b677d3 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -865,6 +865,8 @@ static void kpatch_compare_correlated_symbol(struct symbol *sym) @@ -892,6 +892,8 @@ static void kpatch_compare_correlated_symbol(struct symbol *sym)
if ((sym2->sec->twin && sym2->sec->twin->ignore) || if ((sym2->sec->twin && sym2->sec->twin->ignore) ||
kpatch_subsection_changed(sym1->sec, sym2->sec)) kpatch_subsection_changed(sym1->sec, sym2->sec))
sym->status = CHANGED; sym->status = CHANGED;
@ -27,5 +27,5 @@ index ca55180..6c28280 100644
DIFF_FATAL("symbol changed sections: %s", sym1->name); DIFF_FATAL("symbol changed sections: %s", sym1->name);
} }
-- --
2.23.0 2.33.0

View File

@ -1,90 +1,57 @@
From b71b6e5f46fdc3f1b709b58777cb0da7ec9fc008 Mon Sep 17 00:00:00 2001 From adafc04638712b7227328e44c0e023b5d3c46f53 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sun, 14 Nov 2021 17:26:59 +0800 Date: Sun, 14 Nov 2021 17:26:59 +0800
Subject: [PATCH 03/24] create-diff-object:support Subject: [PATCH 03/37] create-diff-object:support
kpatch_line_macro_change_only on aarch64 kpatch_line_macro_change_only on aarch64
implement kpatch_line_macro_change_only on aarch64 implement kpatch_line_macro_change_only on aarch64
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
--- ---
kpatch-build/create-diff-object.c | 63 +++++++++++++++++++++++++++++++ kpatch-build/create-diff-object.c | 16 ++++++++++++++++
1 file changed, 63 insertions(+) 1 file changed, 16 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6c28280..c20f75e 100644 index 3b677d3..2ad0791 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -757,6 +757,69 @@ static bool kpatch_line_macro_change_only(struct section *sec) @@ -647,6 +647,17 @@ static bool insn_is_load_immediate(struct kpatch_elf *kelf, void *addr)
return true; break;
}
+#elif __aarch64__ + case ARM64:
+#define ARM64_INSTR_LEN 4 + /*
+ * aarch64 immediate move insns is Little-Endian:
+ *
+ * 52 80 00 41 mov w1, #0x2
+ */
+ if ((insn[3] & 0x7f) == 0x52 && (insn[2] & 0x80) == 0x80)
+ return true;
+ +
+static bool kpatch_line_macro_change_only(struct section *sec) + break;
+{ +
+ unsigned long start1, start2, size, offset; case S390:
+ struct rela *rela; /* arg2: lghi %r3, imm */
+ int lineonly = 0, found; if (insn[0] == 0xa7 && insn[1] == 0x39)
@@ -698,6 +709,7 @@ static bool kpatch_line_macro_change_only(struct kpatch_elf *kelf,
void *data1, *data2, *insn1, *insn2;
struct rela *r, *rela;
bool found, found_any = false;
+ unsigned int mov_imm_mask = ((1<<16) - 1)<<5; + unsigned int mov_imm_mask = ((1<<16) - 1)<<5;
if (sec->status != CHANGED ||
is_rela_section(sec) ||
@@ -743,6 +755,10 @@ static bool kpatch_line_macro_change_only(struct kpatch_elf *kelf,
!insn_is_load_immediate(kelf, insn2))
return false;
+ if ((*(int *)(insn1) & ~mov_imm_mask) !=
+ (*(int *)(insn2) & ~mov_imm_mask))
+ return false;
+ +
+ if (sec->status != CHANGED || found = false;
+ is_rela_section(sec) || list_for_each_entry(r, &sec->rela->relas, list) {
+ !is_text_section(sec) ||
+ sec->sh.sh_size != sec->twin->sh.sh_size ||
+ !sec->rela ||
+ sec->rela->status != SAME)
+ return 0;
+
+ start1 = (unsigned long)sec->twin->data->d_buf;
+ start2 = (unsigned long)sec->data->d_buf;
+ size = sec->sh.sh_size;
+ for (offset = 0; offset < size; offset += ARM64_INSTR_LEN) {
+ if (!memcmp((void *)start1 + offset, (void *)start2 + offset,
+ ARM64_INSTR_LEN))
+ continue;
+
+ /* verify it's a mov immediate to w1 */
+ if ((*(int *)(start1 + offset) & ~mov_imm_mask) !=
+ (*(int *)(start2 + offset) & ~mov_imm_mask))
+ return 0;
+
+ found = 0;
+ list_for_each_entry(rela, &sec->rela->relas, list) {
+ if (rela->offset < offset + ARM64_INSTR_LEN)
+ continue;
+ if (rela->string)
+ continue;
+ if (!strncmp(rela->sym->name, "__warned.", 9))
+ continue;
+ if (!strncmp(rela->sym->name, "warn_slowpath_", 14) ||
+ (!strcmp(rela->sym->name, "__warn_printk")) ||
+ (!strcmp(rela->sym->name, "__might_sleep")) ||
+ (!strcmp(rela->sym->name, "___might_sleep")) ||
+ (!strcmp(rela->sym->name, "__might_fault")) ||
+ (!strcmp(rela->sym->name, "printk")) ||
+ (!strcmp(rela->sym->name, "lockdep_rcu_suspicious"))) {
+ found = 1;
+ break;
+ }
+ return 0;
+ }
+ if (!found)
+ return 0;
+
+ lineonly = 1;
+ }
+
+ if (!lineonly)
+ ERROR("no instruction changes detected for changed section %s",
+ sec->name);
+
+ return 1;
+}
#else
static bool kpatch_line_macro_change_only(struct section *sec)
{
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From f82f5ff61b8087e203a994da3911a1c5f3dee978 Mon Sep 17 00:00:00 2001 From d4c1e4f3b5cb162bff499c1f28d11cbea626f787 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sun, 14 Nov 2021 19:53:22 +0800 Date: Sun, 14 Nov 2021 19:53:22 +0800
Subject: [PATCH 04/24] create-diff-object:support skip check func profiling Subject: [PATCH 04/37] create-diff-object:support skip check func profiling
calls calls
when kernel support livepatch without ftrace, we can skip check when kernel support livepatch without ftrace, we can skip check
@ -13,18 +13,18 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 7 insertions(+), 1 deletion(-) 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index c20f75e..7247345 100644 index 2ad0791..02a722d 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3773,6 +3773,7 @@ int main(int argc, char *argv[]) @@ -3917,6 +3917,7 @@ int main(int argc, char *argv[])
struct section *sec, *symtab; struct section *relasec, *symtab;
char *orig_obj, *patched_obj, *parent_name; char *orig_obj, *patched_obj, *parent_name;
char *parent_symtab, *mod_symvers, *patch_name, *output_obj; char *parent_symtab, *mod_symvers, *patch_name, *output_obj;
+ char *no_profiling_calls = NULL; + char *no_profiling_calls = NULL;
memset(&arguments, 0, sizeof(arguments)); memset(&arguments, 0, sizeof(arguments));
argp_parse (&argp, argc, argv, 0, NULL, &arguments); argp_parse (&argp, argc, argv, 0, NULL, &arguments);
@@ -3824,7 +3825,12 @@ int main(int argc, char *argv[]) @@ -3970,7 +3971,12 @@ int main(int argc, char *argv[])
kpatch_compare_correlated_elements(kelf_patched); kpatch_compare_correlated_elements(kelf_patched);
kpatch_mark_ignored_functions_same(kelf_patched); kpatch_mark_ignored_functions_same(kelf_patched);
kpatch_mark_ignored_sections_same(kelf_patched); kpatch_mark_ignored_sections_same(kelf_patched);
@ -39,5 +39,5 @@ index c20f75e..7247345 100644
kpatch_elf_free(kelf_orig); kpatch_elf_free(kelf_orig);
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From fb93c5a8dfbc035ade8fc40b75b85018afaeed2e Mon Sep 17 00:00:00 2001 From dbecda6959a2e0468aa75dbf647efa396a0359f7 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Tue, 25 Feb 2020 22:44:50 -0500 Date: Tue, 25 Feb 2020 22:44:50 -0500
Subject: [PATCH 05/24] create-diff-object: new static var should be included Subject: [PATCH 05/37] create-diff-object: new static var should be included
Before this patch, only global variables(no referenced) will be Before this patch, only global variables(no referenced) will be
included by kpatch-build. But some macros put some static varibles included by kpatch-build. But some macros put some static varibles
@ -18,10 +18,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 16 insertions(+) 1 file changed, 16 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 7247345..1be4fac 100644 index 02a722d..c9ebb05 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -1909,6 +1909,21 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf) @@ -1870,6 +1870,21 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf)
sym->include = 0; sym->include = 0;
} }
@ -43,7 +43,7 @@ index 7247345..1be4fac 100644
static int kpatch_include_new_globals(struct kpatch_elf *kelf) static int kpatch_include_new_globals(struct kpatch_elf *kelf)
{ {
struct symbol *sym; struct symbol *sym;
@@ -3839,6 +3854,7 @@ int main(int argc, char *argv[]) @@ -3985,6 +4000,7 @@ int main(int argc, char *argv[])
callbacks_exist = kpatch_include_callback_elements(kelf_patched); callbacks_exist = kpatch_include_callback_elements(kelf_patched);
kpatch_include_force_elements(kelf_patched); kpatch_include_force_elements(kelf_patched);
new_globals_exist = kpatch_include_new_globals(kelf_patched); new_globals_exist = kpatch_include_new_globals(kelf_patched);
@ -52,5 +52,5 @@ index 7247345..1be4fac 100644
kpatch_process_special_sections(kelf_patched, lookup); kpatch_process_special_sections(kelf_patched, lookup);
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 80b74891e1d609d7881f9c9d29fe4828c49e2d83 Mon Sep 17 00:00:00 2001 From 17cb3696430d9d73c94174006ec9922b2285390b Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Fri, 2 Nov 2018 17:24:51 +0000 Date: Fri, 2 Nov 2018 17:24:51 +0000
Subject: [PATCH 06/24] create-diff-object: fix correlate static local Subject: [PATCH 06/37] create-diff-object: fix correlate static local
variables for __param section variables for __param section
kpatch-build correlate fail when no sections reference kpatch-build correlate fail when no sections reference
@ -31,10 +31,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 4 insertions(+) 1 file changed, 4 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 1be4fac..7efe7b4 100644 index c9ebb05..64b63e3 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -1277,6 +1277,10 @@ static bool kpatch_is_normal_static_local(struct symbol *sym) @@ -1250,6 +1250,10 @@ static bool kpatch_is_normal_static_local(struct symbol *sym)
if (is_special_static(sym)) if (is_special_static(sym))
return false; return false;
@ -46,5 +46,5 @@ index 1be4fac..7efe7b4 100644
} }
-- --
2.23.0 2.33.0

View File

@ -1,28 +0,0 @@
From 42cfc6a9add67e23433bf431da74d6babe38be61 Mon Sep 17 00:00:00 2001
From: Zhiyu Hu <huzhiyu1@huawei.com>
Date: Fri, 28 Dec 2018 07:06:38 +0000
Subject: [PATCH 07/24] fix rodata.str problem
fix some rodata.str problem
Signed-off-by: Zhiyu Hu <huzhiyu1@huawei.com>
---
kpatch-build/create-diff-object.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 7efe7b4..18aff6d 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -1838,7 +1838,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
!strcmp(sec->name, ".toc") ||
!strcmp(sec->name, ".rodata") ||
(!strncmp(sec->name, ".rodata.", 8) &&
- strstr(sec->name, ".str1."))) {
+ strstr(sec->name, ".str"))) {
kpatch_include_section(sec);
}
}
--
2.23.0

View File

@ -1,7 +1,7 @@
From 3d3cb8c0b294a60faaeb68e0d7361babdc1b8902 Mon Sep 17 00:00:00 2001 From 9746f100debb0c17397c47f5d3abbe7ca4bde221 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Tue, 25 Feb 2020 23:40:37 -0500 Date: Tue, 25 Feb 2020 23:40:37 -0500
Subject: [PATCH 08/24] livepatch-patch-hook: support no active after load Subject: [PATCH 07/37] livepatch-patch-hook: support no active after load
suppport Don't active patch after loading the patch when suppport Don't active patch after loading the patch when
DISABLE_AFTER_LOAD is set. DISABLE_AFTER_LOAD is set.
@ -33,10 +33,10 @@ index 3d13ab9..b578ef3 100644
return 0; return 0;
out: out:
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index ad3a079..c85e05a 100755 index 73f8976..00ba9ac 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1176,6 +1176,11 @@ export KCFLAGS="-I$DATADIR/patch $ARCH_KCFLAGS" @@ -1160,6 +1160,11 @@ export KCFLAGS="-I$DATADIR/patch $ARCH_KCFLAGS"
if [[ "$USE_KLP" -eq 0 ]]; then if [[ "$USE_KLP" -eq 0 ]]; then
export KCPPFLAGS="-D__KPATCH_MODULE__" export KCPPFLAGS="-D__KPATCH_MODULE__"
fi fi
@ -49,5 +49,5 @@ index ad3a079..c85e05a 100755
echo "Building patch module: $MODNAME.ko" echo "Building patch module: $MODNAME.ko"
-- --
2.23.0 2.33.0

View File

@ -1,22 +1,22 @@
From 12530d7f476e8629fc7e50443f34164a43ef18b6 Mon Sep 17 00:00:00 2001 From f98adab4e8ad3333a4870aca50f9051d3fdf20c9 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 06:44:06 -0500 Date: Wed, 26 Feb 2020 06:44:06 -0500
Subject: [PATCH 09/24] kpatch-build: enhance for out of tree module Subject: [PATCH 08/37] kpatch-build: enhance for out of tree module
support set USERMODBUILDDIR to build patch for out support set USERMODBUILDDIR to build patch for out
of tree module. of tree module.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
--- ---
kpatch-build/kpatch-build | 62 +++++++++++++++++++++++++++++++-------- kpatch-build/kpatch-build | 71 ++++++++++++++++++++++++++++++---------
kpatch-build/kpatch-cc | 4 ++- kpatch-build/kpatch-cc | 4 ++-
2 files changed, 53 insertions(+), 13 deletions(-) 2 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index c85e05a..3aca1f3 100755 index 00ba9ac..139ebb1 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -492,7 +492,11 @@ filter_parent_obj() @@ -444,7 +444,11 @@ filter_parent_obj()
local dir="${1}" local dir="${1}"
local file="${2}" local file="${2}"
@ -29,7 +29,7 @@ index c85e05a..3aca1f3 100755
} }
find_parent_obj() { find_parent_obj() {
@@ -514,6 +518,11 @@ find_parent_obj() { @@ -466,6 +470,11 @@ find_parent_obj() {
num="$(find . -name ".*.cmd" -print0 | xargs -0 grep -lw "$grepname" | filter_parent_obj "${pdir}" "${file}" | wc -l)" num="$(find . -name ".*.cmd" -print0 | xargs -0 grep -lw "$grepname" | filter_parent_obj "${pdir}" "${file}" | wc -l)"
[[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")" [[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")"
fi fi
@ -41,27 +41,54 @@ index c85e05a..3aca1f3 100755
else else
parent="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | head -n1)" parent="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | head -n1)"
num="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | wc -l)" num="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | wc -l)"
@@ -703,6 +712,10 @@ if [[ -n "$SRCRPM" ]]; then @@ -655,7 +664,11 @@ if [[ -n "$SRCRPM" ]]; then
ARCHVERSION="${ARCHVERSION#alt-}" ARCHVERSION="${ARCHVERSION#alt-}"
fi fi
-if [[ -n "$OOT_MODULE" ]] && [[ -z "$OOT_MODULE_SRCDIR" ]]; then
+if [[ -n "$USERMODBUILDDIR" ]]; then +if [[ -n "$USERMODBUILDDIR" ]]; then
+ OOT_MODULE="yes" + OOT_MODULE="yes"
+fi +fi
+ +
if [[ -n "$OOT_MODULE" ]] && [[ -z "$USERSRCDIR" ]]; then +if [[ -n "$OOT_MODULE" ]] && [[ "$OOT_MODULE" != "yes" ]] && [[ -z "$OOT_MODULE_SRCDIR" ]]; then
warn "--oot-module requires --sourcedir" warn "--oot-module requires --oot-module-src"
exit 1 exit 1
@@ -720,7 +733,7 @@ if [[ -n "$USERSRCDIR" ]]; then fi
@@ -665,7 +678,7 @@ mkdir -p "$TEMPDIR" || die "Couldn't create $TEMPDIR"
rm -rf "${TEMPDIR:?}"/*
rm -f "$LOGFILE"
-if [[ -n "$USERSRCDIR" ]]; then
+if [[ -n "$USERSRCDIR" ]] && [[ "$OOT_MODULE" != "yes" ]]; then
KERNEL_SRCDIR="$USERSRCDIR"
[[ -z "$VMLINUX" ]] && VMLINUX="$KERNEL_SRCDIR"/vmlinux
@@ -685,17 +698,21 @@ if [[ -n "$USERSRCDIR" ]]; then
fi fi
SRCDIR="$USERSRCDIR" fi
- if [[ -z "$OOT_MODULE" ]]; then -if [[ -n "$OOT_MODULE" ]]; then
+ if [[ -z "$OOT_MODULE" || "$OOT_MODULE" == "yes" ]]; then +if [[ -n "$OOT_MODULE" ]] && [[ "$OOT_MODULE" != "yes" ]]; then
[[ -z "$VMLINUX" ]] && VMLINUX="$SRCDIR"/vmlinux ARCHVERSION="$(modinfo -F vermagic "$OOT_MODULE" | awk '{print $1}')"
[[ ! -e "$VMLINUX" ]] && die "can't find vmlinux" fi
@@ -742,7 +755,7 @@ if [[ "$ARCHVERSION" =~ - ]]; then [[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)"
if [[ -n "$OOT_MODULE" ]]; then
- if [[ -z "$USERSRCDIR" ]]; then
+ if [[ -z "$USERSRCDIR" ]] || [[ "$OOT_MODULE" == "yes" ]]; then
KERNEL_SRCDIR="/lib/modules/$ARCHVERSION/build/"
fi
- BUILDDIR="$OOT_MODULE_SRCDIR"
+ if [[ "$OOT_MODULE" == "yes" ]]; then
+ BUILDDIR="$USERSRCDIR"
+ else
+ BUILDDIR="$OOT_MODULE_SRCDIR"
+ fi
else
BUILDDIR="$KERNEL_SRCDIR"
fi
@@ -709,7 +726,7 @@ if [[ "$ARCHVERSION" =~ - ]]; then
fi fi
[[ "$ARCHVERSION" =~ .el7a. ]] && ALT="-alt" [[ "$ARCHVERSION" =~ .el7a. ]] && ALT="-alt"
@ -70,18 +97,16 @@ index c85e05a..3aca1f3 100755
# Don't check external file. # Don't check external file.
# shellcheck disable=SC1090 # shellcheck disable=SC1090
@@ -870,7 +883,9 @@ fi @@ -851,7 +868,7 @@ fi
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$SRCDIR"/.config
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$KERNEL_SRCDIR"/.config
[[ ! -e "$CONFIGFILE" ]] && die "can't find config file" [[ ! -e "$CONFIGFILE" ]] && die "can't find config file"
if [[ ! "$CONFIGFILE" -ef "$SRCDIR"/.config ]] ; then -if [[ -z "$OOT_MODULE" && ! "$CONFIGFILE" -ef "$KERNEL_SRCDIR"/.config ]] ; then
- cp -f "$CONFIGFILE" "$SRCDIR/.config" || die +if [[ ! "$CONFIGFILE" -ef "$KERNEL_SRCDIR"/.config ]] ; then
+ if [[ -z "$OOT_MODULE" ]] ; then cp -f "$CONFIGFILE" "$KERNEL_SRCDIR/.config" || die
+ cp -f "$CONFIGFILE" "$SRCDIR/.config" || die
+ fi
fi fi
# kernel option checking @@ -925,7 +942,7 @@ if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
@@ -947,7 +962,7 @@ if [[ "$CONFIG_CC_IS_CLANG" -eq 1 ]]; then
fi fi
if [[ "$SKIPCOMPILERCHECK" -eq 0 ]]; then if [[ "$SKIPCOMPILERCHECK" -eq 0 ]]; then
@ -90,7 +115,7 @@ index c85e05a..3aca1f3 100755
target="$OOT_MODULE" target="$OOT_MODULE"
else else
target="$VMLINUX" target="$VMLINUX"
@@ -1005,10 +1020,16 @@ fi @@ -987,10 +1004,16 @@ fi
# $TARGETS used as list, no quotes. # $TARGETS used as list, no quotes.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -102,14 +127,14 @@ index c85e05a..3aca1f3 100755
+fi +fi
# Save original module symvers # Save original module symvers
-cp -f "$SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die -cp -f "$BUILDDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die
+if [[ "$OOT_MODULE" != "yes" ]]; then +if [[ "$OOT_MODULE" != "yes" ]]; then
+ cp -f "$SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die + cp -f "$BUILDDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die
+fi +fi
echo "Building patched source" echo "Building patched source"
apply_patches apply_patches
@@ -1018,7 +1039,12 @@ export KPATCH_GCC_SRCDIR="$SRCDIR" @@ -1000,7 +1023,12 @@ export KPATCH_GCC_SRCDIR="$BUILDDIR"
save_env save_env
# $TARGETS used as list, no quotes. # $TARGETS used as list, no quotes.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -123,53 +148,52 @@ index c85e05a..3aca1f3 100755
# source.c:(.section+0xFF): undefined reference to `symbol' # source.c:(.section+0xFF): undefined reference to `symbol'
grep "undefined reference" "$LOGFILE" | sed -r "s/^.*\`(.*)'$/\\1/" \ grep "undefined reference" "$LOGFILE" | sed -r "s/^.*\`(.*)'$/\\1/" \
@@ -1033,7 +1059,7 @@ fi @@ -1015,7 +1043,7 @@ fi
[[ -n "$OOT_MODULE" ]] || grep -q vmlinux "$SRCDIR/Module.symvers" || die "truncated $SRCDIR/Module.symvers file" grep -q vmlinux "$KERNEL_SRCDIR/Module.symvers" || die "truncated $KERNEL_SRCDIR/Module.symvers file"
-if [[ "$CONFIG_MODVERSIONS" -eq 1 ]]; then -if [[ -n "$CONFIG_MODVERSIONS" ]]; then
+if [[ "$CONFIG_MODVERSIONS" -eq 1 ]] && [[ "$OOT_MODULE" != "yes" ]]; then +if [[ -n "$CONFIG_MODVERSIONS" ]] && [[ "$OOT_MODULE" != "yes" ]]; then
while read -ra sym_line; do trace_off "reading Module.symvers"
if [[ ${#sym_line[@]} -lt 4 ]]; then while read -ra sym_line; do
die "Malformed ${TEMPDIR}/Module.symvers file" if [[ ${#sym_line[@]} -lt 4 ]]; then
@@ -1061,7 +1087,11 @@ fi @@ -1045,7 +1073,11 @@ fi
for i in $(cat "$TEMPDIR/changed_objs") for i in $(cat "$TEMPDIR/changed_objs")
do do
mkdir -p "$TEMPDIR/patched/$(dirname "$i")" || die mkdir -p "$TEMPDIR/patched/$(dirname "$i")" || die
- cp -f "$SRCDIR/$i" "$TEMPDIR/patched/$i" || die - cp -f "$BUILDDIR/$i" "$TEMPDIR/patched/$i" || die
+ if [ -z "$USERMODBUILDDIR" ];then + if [ -z "$USERMODBUILDDIR" ];then
+ cp -f "$SRCDIR/$i" "$TEMPDIR/patched/$i" || die + cp -f "$BUILDDIR/$i" "$TEMPDIR/patched/$i" || die
+ else + else
+ cp -f "$i" "$TEMPDIR/patched/$i" || die + cp -f "$i" "$TEMPDIR/patched/$i" || die
+ fi + fi
done done
echo "Extracting new and modified ELF sections" echo "Extracting new and modified ELF sections"
@@ -1095,7 +1125,7 @@ CHANGED=0 @@ -1079,7 +1111,7 @@ CHANGED=0
ERROR=0 ERROR=0
# Prepare OOT module symvers file # Prepare OOT module symvers file
-if [[ -n "$OOT_MODULE" ]]; then -if [[ -n "$OOT_MODULE" ]]; then
+if [[ -n "$OOT_MODULE" ]] && [[ "$OOT_MODULE" != "yes" ]]; then +if [[ -n "$OOT_MODULE" ]] && [[ "$OOT_MODULE" != "yes" ]]; then
BUILDDIR="/lib/modules/$ARCHVERSION/build/" cp -f "$OOT_MODULE_SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die
cp -f "$SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${KERNEL_SRCDIR}/Module.symvers" >> "$TEMPDIR/Module.symvers"
awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${BUILDDIR}/Module.symvers" >> "$TEMPDIR/Module.symvers" fi
@@ -1131,6 +1161,14 @@ for i in $FILES; do @@ -1115,6 +1147,13 @@ for i in $FILES; do
KOBJFILE_PATH="${TEMPDIR}/module/$KOBJFILE" KOBJFILE_PATH="${TEMPDIR}/module/$KOBJFILE"
SYMTAB="${KOBJFILE_PATH}.symtab" SYMTAB="${KOBJFILE_PATH}.symtab"
SYMVERS_FILE="$SRCDIR/Module.symvers" SYMVERS_FILE="$BUILDDIR/Module.symvers"
+ +
+ if [ "$OOT_MODULE" == "yes" ];then + if [ "$OOT_MODULE" == "yes" ];then
+ BUILDDIR="/lib/modules/$ARCHVERSION/build/"
+ SYMVERS_FILE="$TEMPDIR/Module.symvers" + SYMVERS_FILE="$TEMPDIR/Module.symvers"
+ [[ -e $SRCDIR/Module.symvers ]] && cp "$SRCDIR/Module.symvers" "$SYMVERS_FILE" + [[ -e $BUILDDIR/Module.symvers ]] && cp "$BUILDDIR/Module.symvers" "$SYMVERS_FILE"
+ [[ -e $USERMODBUILDDIR/Module.symvers ]] && cp "$USERMODBUILDDIR/Module.symvers" $SYMVERS_FILE + [[ -e $USERMODBUILDDIR/Module.symvers ]] && cp "$USERMODBUILDDIR/Module.symvers" $SYMVERS_FILE
+ awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${BUILDDIR}/Module.symvers" >> "$SYMVERS_FILE" + awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${KERNEL_SRCDIR}/Module.symvers" >> "$SYMVERS_FILE"
+ fi + fi
fi fi
readelf -s --wide "$KOBJFILE_PATH" > "$SYMTAB" "$READELF" -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
@@ -1283,7 +1321,7 @@ fi @@ -1263,7 +1302,7 @@ fi
# column containing lines unique to first file. # column containing lines unique to first file.
UNDEFINED=$(comm -23 <(sort -u "${TEMPDIR}"/undefined_references) \ UNDEFINED=$(comm -23 <(sort -u "${TEMPDIR}"/undefined_references) \
<(sort -u "${TEMPDIR}"/new_symbols) | tr '\n' ' ') <(sort -u "${TEMPDIR}"/new_symbols) | tr '\n' ' ')
@ -179,13 +203,13 @@ index c85e05a..3aca1f3 100755
cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die
diff --git a/kpatch-build/kpatch-cc b/kpatch-build/kpatch-cc diff --git a/kpatch-build/kpatch-cc b/kpatch-build/kpatch-cc
index 476436f..7ee1655 100755 index 6f0063e..991bcad 100755
--- a/kpatch-build/kpatch-cc --- a/kpatch-build/kpatch-cc
+++ b/kpatch-build/kpatch-cc +++ b/kpatch-build/kpatch-cc
@@ -24,7 +24,9 @@ if [[ "$TOOLCHAINCMD" =~ ^(.*-)?gcc$ || "$TOOLCHAINCMD" =~ ^(.*-)?clang$ ]] ; th @@ -24,7 +24,9 @@ if [[ "$TOOLCHAINCMD" =~ ^(.*-)?gcc$ || "$TOOLCHAINCMD" =~ ^(.*-)?clang$ ]] ; th
[[ "$obj" = */.tmp_*.o ]] && obj="${obj/.tmp_/}" [[ "$obj" = */.tmp_*.o ]] && obj="${obj/.tmp_/}"
relobj=${obj//$KPATCH_GCC_SRCDIR\//} relobj=${obj##$KPATCH_GCC_SRCDIR/}
- case "$relobj" in - case "$relobj" in
+ tmpobj=$(readlink -f $obj) + tmpobj=$(readlink -f $obj)
+ relobj2=${tmpobj//$KPATCH_GCC_SRCDIR\//} + relobj2=${tmpobj//$KPATCH_GCC_SRCDIR\//}
@ -194,5 +218,5 @@ index 476436f..7ee1655 100755
*built-in.o|\ *built-in.o|\
*built-in.a|\ *built-in.a|\
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 86bae0f77f1e11f6b64eb950c739f7c6b444eb43 Mon Sep 17 00:00:00 2001 From 413d7e988102a6cd085650909c98d54656295de9 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 07:36:59 -0500 Date: Wed, 26 Feb 2020 07:36:59 -0500
Subject: [PATCH 10/24] support c++ kernel module Subject: [PATCH 09/37] support c++ kernel module
support GNU_UNIQUE type symbols. support GNU_UNIQUE type symbols.
support .group section corelation. support .group section corelation.
@ -16,10 +16,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
4 files changed, 45 insertions(+), 20 deletions(-) 4 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 18aff6d..5903803 100644 index 64b63e3..7e415dd 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -539,7 +539,7 @@ static void kpatch_compare_correlated_nonrela_section(struct section *sec) @@ -554,7 +554,7 @@ static void kpatch_compare_correlated_nonrela_section(struct section *sec)
{ {
struct section *sec1 = sec, *sec2 = sec->twin; struct section *sec1 = sec, *sec2 = sec->twin;
@ -28,7 +28,7 @@ index 18aff6d..5903803 100644
memcmp(sec1->data->d_buf, sec2->data->d_buf, sec1->data->d_size)) memcmp(sec1->data->d_buf, sec2->data->d_buf, sec1->data->d_size))
sec->status = CHANGED; sec->status = CHANGED;
else else
@@ -555,7 +555,7 @@ static void kpatch_compare_correlated_section(struct section *sec) @@ -570,7 +570,7 @@ static void kpatch_compare_correlated_section(struct section *sec)
sec1->sh.sh_flags != sec2->sh.sh_flags || sec1->sh.sh_flags != sec2->sh.sh_flags ||
sec1->sh.sh_entsize != sec2->sh.sh_entsize || sec1->sh.sh_entsize != sec2->sh.sh_entsize ||
(sec1->sh.sh_addralign != sec2->sh.sh_addralign && (sec1->sh.sh_addralign != sec2->sh.sh_addralign &&
@ -37,7 +37,7 @@ index 18aff6d..5903803 100644
DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name); DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name);
/* Short circuit for mcount sections, we rebuild regardless */ /* Short circuit for mcount sections, we rebuild regardless */
@@ -1024,6 +1024,34 @@ static void kpatch_correlate_section(struct section *sec_orig, @@ -1006,6 +1006,34 @@ static void kpatch_correlate_section(struct section *sec_orig,
kpatch_correlate_symbol(sec_orig->sym, sec_patched->sym); kpatch_correlate_symbol(sec_orig->sym, sec_patched->sym);
} }
@ -72,7 +72,7 @@ index 18aff6d..5903803 100644
static void kpatch_correlate_sections(struct list_head *seclist_orig, static void kpatch_correlate_sections(struct list_head *seclist_orig,
struct list_head *seclist_patched) struct list_head *seclist_patched)
{ {
@@ -1047,10 +1075,7 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig, @@ -1029,10 +1057,7 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig,
* Changed group sections are currently not supported. * Changed group sections are currently not supported.
*/ */
if (sec_orig->sh.sh_type == SHT_GROUP) { if (sec_orig->sh.sh_type == SHT_GROUP) {
@ -84,7 +84,7 @@ index 18aff6d..5903803 100644
continue; continue;
} }
@@ -1725,17 +1750,6 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf) @@ -1682,17 +1707,6 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf)
errs++; errs++;
} }
@ -103,7 +103,7 @@ index 18aff6d..5903803 100644
* ensure we aren't including .data.* or .bss.* * ensure we aren't including .data.* or .bss.*
* (.data.unlikely and .data.once is ok b/c it only has __warned vars) * (.data.unlikely and .data.once is ok b/c it only has __warned vars)
diff --git a/kpatch-build/kpatch-cc b/kpatch-build/kpatch-cc diff --git a/kpatch-build/kpatch-cc b/kpatch-build/kpatch-cc
index 7ee1655..80d310c 100755 index 991bcad..5e241dd 100755
--- a/kpatch-build/kpatch-cc --- a/kpatch-build/kpatch-cc
+++ b/kpatch-build/kpatch-cc +++ b/kpatch-build/kpatch-cc
@@ -13,7 +13,9 @@ fi @@ -13,7 +13,9 @@ fi
@ -118,10 +118,10 @@ index 7ee1655..80d310c 100755
if [ "$1" = "-o" ]; then if [ "$1" = "-o" ]; then
obj="$2" obj="$2"
diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c
index 68d5c86..2df9105 100644 index 069e102..877deac 100644
--- a/kpatch-build/kpatch-elf.c --- a/kpatch-build/kpatch-elf.c
+++ b/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c
@@ -712,8 +712,14 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf) @@ -851,8 +851,14 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf)
unsigned int index; unsigned int index;
index = 1; /* elf write function handles NULL section 0 */ index = 1; /* elf write function handles NULL section 0 */
@ -138,10 +138,10 @@ index 68d5c86..2df9105 100644
index = 0; index = 0;
list_for_each_entry(sym, &kelf->symbols, list) { list_for_each_entry(sym, &kelf->symbols, list) {
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index 0323c61..e81e934 100644 index f2596b1..829250f 100644
--- a/kpatch-build/lookup.c --- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c
@@ -304,6 +304,8 @@ static void symtab_read(struct lookup_table *table, char *path) @@ -306,6 +306,8 @@ static void symtab_read(struct lookup_table *table, char *path)
table->obj_syms[i].bind = STB_GLOBAL; table->obj_syms[i].bind = STB_GLOBAL;
} else if (!strcmp(bind, "WEAK")) { } else if (!strcmp(bind, "WEAK")) {
table->obj_syms[i].bind = STB_WEAK; table->obj_syms[i].bind = STB_WEAK;
@ -150,7 +150,7 @@ index 0323c61..e81e934 100644
} else { } else {
ERROR("unknown symbol bind %s", bind); ERROR("unknown symbol bind %s", bind);
} }
@@ -528,7 +530,8 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name, @@ -530,7 +532,8 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name,
memset(result, 0, sizeof(*result)); memset(result, 0, sizeof(*result));
for_each_obj_symbol(i, sym, table) { for_each_obj_symbol(i, sym, table) {
@ -161,5 +161,5 @@ index 0323c61..e81e934 100644
if (result->objname) if (result->objname)
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 34a0c47eb0f786222b3f2e1fe544f71687920943 Mon Sep 17 00:00:00 2001 From 4821b72a908ed4ded1f0a37afa238af62d0f778a Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 22:03:55 -0500 Date: Wed, 26 Feb 2020 22:03:55 -0500
Subject: [PATCH 11/24] symbol lookup enhancement Subject: [PATCH 10/37] symbol lookup enhancement
For symbols which have same name in one module or have For symbols which have same name in one module or have
length longger than KSYM_NAME_LEN(128 bytes). we add length longger than KSYM_NAME_LEN(128 bytes). we add
@ -44,10 +44,10 @@ index da4f6a0..9df7818 100644
struct kpatch_pre_patch_callback { struct kpatch_pre_patch_callback {
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 5903803..ea1e01b 100644 index 7e415dd..e11a900 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3032,6 +3032,14 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, @@ -3087,6 +3087,14 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
funcs[index].old_size = symbol.size; funcs[index].old_size = symbol.size;
funcs[index].new_size = sym->sym.st_size; funcs[index].new_size = sym->sym.st_size;
funcs[index].sympos = symbol.sympos; funcs[index].sympos = symbol.sympos;
@ -62,17 +62,17 @@ index 5903803..ea1e01b 100644
/* /*
* Add a relocation that will populate the * Add a relocation that will populate the
@@ -3050,7 +3058,8 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, @@ -3105,7 +3113,8 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
ALLOC_LINK(rela, &relasec->relas); ALLOC_LINK(rela, &relasec->relas);
rela->sym = strsym; rela->sym = strsym;
rela->type = ABSOLUTE_RELA_TYPE; rela->type = absolute_rela_type(kelf);
- rela->addend = offset_of_string(&kelf->strings, sym->name); - rela->addend = offset_of_string(&kelf->strings, sym->name);
+ rela->addend = offset_of_string(&kelf->strings, + rela->addend = offset_of_string(&kelf->strings,
+ strndup(sym->name, KSYM_NAME_LEN-1)); + strndup(sym->name, KSYM_NAME_LEN-1));
rela->offset = (unsigned int)(index * sizeof(*funcs) + rela->offset = (unsigned int)(index * sizeof(*funcs) +
offsetof(struct kpatch_patch_func, name)); offsetof(struct kpatch_patch_func, name));
@@ -3274,6 +3283,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, @@ -3345,6 +3354,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
bool special; bool special;
bool vmlinux = !strcmp(objname, "vmlinux"); bool vmlinux = !strcmp(objname, "vmlinux");
struct special_section *s; struct special_section *s;
@ -80,7 +80,7 @@ index 5903803..ea1e01b 100644
/* count rela entries that need to be dynamic */ /* count rela entries that need to be dynamic */
nr = 0; nr = 0;
@@ -3370,12 +3380,34 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, @@ -3445,12 +3455,34 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
rela->sym->name, symbol.objname, rela->sym->name, symbol.objname,
symbol.sympos); symbol.sympos);
@ -106,7 +106,7 @@ index 5903803..ea1e01b 100644
+ /* add rela to fill in ref_name field */ + /* add rela to fill in ref_name field */
+ ALLOC_LINK(rela2, &krela_sec->rela->relas); + ALLOC_LINK(rela2, &krela_sec->rela->relas);
+ rela2->sym = strsym; + rela2->sym = strsym;
+ rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type(kelf);
+ rela2->addend = offset_of_string(&kelf->strings, + rela2->addend = offset_of_string(&kelf->strings,
+ refsym.name); + refsym.name);
+ rela2->offset = (unsigned int)(index * sizeof(*krelas) + + rela2->offset = (unsigned int)(index * sizeof(*krelas) +
@ -116,17 +116,17 @@ index 5903803..ea1e01b 100644
ksyms[index].sympos = symbol.sympos; ksyms[index].sympos = symbol.sympos;
ksyms[index].type = rela->sym->type; ksyms[index].type = rela->sym->type;
ksyms[index].bind = rela->sym->bind; ksyms[index].bind = rela->sym->bind;
@@ -3384,7 +3416,8 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, @@ -3459,7 +3491,8 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
ALLOC_LINK(rela2, &ksym_sec->rela->relas); ALLOC_LINK(rela2, &ksym_sec->rela->relas);
rela2->sym = strsym; rela2->sym = strsym;
rela2->type = ABSOLUTE_RELA_TYPE; rela2->type = absolute_rela_type(kelf);
- rela2->addend = offset_of_string(&kelf->strings, rela->sym->name); - rela2->addend = offset_of_string(&kelf->strings, rela->sym->name);
+ rela2->addend = offset_of_string(&kelf->strings, + rela2->addend = offset_of_string(&kelf->strings,
+ strndup(rela->sym->name, KSYM_NAME_LEN-1)); + strndup(rela->sym->name, KSYM_NAME_LEN-1));
rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \ rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \
offsetof(struct kpatch_symbol, name)); offsetof(struct kpatch_symbol, name));
@@ -3403,6 +3436,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, @@ -3478,6 +3511,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
krelas[index].addend = rela->addend; krelas[index].addend = rela->addend;
krelas[index].type = rela->type; krelas[index].type = rela->type;
krelas[index].external = !vmlinux && symbol.exported; krelas[index].external = !vmlinux && symbol.exported;
@ -135,7 +135,7 @@ index 5903803..ea1e01b 100644
/* add rela to fill in krelas[index].dest field */ /* add rela to fill in krelas[index].dest field */
ALLOC_LINK(rela2, &krela_sec->rela->relas); ALLOC_LINK(rela2, &krela_sec->rela->relas);
diff --git a/kpatch-build/create-klp-module.c b/kpatch-build/create-klp-module.c diff --git a/kpatch-build/create-klp-module.c b/kpatch-build/create-klp-module.c
index d1b03fe..547e587 100644 index e942b9e..b77028f 100644
--- a/kpatch-build/create-klp-module.c --- a/kpatch-build/create-klp-module.c
+++ b/kpatch-build/create-klp-module.c +++ b/kpatch-build/create-klp-module.c
@@ -38,7 +38,9 @@ enum loglevel loglevel = NORMAL; @@ -38,7 +38,9 @@ enum loglevel loglevel = NORMAL;
@ -200,16 +200,16 @@ index d1b03fe..547e587 100644
ERROR("error finding or adding ksym to symtab"); ERROR("error finding or adding ksym to symtab");
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 3aca1f3..722d362 100755 index 139ebb1..f6855ed 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1162,6 +1162,18 @@ for i in $FILES; do @@ -1148,6 +1148,18 @@ for i in $FILES; do
SYMTAB="${KOBJFILE_PATH}.symtab" SYMTAB="${KOBJFILE_PATH}.symtab"
SYMVERS_FILE="$SRCDIR/Module.symvers" SYMVERS_FILE="$BUILDDIR/Module.symvers"
+ unset KCFLAGS + unset KCFLAGS
+ remove_patches + remove_patches
+ cd "$SRCDIR" || die + cd "$BUILDDIR" || die
+ if [ -z "$USERMODBUILDDIR" ];then + if [ -z "$USERMODBUILDDIR" ];then
+ make "-j$CPUS" $TARGETS 2>&1 | logger || die + make "-j$CPUS" $TARGETS 2>&1 | logger || die
+ else + else
@ -220,8 +220,8 @@ index 3aca1f3..722d362 100755
+ cd "$TEMPDIR" || die + cd "$TEMPDIR" || die
+ +
if [ "$OOT_MODULE" == "yes" ];then if [ "$OOT_MODULE" == "yes" ];then
BUILDDIR="/lib/modules/$ARCHVERSION/build/"
SYMVERS_FILE="$TEMPDIR/Module.symvers" SYMVERS_FILE="$TEMPDIR/Module.symvers"
[[ -e $BUILDDIR/Module.symvers ]] && cp "$BUILDDIR/Module.symvers" "$SYMVERS_FILE"
diff --git a/kpatch-build/kpatch-intermediate.h b/kpatch-build/kpatch-intermediate.h diff --git a/kpatch-build/kpatch-intermediate.h b/kpatch-build/kpatch-intermediate.h
index 2036cb3..2589959 100644 index 2036cb3..2589959 100644
--- a/kpatch-build/kpatch-intermediate.h --- a/kpatch-build/kpatch-intermediate.h
@ -236,7 +236,7 @@ index 2036cb3..2589959 100644
struct kpatch_arch { struct kpatch_arch {
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index e81e934..238541c 100644 index 829250f..71ede78 100644
--- a/kpatch-build/lookup.c --- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c
@@ -45,6 +45,7 @@ struct object_symbol { @@ -45,6 +45,7 @@ struct object_symbol {
@ -247,7 +247,7 @@ index e81e934..238541c 100644
}; };
struct export_symbol { struct export_symbol {
@@ -297,6 +298,7 @@ static void symtab_read(struct lookup_table *table, char *path) @@ -299,6 +300,7 @@ static void symtab_read(struct lookup_table *table, char *path)
table->obj_syms[i].addr = addr; table->obj_syms[i].addr = addr;
table->obj_syms[i].size = strtoul(size, NULL, 0); table->obj_syms[i].size = strtoul(size, NULL, 0);
@ -255,7 +255,7 @@ index e81e934..238541c 100644
if (!strcmp(bind, "LOCAL")) { if (!strcmp(bind, "LOCAL")) {
table->obj_syms[i].bind = STB_LOCAL; table->obj_syms[i].bind = STB_LOCAL;
@@ -457,6 +459,17 @@ static bool lookup_local_symbol(struct lookup_table *table, @@ -459,6 +461,17 @@ static bool lookup_local_symbol(struct lookup_table *table,
if (sym->bind == STB_LOCAL && !strcmp(sym->name, if (sym->bind == STB_LOCAL && !strcmp(sym->name,
lookup_sym->name)) lookup_sym->name))
sympos++; sympos++;
@ -273,7 +273,7 @@ index e81e934..238541c 100644
if (lookup_sym->lookup_table_file_sym == sym) { if (lookup_sym->lookup_table_file_sym == sym) {
in_file = 1; in_file = 1;
@@ -527,11 +540,22 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name, @@ -529,11 +542,22 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name,
{ {
struct object_symbol *sym; struct object_symbol *sym;
int i; int i;
@ -298,7 +298,7 @@ index e81e934..238541c 100644
!strcmp(sym->name, name)) { !strcmp(sym->name, name)) {
if (result->objname) if (result->objname)
@@ -540,7 +564,7 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name, @@ -542,7 +566,7 @@ static bool lookup_global_symbol(struct lookup_table *table, char *name,
result->objname = table->objname; result->objname = table->objname;
result->addr = sym->addr; result->addr = sym->addr;
result->size = sym->size; result->size = sym->size;
@ -307,7 +307,7 @@ index e81e934..238541c 100644
result->global = true; result->global = true;
result->exported = is_exported(table, name); result->exported = is_exported(table, name);
} }
@@ -560,3 +584,132 @@ bool lookup_symbol(struct lookup_table *table, struct symbol *sym, @@ -562,3 +586,132 @@ bool lookup_symbol(struct lookup_table *table, struct symbol *sym,
return lookup_exported_symbol(table, sym->name, result); return lookup_exported_symbol(table, sym->name, result);
} }
@ -478,5 +478,5 @@ index e1277f1..21aceb4 100644
#endif /* _LOOKUP_H_ */ #endif /* _LOOKUP_H_ */
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 344dfff72d5a2d574d8d7804277bf587af45743d Mon Sep 17 00:00:00 2001 From 1a7e97179174f64a99e27649c1e5ff2c322bfa26 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 20:28:13 -0500 Date: Wed, 26 Feb 2020 20:28:13 -0500
Subject: [PATCH 12/24] Add running kernel symbol table to help symbol lookup Subject: [PATCH 11/37] Add running kernel symbol table to help symbol lookup
For some duplicate symbols whose section have no other For some duplicate symbols whose section have no other
symbols, we need running kernel symbol table to help symbols, we need running kernel symbol table to help
@ -13,7 +13,7 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 73 insertions(+) 1 file changed, 73 insertions(+)
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index 238541c..2cdff67 100644 index 71ede78..d3b6ae9 100644
--- a/kpatch-build/lookup.c --- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c
@@ -46,6 +46,7 @@ struct object_symbol { @@ -46,6 +46,7 @@ struct object_symbol {
@ -24,7 +24,7 @@ index 238541c..2cdff67 100644
}; };
struct export_symbol { struct export_symbol {
@@ -409,10 +410,62 @@ static void symvers_read(struct lookup_table *table, char *path) @@ -411,10 +412,62 @@ static void symvers_read(struct lookup_table *table, char *path)
fclose(file); fclose(file);
} }
@ -87,7 +87,7 @@ index 238541c..2cdff67 100644
table = malloc(sizeof(*table)); table = malloc(sizeof(*table));
if (!table) if (!table)
@@ -422,6 +475,9 @@ struct lookup_table *lookup_open(char *symtab_path, char *objname, @@ -424,6 +477,9 @@ struct lookup_table *lookup_open(char *symtab_path, char *objname,
table->objname = objname; table->objname = objname;
symtab_read(table, symtab_path); symtab_read(table, symtab_path);
symvers_read(table, symvers_path); symvers_read(table, symvers_path);
@ -97,7 +97,7 @@ index 238541c..2cdff67 100644
find_local_syms_multiple(table, kelf); find_local_syms_multiple(table, kelf);
@@ -687,6 +743,23 @@ int lookup_ref_symbol_offset(struct lookup_table *table, @@ -689,6 +745,23 @@ int lookup_ref_symbol_offset(struct lookup_table *table,
} }
} }
@ -122,5 +122,5 @@ index 238541c..2cdff67 100644
} }
-- --
2.23.0 2.33.0

View File

@ -0,0 +1,125 @@
From 66c81cb4c67b21dea3be2d93edf4273346c880e0 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 20:43:34 -0500
Subject: [PATCH 12/37] livepatch-patch-hook: support force enable/disable
we use force to indicate function which bypass stack check
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
kmod/patch/kpatch-patch.h | 1 +
kmod/patch/livepatch-patch-hook.c | 17 +++++++++++++++++
kpatch-build/kpatch-build | 17 +++++++++++++++--
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/kmod/patch/kpatch-patch.h b/kmod/patch/kpatch-patch.h
index 9df7818..6e39364 100644
--- a/kmod/patch/kpatch-patch.h
+++ b/kmod/patch/kpatch-patch.h
@@ -64,4 +64,5 @@ struct kpatch_post_unpatch_callback {
char *objname;
};
+extern unsigned long __kpatch_force_funcs[], __kpatch_force_funcs_end[];
#endif /* _KPATCH_PATCH_H_ */
diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c
index b578ef3..71439d9 100644
--- a/kmod/patch/livepatch-patch-hook.c
+++ b/kmod/patch/livepatch-patch-hook.c
@@ -432,6 +432,16 @@ extern struct kpatch_patch_func __kpatch_funcs[], __kpatch_funcs_end[];
extern struct kpatch_patch_dynrela __kpatch_dynrelas[], __kpatch_dynrelas_end[];
#endif
+static int patch_is_func_forced(unsigned long addr)
+{
+ unsigned long *a;
+
+ for (a = __kpatch_force_funcs; a < __kpatch_force_funcs_end; a++)
+ if (*a == addr)
+ return 1;
+ return 0;
+}
+
static int __init patch_init(void)
{
struct kpatch_patch_func *kfunc;
@@ -520,6 +530,13 @@ static int __init patch_init(void)
lfunc = &lfuncs[j];
lfunc->old_name = func->kfunc->name;
lfunc->new_func = (void *)func->kfunc->new_addr;
+#if defined(__KLP_SUPPORT_FORCE__)
+#ifdef __ALL_FORCE__
+ lfunc->force = 1;
+#else
+ lfunc->force = patch_is_func_forced(func->kfunc->new_addr);
+#endif
+#endif
#ifdef HAVE_SYMPOS
lfunc->old_sympos = func->kfunc->sympos;
#else
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index f6855ed..a5324db 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -377,7 +377,7 @@ find_special_section_data() {
# shellcheck disable=SC2086
SPECIAL_VARS="$("$READELF" -wi "$VMLINUX" |
gawk --non-decimal-data $AWK_OPTIONS '
- BEGIN { a = b = e = f = i = j = o = p = s = 0 }
+ BEGIN { a = b = e = f = i = j = o = p = s = c = d = 0 }
# Set state if name matches
check_a && a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next}
@@ -389,6 +389,7 @@ find_special_section_data() {
check_o && o == 0 && /DW_AT_name.* orc_entry[[:space:]]*$/ {o = 1; next}
check_p && p == 0 && /DW_AT_name.* paravirt_patch_site[[:space:]]*$/ {p = 1; next}
check_s && s == 0 && /DW_AT_name.* static_call_site[[:space:]]*$/ {s = 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 }
@@ -400,6 +401,8 @@ find_special_section_data() {
o == 1 && !/DW_AT_byte_size/ { o = 0; next }
p == 1 && !/DW_AT_byte_size/ { p = 0; next }
s == 1 && !/DW_AT_byte_size/ { s = 0; next }
+ c == 1 && /DW_TAG_structure_type/ { c = 2; next }
+ c == 1 && /DW_AT_name.* force[[:space:]]*$/ {d = 1; next}
# Now that we know the size, stop parsing for it
a == 1 {printf("export ALT_STRUCT_SIZE=%d\n", $4); a = 2}
@@ -411,6 +414,7 @@ find_special_section_data() {
o == 1 {printf("export ORC_STRUCT_SIZE=%d\n", $4); o = 2}
p == 1 {printf("export PARA_STRUCT_SIZE=%d\n", $4); p = 2}
s == 1 {printf("export STATIC_CALL_STRUCT_SIZE=%d\n", $4); s = 2}
+ d == 1 {printf("export KLP_SUPPORT_FORCE=y\n"); d = 2}
# Bail out once we have everything
(!check_a || a == 2) &&
@@ -421,7 +425,8 @@ find_special_section_data() {
(!check_j || j == 2) &&
(!check_o || o == 2) &&
(!check_p || p == 2) &&
- (!check_s || s == 2) {exit}')"
+ (!check_s || s == 2) &&
+ c == 2 {exit}')"
[[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS"
@@ -1216,6 +1221,14 @@ if [[ -n "$DISABLE_AFTER_LOAD" ]];then
export KCPPFLAGS="-DDISABLE_AFTER_LOAD $KCPPFLAGS"
fi
+if [[ -n "$NO_STACK_CHECK" ]];then
+ export KCPPFLAGS="-D__ALL_FORCE__ $KCPPFLAGS"
+fi
+
+if [[ -n "$KLP_SUPPORT_FORCE" ]];then
+ export KCPPFLAGS="-D__KLP_SUPPORT_FORCE__ $KCPPFLAGS"
+fi
+
save_env
echo "Building patch module: $MODNAME.ko"
--
2.33.0

View File

@ -1,7 +1,7 @@
From d28c18b094c18118427eadb4c63ab73cf64af4e6 Mon Sep 17 00:00:00 2001 From 5e9f742fae2faef7ce30acd3bcf0f3085f55a0f6 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 21:01:02 -0500 Date: Wed, 26 Feb 2020 21:01:02 -0500
Subject: [PATCH 14/24] kpatch-build: ignore debuginfo in patch Subject: [PATCH 13/37] kpatch-build: ignore debuginfo in patch
Just ignore all .debug_* sections Just ignore all .debug_* sections
@ -12,10 +12,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
2 files changed, 19 insertions(+) 2 files changed, 19 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index ea1e01b..8c5af6b 100644 index e11a900..9b966e8 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -2714,6 +2714,23 @@ static void kpatch_include_debug_sections(struct kpatch_elf *kelf) @@ -2763,6 +2763,23 @@ static void kpatch_include_debug_sections(struct kpatch_elf *kelf)
} }
} }
@ -39,7 +39,7 @@ index ea1e01b..8c5af6b 100644
static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf) static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf)
{ {
struct section *sec, *strsec, *ignoresec; struct section *sec, *strsec, *ignoresec;
@@ -3908,6 +3925,7 @@ int main(int argc, char *argv[]) @@ -4054,6 +4071,7 @@ int main(int argc, char *argv[])
new_globals_exist = kpatch_include_new_globals(kelf_patched); new_globals_exist = kpatch_include_new_globals(kelf_patched);
kpatch_include_new_static_var(kelf_patched); kpatch_include_new_static_var(kelf_patched);
kpatch_include_debug_sections(kelf_patched); kpatch_include_debug_sections(kelf_patched);
@ -48,10 +48,10 @@ index ea1e01b..8c5af6b 100644
kpatch_process_special_sections(kelf_patched, lookup); kpatch_process_special_sections(kelf_patched, lookup);
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 9a98bfc..a0d8ba8 100755 index a5324db..84d8592 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1295,6 +1295,7 @@ KPATCH_LDFLAGS="$KPATCH_LDFLAGS" @@ -1273,6 +1273,7 @@ CROSS_COMPILE="$CROSS_COMPILE"
save_env save_env
make "${MAKEVARS[@]}" 2>&1 | logger || die make "${MAKEVARS[@]}" 2>&1 | logger || die
@ -60,5 +60,5 @@ index 9a98bfc..a0d8ba8 100755
if [[ "$USE_KLP" -eq 1 ]]; then if [[ "$USE_KLP" -eq 1 ]]; then
if [[ "$USE_KLP_ARCH" -eq 0 ]]; then if [[ "$USE_KLP_ARCH" -eq 0 ]]; then
-- --
2.23.0 2.33.0

View File

@ -1,154 +0,0 @@
From 88d2a5c88fcab0016db9347fbab41a22b9fb9a52 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 26 Feb 2020 20:43:34 -0500
Subject: [PATCH 13/24] livepatch-patch-hook: support force enable/disable
we use force to indicate function which bypass stack check
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
kmod/patch/kpatch-patch.h | 1 +
kmod/patch/livepatch-patch-hook.c | 17 +++++++++++++++++
kpatch-build/kpatch-build | 24 ++++++++++++++++++++----
3 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/kmod/patch/kpatch-patch.h b/kmod/patch/kpatch-patch.h
index 9df7818..6e39364 100644
--- a/kmod/patch/kpatch-patch.h
+++ b/kmod/patch/kpatch-patch.h
@@ -64,4 +64,5 @@ struct kpatch_post_unpatch_callback {
char *objname;
};
+extern unsigned long __kpatch_force_funcs[], __kpatch_force_funcs_end[];
#endif /* _KPATCH_PATCH_H_ */
diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c
index b578ef3..71439d9 100644
--- a/kmod/patch/livepatch-patch-hook.c
+++ b/kmod/patch/livepatch-patch-hook.c
@@ -432,6 +432,16 @@ extern struct kpatch_patch_func __kpatch_funcs[], __kpatch_funcs_end[];
extern struct kpatch_patch_dynrela __kpatch_dynrelas[], __kpatch_dynrelas_end[];
#endif
+static int patch_is_func_forced(unsigned long addr)
+{
+ unsigned long *a;
+
+ for (a = __kpatch_force_funcs; a < __kpatch_force_funcs_end; a++)
+ if (*a == addr)
+ return 1;
+ return 0;
+}
+
static int __init patch_init(void)
{
struct kpatch_patch_func *kfunc;
@@ -520,6 +530,13 @@ static int __init patch_init(void)
lfunc = &lfuncs[j];
lfunc->old_name = func->kfunc->name;
lfunc->new_func = (void *)func->kfunc->new_addr;
+#if defined(__KLP_SUPPORT_FORCE__)
+#ifdef __ALL_FORCE__
+ lfunc->force = 1;
+#else
+ lfunc->force = patch_is_func_forced(func->kfunc->new_addr);
+#endif
+#endif
#ifdef HAVE_SYMPOS
lfunc->old_sympos = func->kfunc->sympos;
#else
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 722d362..9a98bfc 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -383,28 +383,32 @@ find_special_section_data_aarch64() {
# shellcheck disable=SC2086
SPECIAL_VARS="$(readelf -wi "$VMLINUX" |
gawk --non-decimal-data $AWK_OPTIONS '
- BEGIN { a = b = e = j = 0 }
+ BEGIN { a = b = e = j = c = f = 0 }
# Set state if name matches
a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next}
b == 0 && /DW_AT_name.* bug_entry[[:space:]]*$/ {b = 1; next}
e == 0 && /DW_AT_name.* exception_table_entry[[:space:]]*$/ {e = 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 }
b == 1 && !/DW_AT_byte_size/ { b = 0; next }
e == 1 && !/DW_AT_byte_size/ { e = 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}
b == 1 {printf("export BUG_STRUCT_SIZE=%d\n", $4); b = 2}
e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 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 && e == 2 && (j == 2 || skip_j) {exit}')"
+ a == 2 && b == 2 && e == 2 && (j == 2 || skip_j) && c == 3 {exit}')"
[[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS"
@@ -437,7 +441,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 = s = i = 0 }
+ BEGIN { a = b = p = e = o = j = s = i = c = f = 0 }
# Set state if name matches
a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next}
@@ -448,6 +452,7 @@ find_special_section_data() {
j == 0 && /DW_AT_name.* jump_entry[[:space:]]*$/ {j = 1; next}
s == 0 && /DW_AT_name.* static_call_site[[:space:]]*$/ {s = 1; next}
i == 0 && /DW_AT_name.* pi_entry[[:space:]]*$/ {i = 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 }
@@ -458,6 +463,8 @@ find_special_section_data() {
j == 1 && !/DW_AT_byte_size/ { j = 0; next }
s == 1 && !/DW_AT_byte_size/ { s = 0; next }
i == 1 && !/DW_AT_byte_size/ { i = 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}
@@ -468,9 +475,10 @@ find_special_section_data() {
j == 1 {printf("export JUMP_STRUCT_SIZE=%d\n", $4); j = 2}
s == 1 {printf("export STATIC_CALL_STRUCT_SIZE=%d\n", $4); s = 2}
i == 1 {printf("export PRINTK_INDEX_STRUCT_SIZE=%d\n", $4); i = 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) && (s == 2 || skip_s) && (i == 2 || skip_i) {exit}')"
+ a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 && (o == 2 || skip_o) && (j == 2 || skip_j) && (s == 2 || skip_s) && (i == 2 || skip_i) && c == 3 {exit}')"
[[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS"
@@ -1231,6 +1239,14 @@ if [[ -n "$DISABLE_AFTER_LOAD" ]];then
export KCPPFLAGS="-DDISABLE_AFTER_LOAD $KCPPFLAGS"
fi
+if [[ -n "$NO_STACK_CHECK" ]];then
+ export KCPPFLAGS="-D__ALL_FORCE__ $KCPPFLAGS"
+fi
+
+if [[ -n "$KLP_SUPPORT_FORCE" ]];then
+ export KCPPFLAGS="-D__KLP_SUPPORT_FORCE__ $KCPPFLAGS"
+fi
+
save_env
echo "Building patch module: $MODNAME.ko"
--
2.23.0

View File

@ -1,7 +1,7 @@
From 8341b9ea6b889a887577772f6adfb49e1fea1bc1 Mon Sep 17 00:00:00 2001 From 9e83f203c363d6cb88853daa0f5751501baa1d70 Mon Sep 17 00:00:00 2001
From: Bin Yang <robin.yb@huawei.com> From: Bin Yang <robin.yb@huawei.com>
Date: Tue, 16 Jul 2019 14:39:27 +0800 Date: Tue, 16 Jul 2019 14:39:27 +0800
Subject: [PATCH 15/24] add object in kpatch Subject: [PATCH 14/37] add object in kpatch
it is required by make_hotpatch users it is required by make_hotpatch users
@ -11,10 +11,10 @@ Signed-off-by: Bin Yang <robin.yb@huawei.com>
1 file changed, 3 insertions(+) 1 file changed, 3 insertions(+)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index a0d8ba8..c21f3ca 100755 index 84d8592..a5168f5 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1227,6 +1227,8 @@ echo -n "Patched objects:" @@ -1209,6 +1209,8 @@ echo -n "Patched objects:"
for i in $(echo "${objnames[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') for i in $(echo "${objnames[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
do do
echo -n " $i" echo -n " $i"
@ -23,7 +23,7 @@ index a0d8ba8..c21f3ca 100755
done done
echo echo
@@ -1353,6 +1355,7 @@ UNDEFINED=$(comm -23 <(sort -u "${TEMPDIR}"/undefined_references) \ @@ -1331,6 +1333,7 @@ UNDEFINED=$(comm -23 <(sort -u "${TEMPDIR}"/undefined_references) \
[[ -z "$USERMODBUILDDIR" ]] && [[ -n "$UNDEFINED" ]] && die "Undefined symbols: $UNDEFINED" [[ -z "$USERMODBUILDDIR" ]] && [[ -n "$UNDEFINED" ]] && die "Undefined symbols: $UNDEFINED"
cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die
@ -32,5 +32,5 @@ index a0d8ba8..c21f3ca 100755
[[ "$DEBUG" -eq 0 && "$SKIPCLEANUP" -eq 0 ]] && rm -f "$LOGFILE" [[ "$DEBUG" -eq 0 && "$SKIPCLEANUP" -eq 0 ]] && rm -f "$LOGFILE"
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 2dab7f74fecefab38fbd9c2d171e5a6090e66829 Mon Sep 17 00:00:00 2001 From 98823cdec5eeafae9b7ed17be4e909314e924111 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 27 Feb 2020 15:36:55 -0500 Date: Thu, 27 Feb 2020 15:36:55 -0500
Subject: [PATCH 16/24] create-diff-object: fix .orc_unwind_ip error Subject: [PATCH 15/37] create-diff-object: fix .orc_unwind_ip error
error: .orc_unwind_ip section header details error: .orc_unwind_ip section header details
differ from .orc_unwind_ip differ from .orc_unwind_ip
@ -14,10 +14,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 6 insertions(+) 1 file changed, 6 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 8c5af6b..5f51034 100644 index 9b966e8..9c70fee 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -1079,6 +1079,9 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig, @@ -1061,6 +1061,9 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig,
continue; continue;
} }
@ -27,7 +27,7 @@ index 8c5af6b..5f51034 100644
kpatch_correlate_section(sec_orig, sec_patched); kpatch_correlate_section(sec_orig, sec_patched);
break; break;
} }
@@ -1125,6 +1128,9 @@ static void kpatch_correlate_symbols(struct list_head *symlist_orig, @@ -1098,6 +1101,9 @@ static void kpatch_correlate_symbols(struct list_head *symlist_orig,
sym_orig->sec->twin != sym_patched->sec) sym_orig->sec->twin != sym_patched->sec)
continue; continue;
@ -38,5 +38,5 @@ index 8c5af6b..5f51034 100644
break; break;
} }
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 78a04dd5a2a98e6442441b802e1f4aa017fae87a Mon Sep 17 00:00:00 2001 From 7d73bf5fe9d4c551424eb4868cd7081cbf0334d1 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Mon, 2 Mar 2020 04:35:07 -0500 Date: Mon, 2 Mar 2020 04:35:07 -0500
Subject: [PATCH 17/24] create-diff-object: add jump label support Subject: [PATCH 16/37] create-diff-object: add jump label support
This patch processes the __jump_table special section, and This patch processes the __jump_table special section, and
only the jump_lable used by the changed functions will be only the jump_lable used by the changed functions will be
@ -15,10 +15,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 7 insertions(+), 2 deletions(-) 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 5f51034..6b915ae 100644 index 9c70fee..9334cf9 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -79,6 +79,7 @@ enum subsection { @@ -70,6 +70,7 @@ enum subsection {
enum loglevel loglevel = NORMAL; enum loglevel loglevel = NORMAL;
bool KLP_ARCH; bool KLP_ARCH;
@ -26,7 +26,7 @@ index 5f51034..6b915ae 100644
/******************* /*******************
* Data structures * Data structures
@@ -2374,6 +2375,8 @@ static bool should_keep_jump_label(struct lookup_table *lookup, @@ -2399,6 +2400,8 @@ static bool should_keep_jump_label(struct lookup_table *lookup,
if (tracepoint || dynamic_debug) if (tracepoint || dynamic_debug)
return false; return false;
@ -35,7 +35,7 @@ index 5f51034..6b915ae 100644
/* /*
* This will be upgraded to an error after all jump labels have * This will be upgraded to an error after all jump labels have
* been reported. * been reported.
@@ -2404,6 +2407,8 @@ static bool should_keep_jump_label(struct lookup_table *lookup, @@ -2429,6 +2432,8 @@ static bool should_keep_jump_label(struct lookup_table *lookup,
if (tracepoint || dynamic_debug) if (tracepoint || dynamic_debug)
return false; return false;
@ -44,7 +44,7 @@ index 5f51034..6b915ae 100644
/* /*
* This will be upgraded to an error after all jump labels have * This will be upgraded to an error after all jump labels have
* been reported. * been reported.
@@ -2972,8 +2977,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf, @@ -3027,8 +3032,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
* labels and enable tracepoints in a patched function. * labels and enable tracepoints in a patched function.
*/ */
list_for_each_entry(sec, &kelf->sections, list) { list_for_each_entry(sec, &kelf->sections, list) {
@ -54,7 +54,7 @@ index 5f51034..6b915ae 100644
strcmp(sec->name, "__tracepoints_ptrs") && strcmp(sec->name, "__tracepoints_ptrs") &&
strcmp(sec->name, "__tracepoints_strings")) strcmp(sec->name, "__tracepoints_strings"))
continue; continue;
@@ -3865,6 +3869,7 @@ int main(int argc, char *argv[]) @@ -4009,6 +4013,7 @@ int main(int argc, char *argv[])
char *parent_symtab, *mod_symvers, *patch_name, *output_obj; char *parent_symtab, *mod_symvers, *patch_name, *output_obj;
char *no_profiling_calls = NULL; char *no_profiling_calls = NULL;
@ -63,5 +63,5 @@ index 5f51034..6b915ae 100644
argp_parse (&argp, argc, argv, 0, NULL, &arguments); argp_parse (&argp, argc, argv, 0, NULL, &arguments);
if (arguments.debug) if (arguments.debug)
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 46a24818a2227ad1b6f644c2499415021522ce55 Mon Sep 17 00:00:00 2001 From 74f78de8bd7f97f4129320f944024ffaa4317c9e Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 12 Mar 2020 06:56:21 -0400 Date: Thu, 12 Mar 2020 06:56:21 -0400
Subject: [PATCH 18/24] kpatch-build: add compile flag -fno-reorder-functions Subject: [PATCH 17/37] kpatch-build: add compile flag -fno-reorder-functions
Sometimes function foo with static variables can be put in Sometimes function foo with static variables can be put in
.text.foo section in original binary and be put in .text.foo section in original binary and be put in
@ -23,11 +23,11 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index c21f3ca..2ead6e4 100755 index a5168f5..a73bd1b 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -994,7 +994,7 @@ if [[ "$ARCH" = "ppc64le" ]]; then @@ -975,7 +975,7 @@ if [[ "$ARCH" = "s390x" ]]; then
ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so" ARCH_KCFLAGS="-mno-pic-data-is-text-relative -fno-section-anchors"
fi fi
-export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections \ -export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections \
@ -36,5 +36,5 @@ index c21f3ca..2ead6e4 100755
echo "Reading special section data" echo "Reading special section data"
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 47a9749d381f02868b4f4bbe1bc841f3f38ac1a1 Mon Sep 17 00:00:00 2001 From 240690fed2b440ec5e1a69e5c1d69cbbd064757f Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sun, 22 Nov 2020 21:40:39 +0800 Date: Sun, 22 Nov 2020 21:40:39 +0800
Subject: [PATCH 19/24] Fix relocation not resolved when new functions exported Subject: [PATCH 18/37] Fix relocation not resolved when new functions exported
only only
When no functions changed and new functions exported, kobject is not When no functions changed and new functions exported, kobject is not
@ -84,10 +84,10 @@ index 71439d9..9e56fe3 100644
ret = -ENOMEM; ret = -ENOMEM;
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6b915ae..0bef022 100644 index 9334cf9..2510620 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -2916,6 +2916,27 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj @@ -2968,6 +2968,27 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj
karch_sec->sh.sh_size = karch_sec->data->d_size; karch_sec->sh.sh_size = karch_sec->data->d_size;
} }
@ -107,7 +107,7 @@ index 6b915ae..0bef022 100644
+ /* entries[index].objname */ + /* entries[index].objname */
+ ALLOC_LINK(rela, &kobj_sec->rela->relas); + ALLOC_LINK(rela, &kobj_sec->rela->relas);
+ rela->sym = strsym; + rela->sym = strsym;
+ rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type(kelf);
+ rela->addend = offset_of_string(&kelf->strings, objname); + rela->addend = offset_of_string(&kelf->strings, objname);
+ rela->offset = (unsigned int)(offsetof(struct kpatch_object, objname)); + rela->offset = (unsigned int)(offsetof(struct kpatch_object, objname));
+} +}
@ -115,7 +115,7 @@ index 6b915ae..0bef022 100644
static void kpatch_process_special_sections(struct kpatch_elf *kelf, static void kpatch_process_special_sections(struct kpatch_elf *kelf,
struct lookup_table *lookup) struct lookup_table *lookup)
{ {
@@ -3973,6 +3994,11 @@ int main(int argc, char *argv[]) @@ -4119,6 +4140,11 @@ int main(int argc, char *argv[])
kpatch_create_intermediate_sections(kelf_out, lookup, parent_name, patch_name); kpatch_create_intermediate_sections(kelf_out, lookup, parent_name, patch_name);
kpatch_create_kpatch_arch_section(kelf_out, parent_name); kpatch_create_kpatch_arch_section(kelf_out, parent_name);
kpatch_create_callbacks_objname_rela(kelf_out, parent_name); kpatch_create_callbacks_objname_rela(kelf_out, parent_name);
@ -128,5 +128,5 @@ index 6b915ae..0bef022 100644
kpatch_create_mcount_sections(kelf_out); kpatch_create_mcount_sections(kelf_out);
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From a81f64c1eae14f2b0da8168ca60b3d9beb0a9fb0 Mon Sep 17 00:00:00 2001 From fbf50da80b82c2749a76181f6bd76c9ee8d2539c Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Wed, 30 Dec 2020 21:13:10 -0500 Date: Wed, 30 Dec 2020 21:13:10 -0500
Subject: [PATCH 20/24] support remove static variables using Subject: [PATCH 19/37] support remove static variables using
KPATCH_IGNORE_STATIC KPATCH_IGNORE_STATIC
Static variables will be removed due to compiler optimization. Static variables will be removed due to compiler optimization.
@ -16,10 +16,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
2 files changed, 48 insertions(+), 1 deletion(-) 2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/kmod/patch/kpatch-macros.h b/kmod/patch/kpatch-macros.h diff --git a/kmod/patch/kpatch-macros.h b/kmod/patch/kpatch-macros.h
index caaadbc..ee455d2 100644 index 8e09702..02d548e 100644
--- a/kmod/patch/kpatch-macros.h --- a/kmod/patch/kpatch-macros.h
+++ b/kmod/patch/kpatch-macros.h +++ b/kmod/patch/kpatch-macros.h
@@ -12,6 +12,10 @@ @@ -13,6 +13,10 @@
# define __kpatch_section(section) __section(#section) # define __kpatch_section(section) __section(#section)
#endif #endif
@ -31,10 +31,10 @@ index caaadbc..ee455d2 100644
* KPATCH_IGNORE_SECTION macro * KPATCH_IGNORE_SECTION macro
* *
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 0bef022..f83000b 100644 index 2510620..c90b30a 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -1345,6 +1345,40 @@ static struct rela *kpatch_find_static_twin_ref(struct section *rela_sec, struct @@ -1319,6 +1319,40 @@ static struct rela *kpatch_find_static_twin_ref(struct section *relasec,
return NULL; return NULL;
} }
@ -75,7 +75,7 @@ index 0bef022..f83000b 100644
/* /*
* gcc renames static local variables by appending a period and a number. For * gcc renames static local variables by appending a period and a number. For
* example, __foo could be renamed to __foo.31452. Unfortunately this number * example, __foo could be renamed to __foo.31452. Unfortunately this number
@@ -1425,6 +1459,11 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig, @@ -1399,6 +1433,11 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig,
if (sym->twin) if (sym->twin)
continue; continue;
@ -85,9 +85,9 @@ index 0bef022..f83000b 100644
+ } + }
+ +
bundled = sym == sym->sec->sym; bundled = sym == sym->sec->sym;
if (bundled && sym->sec == sec->base) { if (bundled && sym->sec == relasec->base) {
/* /*
@@ -1482,6 +1521,11 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig, @@ -1456,6 +1495,11 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig,
if (!kpatch_is_normal_static_local(sym)) if (!kpatch_is_normal_static_local(sym))
continue; continue;
@ -96,17 +96,17 @@ index 0bef022..f83000b 100644
+ continue; + continue;
+ } + }
+ +
if (!sec->twin && sec->base->sym) { if (!relasec->twin && relasec->base->sym) {
struct symbol *parent = NULL; struct symbol *parent = NULL;
@@ -1525,7 +1569,6 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig, @@ -1499,7 +1543,6 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *orig,
log_normal("WARNING: unable to correlate static local variable %s used by %s, assuming variable is new\n", log_normal("WARNING: unable to correlate static local variable %s used by %s, assuming variable is new\n",
sym->name, sym->name,
kpatch_section_function_name(sec)); kpatch_section_function_name(relasec));
- return; - return;
} }
} }
} }
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From b841186b9f8ced6a78953c0c109138f9aef7a53a Mon Sep 17 00:00:00 2001 From d122635200d5c9d7e6efa59745efe2e796a7f9ff Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 12 Mar 2020 05:10:55 -0400 Date: Thu, 12 Mar 2020 05:10:55 -0400
Subject: [PATCH 22/24] use original reloc for symbols exported from modules Subject: [PATCH 20/37] use original reloc for symbols exported from modules
symbols exported in a patch will generate a symbol version with symbols exported in a patch will generate a symbol version with
object module name in Module.symvers, but the symbol is actually object module name in Module.symvers, but the symbol is actually
@ -13,10 +13,10 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 1 insertion(+), 7 deletions(-) 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index aa5c5c4..59d491d 100644 index c90b30a..deddde9 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3317,13 +3317,7 @@ static bool need_dynrela(struct lookup_table *table, struct section *sec, const @@ -3388,13 +3388,7 @@ static bool need_dynrela(struct kpatch_elf *kelf, struct lookup_table *table,
return false; return false;
} }
@ -32,5 +32,5 @@ index aa5c5c4..59d491d 100644
if (symbol.global) { if (symbol.global) {
-- --
2.23.0 2.33.0

View File

@ -1,7 +1,7 @@
From 7fa14b0c6f2e42cdf76b44b1337eb27e5b777d14 Mon Sep 17 00:00:00 2001 From 2de1633802ae3bc2c4f91e536dbba830da6ad932 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Fri, 2 Nov 2018 17:25:38 +0000 Date: Fri, 2 Nov 2018 17:25:38 +0000
Subject: [PATCH 23/24] create-diff-object: create dynamic relocs for changed Subject: [PATCH 21/37] create-diff-object: create dynamic relocs for changed
functions in this object functions in this object
Currently, we only create dynamic relocs for changed functions of Currently, we only create dynamic relocs for changed functions of
@ -26,22 +26,22 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 6 insertions(+) 1 file changed, 6 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 59d491d..3a12ee1 100644 index deddde9..5e216d1 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3238,6 +3238,12 @@ static bool need_dynrela(struct lookup_table *table, struct section *sec, const @@ -3309,6 +3309,12 @@ static bool need_dynrela(struct kpatch_elf *kelf, struct lookup_table *table,
return false; return false;
if (rela->sym->sec) { if (rela->sym->sec) {
+ if (rela->sym->type == STT_FUNC && + if (rela->sym->type == STT_FUNC &&
+ rela->sym->status == CHANGED && + rela->sym->status == CHANGED &&
+ rela->sym->sec != sec->base && + rela->sym->sec != relasec->base &&
+ sec->base->sym && + relasec->base->sym &&
+ sec->base->sym->type == STT_FUNC) + relasec->base->sym->type == STT_FUNC)
+ return true; + return true;
/* /*
* Internal symbols usually don't need dynrelas, because they * Internal symbols usually don't need dynrelas, because they
* live in the patch module and can be relocated normally. * live in the patch module and can be relocated normally.
-- --
2.23.0 2.33.0

View File

@ -1,31 +0,0 @@
From 2189dd022cda1973efdc198daa0525cbd2ee5bb2 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Fri, 17 Sep 2021 10:22:24 +0800
Subject: [PATCH 21/24] create-diff-object: fix segment fault when sec2->rela
is NULL
when patched section has no rela section, we meet segment fault in
__kpatch_correlate_section. add sec2->rela check to fix it.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
Signed-off-by: hubin57 <hubin57@huawei.com>
---
kpatch-build/create-diff-object.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index f83000b..aa5c5c4 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -1015,7 +1015,7 @@ static void kpatch_correlate_section(struct section *sec_orig,
__kpatch_correlate_section(sec_orig->base, sec_patched->base);
sec_orig = sec_orig->base;
sec_patched = sec_patched->base;
- } else if (sec_orig->rela) {
+ } else if (sec_orig->rela && sec_patched->rela) {
__kpatch_correlate_section(sec_orig->rela, sec_patched->rela);
}
--
2.23.0

View File

@ -1,7 +1,7 @@
From ea05261d87f22ecebcc5e4abac662960e732e33b Mon Sep 17 00:00:00 2001 From 9b611ad453be06cfb48d9352ef65166a432a8edd Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com> From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Tue, 16 Nov 2021 20:21:31 +0800 Date: Tue, 16 Nov 2021 20:21:31 +0800
Subject: [PATCH 24/24] kpatch-build: support CROSS_COMPILE Subject: [PATCH 22/37] kpatch-build: support CROSS_COMPILE
some Makefile use $(CROSS_COMPILE)gcc to compile .o some Makefile use $(CROSS_COMPILE)gcc to compile .o
file, append CROSS_COMPILE to MAKEVARS to make it file, append CROSS_COMPILE to MAKEVARS to make it
@ -13,17 +13,17 @@ Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
1 file changed, 1 insertion(+) 1 file changed, 1 insertion(+)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 2ead6e4..6a9e818 100755 index a73bd1b..daa9a81 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1016,6 +1016,7 @@ if [ "$CONFIG_CC_IS_CLANG" -eq 1 ]; then @@ -997,6 +997,7 @@ if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
MAKEVARS+=("HOSTCC=clang") MAKEVARS+=("HOSTCC=clang")
else else
MAKEVARS+=("CC=${KPATCH_CC_PREFIX}gcc") MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${GCC}")
+ MAKEVARS+=("CROSS_COMPILE=${KPATCH_CC_PREFIX}") + MAKEVARS+=("CROSS_COMPILE=${KPATCH_CC_PREFIX}")
fi fi
if [ "$CONFIG_LD_IS_LLD" -eq 1 ]; then if [[ -n "$CONFIG_LD_IS_LLD" ]]; then
-- --
2.23.0 2.33.0

View File

@ -1,8 +1,8 @@
From 5b34dae2eaf57c33beb5cd4e3972a4580259a5fc Mon Sep 17 00:00:00 2001 From 906b218903a32134dcc1a1fdda606e7b41aad616 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:26:25 +0800 Date: Tue, 10 May 2022 15:26:25 +0800
Subject: [PATCH] livepatch-patch-hook: disable HAVE_SIMPLE_ENABLE to keep Subject: [PATCH 23/37] livepatch-patch-hook: disable HAVE_SIMPLE_ENABLE to
register and unregister step of hotpatch keep register and unregister step of hotpatch
Signed-off-by: Bin Hu <hubin73@huawei.com> Signed-off-by: Bin Hu <hubin73@huawei.com>
--- ---
@ -23,5 +23,5 @@ index 9e56fe3..b565a6a 100644
#ifdef RHEL_RELEASE_CODE #ifdef RHEL_RELEASE_CODE
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,8 +1,8 @@
From f435e99fc2652cd6263f3a2fe02b0947a5279a82 Mon Sep 17 00:00:00 2001 From 4a0580c4179a3455dd3442a0de0ee9e3f4ce6896 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:27:28 +0800 Date: Tue, 10 May 2022 15:27:28 +0800
Subject: [PATCH 2/9] kpatch-build: add KBUILD_MODPOST_WARN=1 to avoid modpost Subject: [PATCH 24/37] kpatch-build: add KBUILD_MODPOST_WARN=1 to avoid
undefined error modpost undefined error
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 5 insertions(+), 5 deletions(-) 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 6a9e818..ba33a3e 100644 index daa9a81..a822708 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -1030,9 +1030,9 @@ fi @@ -1011,9 +1011,9 @@ fi
# $TARGETS used as list, no quotes. # $TARGETS used as list, no quotes.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if [[ -z "$USERMODBUILDDIR" ]]; then if [[ -z "$USERMODBUILDDIR" ]]; then
@ -25,9 +25,9 @@ index 6a9e818..ba33a3e 100644
fi fi
# Save original module symvers # Save original module symvers
@@ -1175,9 +1175,9 @@ for i in $FILES; do @@ -1158,9 +1158,9 @@ for i in $FILES; do
remove_patches remove_patches
cd "$SRCDIR" || die cd "$BUILDDIR" || die
if [ -z "$USERMODBUILDDIR" ];then if [ -z "$USERMODBUILDDIR" ];then
- make "-j$CPUS" $TARGETS 2>&1 | logger || die - make "-j$CPUS" $TARGETS 2>&1 | logger || die
+ KBUILD_MODPOST_WARN=1 make "-j$CPUS" $TARGETS 2>&1 | logger || die + KBUILD_MODPOST_WARN=1 make "-j$CPUS" $TARGETS 2>&1 | logger || die
@ -37,8 +37,8 @@ index 6a9e818..ba33a3e 100644
fi fi
cp ${KOBJFILE} ${KOBJFILE_PATH} cp ${KOBJFILE} ${KOBJFILE_PATH}
apply_patches apply_patches
@@ -1297,7 +1297,7 @@ KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS" \ @@ -1275,7 +1275,7 @@ KPATCH_LDFLAGS="$KPATCH_LDFLAGS" \
KPATCH_LDFLAGS="$KPATCH_LDFLAGS" CROSS_COMPILE="$CROSS_COMPILE"
save_env save_env
-make "${MAKEVARS[@]}" 2>&1 | logger || die -make "${MAKEVARS[@]}" 2>&1 | logger || die
@ -47,5 +47,5 @@ index 6a9e818..ba33a3e 100644
if [[ "$USE_KLP" -eq 1 ]]; then if [[ "$USE_KLP" -eq 1 ]]; then
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,68 +0,0 @@
From 03a09bb210eb5b03ceb5a45452fa962efbd923d1 Mon Sep 17 00:00:00 2001
From: Joe Lawrence <joe.lawrence@redhat.com>
Date: Mon, 6 Dec 2021 09:55:06 -0500
Subject: [PATCH] create-diff-object: update for __already_done
Upstream v5.14+ kernel change a358f40600b3 ("once: implement
DO_ONCE_LITE for non-fast-path "do once" functionality") consolidated a
bunch of do-once macros into a common macro:
#define DO_ONCE_LITE_IF(condition, func, ...) \
({ \
static bool __section(".data.once") __already_done; \
...
which replaced static local variable __warned with __already_done.
Update any __warned static local checks to also look for the new
__already_done variable as well.
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
---
kpatch-build/create-diff-object.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6a06b04..442d8f8 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -320,6 +320,7 @@ static bool is_special_static(struct symbol *sym)
static char *var_names[] = {
"__key",
"__warned",
+ "__already_done.",
"__func__",
"__FUNCTION__",
"_rs",
@@ -610,7 +611,7 @@ out:
* The pattern which applies to all cases:
* 1) immediate move of the line number to %esi
* 2) (optional) string section rela
- * 3) (optional) __warned.xxxxx static local rela
+ * 3) (optional) __warned.xxxxx or __already_done.xxxxx static local rela
* 4) warn_slowpath_* or __might_sleep or some other similar rela
*/
static bool kpatch_line_macro_change_only(struct section *sec)
@@ -666,7 +667,8 @@ static bool kpatch_line_macro_change_only(struct section *sec)
continue;
if (rela->string)
continue;
- if (!strncmp(rela->sym->name, "__warned.", 9))
+ if (!strncmp(rela->sym->name, "__warned.", 9) ||
+ !strncmp(rela->sym->name, "__already_done.", 15))
continue;
if (!strncmp(rela->sym->name, "warn_slowpath_", 14) ||
(!strcmp(rela->sym->name, "__warn_printk")) ||
@@ -732,7 +734,8 @@ static bool kpatch_line_macro_change_only(struct section *sec)
continue;
if (toc_rela(rela) && toc_rela(rela)->string)
continue;
- if (!strncmp(rela->sym->name, "__warned.", 9))
+ if (!strncmp(rela->sym->name, "__warned.", 9) ||
+ !strncmp(rela->sym->name, "__already_done.", 15))
continue;
if (!strncmp(rela->sym->name, "warn_slowpath_", 14) ||
(!strcmp(rela->sym->name, "__warn_printk")) ||
--
2.23.0

View File

@ -1,8 +1,8 @@
From f1de68ea87426e7ed65dc615a46f5ce1d15df994 Mon Sep 17 00:00:00 2001 From d59f96e9287c3af1090f8f19fdd0f76b2eeedeec Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:27:52 +0800 Date: Tue, 10 May 2022 15:27:52 +0800
Subject: [PATCH 3/9] kpatch-build: update find_parent_obj to avoid error that Subject: [PATCH 25/37] kpatch-build: update find_parent_obj to avoid error
two parent match same object that two parent match same object
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 2 insertions(+), 2 deletions(-) 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index ba33a3e..ce163e5 100644 index a822708..5063dd7 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -527,8 +527,8 @@ find_parent_obj() { @@ -476,8 +476,8 @@ find_parent_obj() {
[[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")" [[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")"
fi fi
if [[ "$num" -eq 0 ]]; then if [[ "$num" -eq 0 ]]; then
@ -25,5 +25,5 @@ index ba33a3e..ce163e5 100644
fi fi
else else
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,7 +1,7 @@
From b1be16f5c42bae41f15a2579cb6ce39406648e19 Mon Sep 17 00:00:00 2001 From 85881a54bcb1bbc726d968de708f598c5e2b62c6 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:00 +0800 Date: Tue, 10 May 2022 15:28:00 +0800
Subject: [PATCH 4/9] create-diff-object: fix segment fault when using Subject: [PATCH 26/37] create-diff-object: fix segment fault when using
KPATCH_FORCE_UNSAFE KPATCH_FORCE_UNSAFE
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 6 insertions(+), 1 deletion(-) 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index bbb40ed..2cca6f3 100644 index 5e216d1..b27edd8 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -1969,9 +1969,14 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf) @@ -1925,9 +1925,14 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf)
continue; continue;
} }
/* .rela.kpatch.force */ /* .rela.kpatch.force */
@ -30,5 +30,5 @@ index bbb40ed..2cca6f3 100644
} }
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,60 +0,0 @@
From e06664f379eab0b3f80c504c6656f805bba30e69 Mon Sep 17 00:00:00 2001
From: David Vernet <void@manifault.com>
Date: Thu, 13 Jan 2022 12:57:15 -0800
Subject: [PATCH] kpatch-build: Add missing allocation failure checks
In kpatch-build, there are a number of places where a dynamic allocation
is performed, but the allocation is not checked for a failure. The
common pattern in kpatch-build is to check whether the returned pointer
is NULL, and if so, invoke the ERROR() macro to print a message and
abort the program.
kpatch_create_mcount_sections(), CORRELATE_ELEMENT(), and
create_klp_arch_sections() all had dynamic allocations without failure
checks. This diff adjusts those callsites to properly check for a failed
allocation, and ERROR() accordingly.
Signed-off-by: David Vernet <void@manifault.com>
---
kpatch-build/create-diff-object.c | 4 ++++
kpatch-build/create-klp-module.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 442d8f8..01e5d63 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -979,6 +979,8 @@ do { \
log_debug("renaming %s %s to %s\n", \
kindstr, e2->name, e1->name); \
e2->name = strdup(e1->name); \
+ if (!e2->name) \
+ ERROR("strdup"); \
} \
} while (0)
@@ -3688,6 +3690,8 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
/* Make a writable copy of the text section data */
newdata = malloc(sym->sec->data->d_size);
+ if (!newdata)
+ ERROR("malloc");
memcpy(newdata, sym->sec->data->d_buf, sym->sec->data->d_size);
sym->sec->data->d_buf = newdata;
insn = newdata;
diff --git a/kpatch-build/create-klp-module.c b/kpatch-build/create-klp-module.c
index 547e587..8ceb8f3 100644
--- a/kpatch-build/create-klp-module.c
+++ b/kpatch-build/create-klp-module.c
@@ -343,6 +343,8 @@ static void create_klp_arch_sections(struct kpatch_elf *kelf, char *strings)
new_size = old_size + base->data->d_size;
sec->data->d_buf = realloc(sec->data->d_buf, new_size);
+ if (!sec->data->d_buf)
+ ERROR("realloc");
sec->data->d_size = new_size;
sec->sh.sh_size = sec->data->d_size;
memcpy(sec->data->d_buf + old_size,
--
2.27.0

View File

@ -1,48 +0,0 @@
From 20c31ce6e82430ae0df0e8014058cfde83196ea0 Mon Sep 17 00:00:00 2001
From: Markus Boehme <markubo@amazon.com>
Date: Sat, 15 Jan 2022 01:00:39 +0100
Subject: [PATCH] create-diff-object: add support for .retpoline_sites section
Commit 134ab5bd1883 ("objtool,x86: Replace alternatives with .retpoline_sites")
in the kernel starts keeping track of retpoline thunk call sites in a
dedicated section rather than via the alternatives mechanism.
The .retpoline_sites section needs to have its entries and relocations
for changed symbols included in the patch ELF when building for kernel
5.16+ with CONFIG_RETPOLINE=y.
Signed-off-by: Markus Boehme <markubo@amazon.com>
---
kpatch-build/create-diff-object.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 01e5d63..bbb40ed 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2233,6 +2233,11 @@ static int static_call_sites_group_size(struct kpatch_elf *kelf, int offset)
return size;
}
+
+static int retpoline_sites_group_size(struct kpatch_elf *kelf, int offset)
+{
+ return 4;
+}
#endif
#ifdef __powerpc64__
static int fixup_entry_group_size(struct kpatch_elf *kelf, int offset)
@@ -2349,6 +2354,10 @@ static struct special_section special_sections[] = {
.name = ".static_call_sites",
.group_size = static_call_sites_group_size,
},
+ {
+ .name = ".retpoline_sites",
+ .group_size = retpoline_sites_group_size,
+ },
#endif
#ifdef __powerpc64__
{
--
2.27.0

View File

@ -1,8 +1,8 @@
From 83b98afd69c8be39587bfcd2260f03b2b3082a94 Mon Sep 17 00:00:00 2001 From 7be77c200280aaf4e788dfa9b24194e847ea46fc Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:17 +0800 Date: Tue, 10 May 2022 15:28:17 +0800
Subject: [PATCH 5/9] kpatch-macros: replace __section with __kpatch_section in Subject: [PATCH 27/37] kpatch-macros: replace __section with __kpatch_section
kpatch macro definition in kpatch macro definition
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kmod/patch/kpatch-macros.h b/kmod/patch/kpatch-macros.h diff --git a/kmod/patch/kpatch-macros.h b/kmod/patch/kpatch-macros.h
index ee455d2..c20b061 100644 index 02d548e..f546822 100644
--- a/kmod/patch/kpatch-macros.h --- a/kmod/patch/kpatch-macros.h
+++ b/kmod/patch/kpatch-macros.h +++ b/kmod/patch/kpatch-macros.h
@@ -13,7 +13,7 @@ @@ -14,7 +14,7 @@
#endif #endif
#define KPATCH_IGNORE_STATIC(_static) \ #define KPATCH_IGNORE_STATIC(_static) \
@ -23,5 +23,5 @@ index ee455d2..c20b061 100644
/* /*
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,30 +0,0 @@
From 4d8c8102de49534bd538bb20319680ce1f1ff9ef Mon Sep 17 00:00:00 2001
From: Artem Savkov <asavkov@redhat.com>
Date: Thu, 3 Feb 2022 11:59:24 +0100
Subject: [PATCH] Fix sym->type condition in locals_match()
Second loop in locals_match() checks table_sym->type instead of
sym->type.
Fixes: 7207687 Switch to per-file lookup table pointers.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
kpatch-build/lookup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index 0323c61..06f4b38 100644
--- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c
@@ -131,7 +131,7 @@ static bool locals_match(struct lookup_table *table, int idx,
break;
if (sym->bind != STB_LOCAL)
continue;
- if (sym->type != STT_FUNC && table_sym->type != STT_OBJECT)
+ if (sym->type != STT_FUNC && sym->type != STT_OBJECT)
continue;
/*
* Symbols which get discarded at link time are missing from
--
2.27.0

View File

@ -1,7 +1,7 @@
From 41334ab046ad2c89324b61f76b262228a6bc36ad Mon Sep 17 00:00:00 2001 From 66681deab6874218eedc244138dbc464daf13011 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:26 +0800 Date: Tue, 10 May 2022 15:28:26 +0800
Subject: [PATCH 6/9] create-diff-object: ignore changed of section Subject: [PATCH 28/37] create-diff-object: ignore changed of section
__patchable_function_entries __patchable_function_entries
Linux 5.10 aarch64 uses -fpatchable-function-entry=N to generate N NOPs at the Linux 5.10 aarch64 uses -fpatchable-function-entry=N to generate N NOPs at the
@ -17,10 +17,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 2 insertions(+), 1 deletion(-) 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 2cca6f3..8d3f377 100644 index b27edd8..666e44c 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3062,7 +3062,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf, @@ -3103,7 +3103,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
list_for_each_entry(sec, &kelf->sections, list) { list_for_each_entry(sec, &kelf->sections, list) {
if (strcmp(sec->name, "__tracepoints") && if (strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") && strcmp(sec->name, "__tracepoints_ptrs") &&
@ -31,5 +31,5 @@ index 2cca6f3..8d3f377 100644
sec->status = SAME; sec->status = SAME;
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,7 +1,7 @@
From e1b12b68efc7de9e3e3db52ceda2c1b713dc7cb7 Mon Sep 17 00:00:00 2001 From d0c418f1e53cbdd6e1672060cef5dccb253cf231 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:34 +0800 Date: Tue, 10 May 2022 15:28:34 +0800
Subject: [PATCH 7/9] create-diff-object: fix null pointer dereference in Subject: [PATCH 29/37] create-diff-object: fix null pointer dereference in
kpatch_ignore_debug_section kpatch_ignore_debug_section
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 8d3f377..03c877e 100644 index 666e44c..0b8c46e 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -2796,7 +2796,7 @@ static void kpatch_ignore_debug_sections(struct kpatch_elf *kelf) @@ -2831,7 +2831,7 @@ static void kpatch_ignore_debug_sections(struct kpatch_elf *kelf)
if (is_debug_section(sec)) { if (is_debug_section(sec)) {
sec->include = 0; sec->include = 0;
sec->status = SAME; sec->status = SAME;
@ -23,5 +23,5 @@ index 8d3f377..03c877e 100644
sec->secsym->status = SAME; sec->secsym->status = SAME;
} }
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,7 +1,7 @@
From de34b86536bde114f481a73fdbf2f58b643c3e48 Mon Sep 17 00:00:00 2001 From f9413f0a3dbe3ae506c49d528d8cc5f23dc58a68 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:46 +0800 Date: Tue, 10 May 2022 15:28:46 +0800
Subject: [PATCH 8/9] create-diff-object: ignore .note.gnu.property section Subject: [PATCH 30/37] create-diff-object: ignore .note.gnu.property section
Linux GABI introduced new .note.gnu.property section which contains a program Linux GABI introduced new .note.gnu.property section which contains a program
property note which describes special handling requirements for linker and run-time loader. property note which describes special handling requirements for linker and run-time loader.
@ -18,10 +18,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 2 insertions(+), 1 deletion(-) 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 03c877e..c2ecefa 100644 index 0b8c46e..1abf3b8 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3063,7 +3063,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf, @@ -3104,7 +3104,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
if (strcmp(sec->name, "__tracepoints") && if (strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") && strcmp(sec->name, "__tracepoints_ptrs") &&
strcmp(sec->name, "__tracepoints_strings") && strcmp(sec->name, "__tracepoints_strings") &&
@ -32,5 +32,5 @@ index 03c877e..c2ecefa 100644
sec->status = SAME; sec->status = SAME;
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,7 +1,7 @@
From 19b6926284ad2811f6de0ec29e0b45f3ae8b09dd Mon Sep 17 00:00:00 2001 From 9126e10f4998e84f9056b83419f56689c5bcf879 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:55 +0800 Date: Tue, 10 May 2022 15:28:55 +0800
Subject: [PATCH 9/9] create-diff-object: skip creating .kpatch.arch section Subject: [PATCH 31/37] create-diff-object: skip creating .kpatch.arch section
for sections with empty secsym for sections with empty secsym
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
@ -10,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index c2ecefa..6b46e1f 100644 index 1abf3b8..ecc08e9 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -2952,7 +2952,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj @@ -2990,7 +2990,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj
continue; continue;
sec = find_section_by_name(&kelf->sections, special->name); sec = find_section_by_name(&kelf->sections, special->name);
@ -23,5 +23,5 @@ index c2ecefa..6b46e1f 100644
/* entries[index].sec */ /* entries[index].sec */
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,8 +1,8 @@
From 72d80c02e16d7558bea6512116bac2b9461bf879 Mon Sep 17 00:00:00 2001 From 3112275d447899a7063f5753d2cfed4003eecf9d Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 16:12:29 +0800 Date: Tue, 10 May 2022 16:12:29 +0800
Subject: [PATCH] kpatch-build: do not copy linux scripts when building OOT Subject: [PATCH 32/37] kpatch-build: do not copy linux scripts when building
module hotpatch OOT module hotpatch
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,18 +10,18 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index ce163e5..dc5f5a5 100644 index 5063dd7..827207f 100755
--- a/kpatch-build/kpatch-build --- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build
@@ -955,7 +955,7 @@ grep -q "CONFIG_GCC_PLUGIN_RANDSTRUCT=y" "$CONFIGFILE" && die "kernel option 'CO @@ -932,7 +932,7 @@ fi
# support extended ELF sections. Disable the BTF typeinfo generation in # support extended ELF sections. Disable the BTF typeinfo generation in
# link-vmlinux.sh and Makefile.modfinal since kpatch doesn't care about # link-vmlinux.sh and Makefile.modfinal since kpatch doesn't care about
# that anyway. # that anyway.
-if grep -q "CONFIG_DEBUG_INFO_BTF=y" "$CONFIGFILE" ; then -if [[ -n "$CONFIG_DEBUG_INFO_BTF" ]]; then
+if grep -q "CONFIG_DEBUG_INFO_BTF=y" "$CONFIGFILE" && [[ -z "$OOT_MODULE" ]] ; then +if [[ -n "$CONFIG_DEBUG_INFO_BTF" ]] && [[ -z "$OOT_MODULE" ]] ; then
cp -f "$SRCDIR/scripts/link-vmlinux.sh" "$TEMPDIR/link-vmlinux.sh" || die cp -f "$KERNEL_SRCDIR/scripts/link-vmlinux.sh" "$TEMPDIR/link-vmlinux.sh" || die
sed -i 's/CONFIG_DEBUG_INFO_BTF/DISABLED_FOR_KPATCH_BUILD/g' "$SRCDIR"/scripts/link-vmlinux.sh || die sed -i 's/CONFIG_DEBUG_INFO_BTF/DISABLED_FOR_KPATCH_BUILD/g' "$KERNEL_SRCDIR"/scripts/link-vmlinux.sh || die
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,7 +1,8 @@
From ff93b567f3cff56e3f0c668258499acb1d511865 Mon Sep 17 00:00:00 2001 From c7a3d873d6f0655765aee36c76b41c5e54286388 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Mon, 23 May 2022 17:00:37 +0800 Date: Mon, 23 May 2022 17:00:37 +0800
Subject: [PATCH] create-diff-object: ignore change of certain special sections Subject: [PATCH 33/37] create-diff-object: ignore change of certain special
sections
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -9,10 +10,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 13 insertions(+) 1 file changed, 13 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6b46e1f..7fabf4d 100644 index ecc08e9..8e73584 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3076,6 +3076,19 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf, @@ -3117,6 +3117,19 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
} }
} }
@ -33,5 +34,5 @@ index 6b46e1f..7fabf4d 100644
} }
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,8 +1,8 @@
From 556db3ad9deab83942621e56accc711427224ca5 Mon Sep 17 00:00:00 2001 From e7781ead26083eebec1203ac81a797fd07c077c3 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Mon, 23 May 2022 17:08:50 +0800 Date: Mon, 23 May 2022 17:08:50 +0800
Subject: [PATCH] create-diff-object: allow __jump_table section change for Subject: [PATCH 34/37] create-diff-object: allow __jump_table section change
module hotpatch for module hotpatch
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,18 +10,18 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 7fabf4d..d7a6789 100644 index 8e73584..b0975f7 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -3493,7 +3493,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, @@ -3554,7 +3554,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
* special section init code (e.g., apply_paravirt) * special section init code (e.g., apply_paravirt)
* runs due to late module patching. * runs due to late module patching.
*/ */
- if (!KLP_ARCH && !vmlinux && special) - if (!KLP_ARCH && !vmlinux && special)
+ if (!KLP_ARCH && !vmlinux && special && strcmp(sec->base->name, "__jump_table")) + if (!KLP_ARCH && !vmlinux && special && strcmp(relasec->base->name, "__jump_table"))
ERROR("unsupported dynrela reference to symbol '%s' in module-specific special section '%s'", ERROR("unsupported dynrela reference to symbol '%s' in module-specific special section '%s'",
rela->sym->name, sec->base->name); rela->sym->name, relasec->base->name);
-- --
2.31.0.windows.1 2.33.0

View File

@ -1,8 +1,8 @@
From ec538d436364293b15e41f3c2c2a8ab389c7b043 Mon Sep 17 00:00:00 2001 From f4b25dccaac3540f8826ea637549349c0a156a40 Mon Sep 17 00:00:00 2001
From: tangbin <tangbin@cmss.chinamobile.com> From: tangbin <tangbin@cmss.chinamobile.com>
Date: Mon, 5 Sep 2022 12:09:06 -0400 Date: Mon, 5 Sep 2022 12:09:06 -0400
Subject: [PATCH] livepatch-patch-hook: fix kpatch-build error which do not Subject: [PATCH 35/37] livepatch-patch-hook: fix kpatch-build error which do
support ftrace not support ftrace
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
@ -39,5 +39,5 @@ index b565a6a..5d8780c 100644
#ifdef RHEL_RELEASE_CODE #ifdef RHEL_RELEASE_CODE
-- --
2.18.4 2.33.0

View File

@ -1,8 +1,8 @@
From 6b79df49055abbccd3033fbec52085b8a9d7b250 Mon Sep 17 00:00:00 2001 From cb75d02d8b8a773386ef3867457d600752a9ec4b Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Sun, 9 Oct 2022 10:34:52 +0800 Date: Sun, 9 Oct 2022 10:34:52 +0800
Subject: [PATCH] lookup: skip finding local symbols for object with no local Subject: [PATCH 36/37] lookup: skip finding local symbols for object with no
symbols local symbols
Signed-off-by: hubin <hubin73@huawei.com> Signed-off-by: hubin <hubin73@huawei.com>
--- ---
@ -10,7 +10,7 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 19 insertions(+) 1 file changed, 19 insertions(+)
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index b77d7a8..875605d 100644 index d3b6ae9..4b1717a 100644
--- a/kpatch-build/lookup.c --- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c
@@ -166,6 +166,22 @@ static bool locals_match(struct lookup_table *table, int idx, @@ -166,6 +166,22 @@ static bool locals_match(struct lookup_table *table, int idx,
@ -47,5 +47,5 @@ index b77d7a8..875605d 100644
if (sym->type != STT_FILE) if (sym->type != STT_FILE)
continue; continue;
-- --
2.27.0 2.33.0

View File

@ -1,8 +1,8 @@
From 594f0810329ca074d53399f6d1927aa87607c34a Mon Sep 17 00:00:00 2001 From 4386311b1342c89a999ec2eb6828c9983ffacb65 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com> From: hubin <hubin73@huawei.com>
Date: Sun, 9 Oct 2022 14:33:13 +0800 Date: Sun, 9 Oct 2022 14:33:13 +0800
Subject: [PATCH] create-diff-object: ignore entsize change of .return_sites Subject: [PATCH 37/37] create-diff-object: ignore entsize change of
section .return_sites section
If a patch contains newly exported function, kernel Makefile.build If a patch contains newly exported function, kernel Makefile.build
script will add one ld step when generating object file, which script will add one ld step when generating object file, which
@ -17,10 +17,10 @@ Signed-off-by: hubin <hubin73@huawei.com>
1 file changed, 2 insertions(+), 1 deletion(-) 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index d7a6789..77ee7b2 100644 index b0975f7..49ada5f 100644
--- a/kpatch-build/create-diff-object.c --- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c
@@ -555,7 +555,8 @@ static void kpatch_compare_correlated_section(struct section *sec) @@ -569,7 +569,8 @@ static void kpatch_compare_correlated_section(struct section *sec)
/* Compare section headers (must match or fatal) */ /* Compare section headers (must match or fatal) */
if (sec1->sh.sh_type != sec2->sh.sh_type || if (sec1->sh.sh_type != sec2->sh.sh_type ||
sec1->sh.sh_flags != sec2->sh.sh_flags || sec1->sh.sh_flags != sec2->sh.sh_flags ||
@ -31,5 +31,5 @@ index d7a6789..77ee7b2 100644
!is_text_section(sec1) && strcmp(sec1->name, ".rodata"))) !is_text_section(sec1) && strcmp(sec1->name, ".rodata")))
DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name); DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name);
-- --
2.27.0 2.33.0

View File

@ -1,79 +0,0 @@
From fd5e883eae4d2187e1c2cd6d66b2cf6376183d0e Mon Sep 17 00:00:00 2001
From: tangbin <tangbin_yewu@cmss.chinamobile.com>
Date: Tue, 6 Sep 2022 11:03:02 -0400
Subject: [PATCH] kpatch-build: fix loading error in aarch64
When using the kernel version 4.19.90-2112.8.0.0131.oe1 in
openEuler-22.03-LTS-aarch64, there are some errors in dmesg
as follows:
[ 44.843180 < 38.388618>] klp_30: loading out-of-tree module taints kernel.
[ 44.843183 < 0.000003>] klp_30: tainting kernel with TAINT_LIVEPATCH
[ 44.843325 < 0.000142>] klp_30: module verification failed: signature and/or required key missing - t ainting kernel
[ 44.844007 < 0.000682>] WARNING: CPU: 20 PID: 7708 at kernel/trace/ftrace.c:2040 ftrace_bug+0x74/0x25 8
[ 44.844009 < 0.000002>] Modules linked in: nft_objref nf_conntrack_tftp tun nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_tables_set nf_tabl es ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_nat_ipv6 ip6table_mangle ip6table_raw ip6table _security iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_mangl e iptable_raw iptable_security rfkill ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables i ptable_filter ip_tables sunrpc sg vfat fat sch_fq_codel fuse ext4 mbcache jbd2 sr_mod sd_mod cdrom virtio_n et virtio_gpu net_failover virtio_scsi failover aes_ce_blk crypto_simd cryptd aes_ce_cipher ghash_ce sha2_c e sha256_arm64 sha1_ce virtio_pci virtio_mmio virtio_ring virtio dm_mirror dm_region_hash
[ 44.844035 < 0.000026>] dm_log dm_mod
[ 44.844040 < 0.000005>] CPU: 20 PID: 7708 Comm: insmod Kdump: loaded Tainted: G OE K 4.19 .90+ #1
[ 44.844041 < 0.000001>] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
[ 44.844043 < 0.000002>] pstate: 60400005 (nZCv daif +PAN -UAO)
[ 44.844045 < 0.000002>] pc : ftrace_bug+0x74/0x258
[ 44.844048 < 0.000003>] lr : ftrace_update_code.isra.0+0xe0/0x114
[ 44.844048 < 0.000000>] sp : ffff00002366fc20
[ 44.844049 < 0.000001>] x29: ffff00002366fc20 x28: ffff0000093b5d40
[ 44.844050 < 0.000001>] x27: ffff0000080a2e38 x26: ffff0000093b5000
[ 44.844051 < 0.000001>] x25: ffff000009070028 x24: 0000000002000000
[ 44.844053 < 0.000002>] x23: ffff000002270080 x22: ffff000009725000
[ 44.844054 < 0.000001>] x21: ffff000008df6650 x20: ffff000002250514
[ 44.844055 < 0.000001>] x19: ffff8000c9990050 x18: 0000000000000000
[ 44.844056 < 0.000001>] x17: 0000000000000000 x16: 0000000000000000
[ 44.844057 < 0.000001>] x15: ffff000002250514 x14: ff00000000000000
[ 44.844058 < 0.000001>] x13: 0000000000000000 x12: 0000000000000000
[ 44.844059 < 0.000001>] x11: fefefefefefefeff x10: 0000000000000000
[ 44.844060 < 0.000001>] x9 : 0000000000000000 x8 : ffff8000c9212000
[ 44.844061 < 0.000001>] x7 : ffff00002366f7f0 x6 : ffff00002366fc08
[ 44.844062 < 0.000001>] x5 : ffff00002366fc08 x4 : 000000000fffffff
[ 44.844063 < 0.000001>] x3 : ffff0000093b5d40 x2 : ffff0000093b5000
[ 44.844064 < 0.000001>] x1 : ffff0000080a2e60 x0 : 00000000ffffffea
[ 44.844066 < 0.000002>] Call trace:
[ 44.844068 < 0.000002>] ftrace_bug+0x74/0x258
[ 44.844069 < 0.000001>] ftrace_update_code.isra.0+0xe0/0x114
[ 44.844071 < 0.000002>] ftrace_process_locs.isra.0+0x118/0x1f0
[ 44.844072 < 0.000001>] ftrace_module_init+0x2c/0x34
[ 44.844078 < 0.000006>] load_module+0x3f4/0x820
[ 44.844080 < 0.000002>] __se_sys_finit_module+0xb8/0x120
[ 44.844081 < 0.000001>] __arm64_sys_finit_module+0x28/0x34
[ 44.844084 < 0.000003>] el0_svc_common+0x118/0x170
[ 44.844085 < 0.000001>] el0_svc_handler+0x3c/0x80
[ 44.844088 < 0.000003>] el0_svc+0x8/0x640
[ 44.844090 < 0.000002>] ---[ end trace dab33fa797cbe7ee ]---
[ 44.844090 < 0.000000>] ftrace failed to modify
[ 44.844093 < 0.000003>] [] 0xffff000002250514
[ 44.844093 < 0.000000>] actual: 1f:20:03:d5
[ 44.844096 < 0.000003>] Initializing ftrace call sites
[ 44.844097 < 0.000001>] ftrace record flags: 2000000
[ 44.844098 < 0.000001>] (0)
expected tramp: ffff0000080a2e3c
Thus, fix this problem.
Signed-off-by: tangbin <tangbin_yewu@cmss.chinamobile.com>
---
kpatch-build/kpatch-elf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c
index 2df9105..c84d865 100644
--- a/kpatch-build/kpatch-elf.c
+++ b/kpatch-build/kpatch-elf.c
@@ -325,7 +325,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf)
list_for_each_entry(sym, &kelf->symbols, list) {
if (sym->type != STT_FUNC || !sym->sec || !sym->sec->rela)
continue;
-#if defined(__powerpc64__) || defined(__aarch64__)
+#if defined(__powerpc64__)
list_for_each_entry(rela, &sym->sec->rela->relas, list) {
if (!strcmp(rela->sym->name, "_mcount")) {
sym->has_func_profiling = 1;
--
2.18.4

View File

@ -1,43 +0,0 @@
From 81a48ca6a060cf006cf9eec309e726c4333a9d46 Mon Sep 17 00:00:00 2001
From: tangbin <tangbin_yewu@cmss.chinamobile.com>
Date: Tue, 6 Sep 2022 11:46:41 -0400
Subject: [PATCH] kpatch-build: Remove duplicate functions
We find that there are duplicate functions of "use_klp_arch()" &
"rhel_kernel_version_gte", and one of them are useless, so remove
them.
Signed-off-by: tangbin <tangbin_yewu@cmss.chinamobile.com>
---
kpatch-build/kpatch-build | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index dc5f5a5..6a0645a 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -198,21 +198,6 @@ rhel_kernel_version_gte() {
[ "${ARCHVERSION}" = "$(echo -e "${ARCHVERSION}\\n$1" | sort -rV | head -n1)" ]
}
-# klp.arch relocations were supported prior to v5.8
-# and prior to 4.18.0-240.el8
-use_klp_arch()
-{
- if kernel_is_rhel; then
- ! rhel_kernel_version_gte 4.18.0-240.el8
- else
- ! kernel_version_gte 5.8.0
- fi
-}
-
-rhel_kernel_version_gte() {
- [ "${ARCHVERSION}" = "$(echo -e "${ARCHVERSION}\\n$1" | sort -rV | head -n1)" ]
-}
-
# klp.arch relocations were supported prior to v5.8
# and prior to 4.18.0-284.el8
use_klp_arch()
--
2.18.4

View File

@ -1,43 +0,0 @@
From 764baf9f38c15d48a7cacbafcad9b83b7a23d842 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Thu, 1 Sep 2022 06:13:03 +0800
Subject: [PATCH] create-diff-object: add support for .return_sites section
Signed-off-by: Jonathan Dobson <jdobson@redhat.com>
Reference:https://github.com/dynup/kpatch/commit/33368a88cdf875b0edd02b0dfd3356a7e93b24db
Conflict:kpatch-build/create-diff-object.c
---
kpatch-build/create-diff-object.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 58d4763..3c55013 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2242,6 +2242,11 @@ static int retpoline_sites_group_size(struct kpatch_elf *kelf, int offset)
{
return 4;
}
+
+static int return_sites_group_size(struct kpatch_elf *kelf, int offset)
+{
+ return 4;
+}
#endif
#ifdef __powerpc64__
static int fixup_entry_group_size(struct kpatch_elf *kelf, int offset)
@@ -2362,6 +2367,10 @@ static struct special_section special_sections[] = {
.name = ".retpoline_sites",
.group_size = retpoline_sites_group_size,
},
+ {
+ .name = ".return_sites",
+ .group_size = return_sites_group_size,
+ },
#endif
#ifdef __powerpc64__
{
--
2.33.0

Binary file not shown.

BIN
kpatch-0.9.7.tar.gz Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
Name: kpatch Name: kpatch
Epoch: 1 Epoch: 1
Version: 0.9.5 Version: 0.9.7
Release: 16 Release: 1
Summary: A Linux dynamic kernel patching infrastructure Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2 License: GPLv2
@ -19,46 +19,37 @@ Patch0003:0003-create-diff-object-support-kpatch_line_macro_change_.patch
Patch0004:0004-create-diff-object-support-skip-check-func-profiling.patch Patch0004:0004-create-diff-object-support-skip-check-func-profiling.patch
Patch0005:0005-create-diff-object-new-static-var-should-be-included.patch Patch0005:0005-create-diff-object-new-static-var-should-be-included.patch
Patch0006:0006-create-diff-object-fix-correlate-static-local-variab.patch Patch0006:0006-create-diff-object-fix-correlate-static-local-variab.patch
Patch0007:0007-fix-rodata.str-problem.patch Patch0007:0007-livepatch-patch-hook-support-no-active-after-load.patch
Patch0008:0008-livepatch-patch-hook-support-no-active-after-load.patch Patch0008:0008-kpatch-build-enhance-for-out-of-tree-module.patch
Patch0009:0009-kpatch-build-enhance-for-out-of-tree-module.patch Patch0009:0009-support-c-kernel-module.patch
Patch0010:0010-support-c-kernel-module.patch Patch0010:0010-symbol-lookup-enhancement.patch
Patch0011:0011-symbol-lookup-enhancement.patch Patch0011:0011-Add-running-kernel-symbol-table-to-help-symbol-looku.patch
Patch0012:0012-Add-running-kernel-symbol-table-to-help-symbol-looku.patch Patch0012:0012-livepatch-patch-hook-support-force-enable-disable.patch
Patch0013:0013-livepatch-patch-hook-support-force-enable-disable.patch Patch0013:0013-kpatch-build-ignore-debuginfo-in-patch.patch
Patch0014:0014-kpatch-build-ignore-debuginfo-in-patch.patch Patch0014:0014-add-object-in-kpatch.patch
Patch0015:0015-add-object-in-kpatch.patch Patch0015:0015-create-diff-object-fix-.orc_unwind_ip-error.patch
Patch0016:0016-create-diff-object-fix-.orc_unwind_ip-error.patch Patch0016:0016-create-diff-object-add-jump-label-support.patch
Patch0017:0017-create-diff-object-add-jump-label-support.patch Patch0017:0017-kpatch-build-add-compile-flag-fno-reorder-functions.patch
Patch0018:0018-kpatch-build-add-compile-flag-fno-reorder-functions.patch Patch0018:0018-Fix-relocation-not-resolved-when-new-functions-expor.patch
Patch0019:0019-Fix-relocation-not-resolved-when-new-functions-expor.patch Patch0019:0019-support-remove-static-variables-using-KPATCH_IGNORE_.patch
Patch0020:0020-support-remove-static-variables-using-KPATCH_IGNORE_.patch Patch0020:0020-use-original-reloc-for-symbols-exported-from-modules.patch
Patch0021:0021-create-diff-object-fix-segment-fault-when-sec2-rela-.patch Patch0021:0021-create-diff-object-create-dynamic-relocs-for-changed.patch
Patch0022:0022-use-original-reloc-for-symbols-exported-from-modules.patch Patch0022:0022-kpatch-build-support-CROSS_COMPILE.patch
Patch0023:0023-create-diff-object-create-dynamic-relocs-for-changed.patch Patch0023:0023-livepatch-patch-hook-disable-HAVE_SIMPLE_ENABLE-to-k.patch
Patch0024:0024-kpatch-build-support-CROSS_COMPILE.patch Patch0024:0024-kpatch-build-add-KBUILD_MODPOST_WARN-1-to-avoid-modp.patch
Patch0025:0025-create-diff-object-update-for-__already_done.patch Patch0025:0025-kpatch-build-update-find_parent_obj-to-avoid-error-t.patch
Patch0026:0026-kpatch-build-Add-missing-allocation-failure-checks.patch Patch0026:0026-create-diff-object-fix-segment-fault-when-using-KPAT.patch
Patch0027:0027-create-diff-object-add-support-for-.retpoline_sites-.patch Patch0027:0027-kpatch-macros-replace-__section-with-__kpatch_sectio.patch
Patch0028:0028-Fix-sym-type-condition-in-locals_match.patch Patch0028:0028-create-diff-object-ignore-changed-of-section-__patch.patch
Patch0029:0029-livepatch-patch-hook-disable-HAVE_SIMPLE_ENABLE-to-k.patch Patch0029:0029-create-diff-object-fix-null-pointer-dereference-in-k.patch
Patch0030:0030-kpatch-build-add-KBUILD_MODPOST_WARN-1-to-avoid-modp.patch Patch0030:0030-create-diff-object-ignore-.note.gnu.property-section.patch
Patch0031:0031-kpatch-build-update-find_parent_obj-to-avoid-error-t.patch Patch0031:0031-create-diff-object-skip-creating-.kpatch.arch-sectio.patch
Patch0032:0032-create-diff-object-fix-segment-fault-when-using-KPAT.patch Patch0032:0032-kpatch-build-do-not-copy-linux-scripts-when-building.patch
Patch0033:0033-kpatch-macros-replace-__section-with-__kpatch_sectio.patch Patch0033:0033-create-diff-object-ignore-change-of-certain-special-.patch
Patch0034:0034-create-diff-object-ignore-changed-of-section-__patch.patch Patch0034:0034-create-diff-object-allow-__jump_table-section-change.patch
Patch0035:0035-create-diff-object-fix-null-pointer-dereference-in-k.patch Patch0035:0035-livepatch-patch-hook-fix-kpatch-build-error-which-do.patch
Patch0036:0036-create-diff-object-ignore-.note.gnu.property-section.patch Patch0036:0036-lookup-skip-finding-local-symbols-for-object-with-no.patch
Patch0037:0037-create-diff-object-skip-creating-.kpatch.arch-sectio.patch Patch0037:0037-create-diff-object-ignore-entsize-change-of-.return_.patch
Patch0038:0038-kpatch-build-do-not-copy-linux-scripts-when.patch
Patch0039:0039-create-diff-object-ignore-change-of-certain.patch
Patch0040:0040-create-diff-object-allow-__jump_table-section.patch
Patch0041:0041-livepatch-patch-hook-fix-kpatch-build-error-which-do.patch
Patch0042:0042-kpatch-build-fix-loading-error-in-aarch64.patch
Patch0043:0043-kpatch-build-Remove-duplicate-functions.patch
Patch0044:0044-lookup-skip-finding-local-symbols-for-object-with-no.patch
Patch0045:0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch
Patch0046:0046-create-diff-object-ignore-entsize-change-of-.return_.patch
BuildRequires: gcc elfutils-libelf-devel kernel-devel git BuildRequires: gcc elfutils-libelf-devel kernel-devel git
Requires: bc make gcc patch bison flex openssl-devel Requires: bc make gcc patch bison flex openssl-devel
@ -119,6 +110,12 @@ popd
%{_mandir}/man1/*.1.gz %{_mandir}/man1/*.1.gz
%changelog %changelog
* Mon Jan 30 2023 Bin Hu <hubin73@huawei.com> -1:0.9.7-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:upgrade kpatch to version 0.9.7
* Mon Oct 17 2022 lvgenggeng <lvgenggeng@uniontech.com> - 1:0.9.5-16 * Mon Oct 17 2022 lvgenggeng <lvgenggeng@uniontech.com> - 1:0.9.5-16
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA