Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
e93169d84c
!149 [sync] PR-146: 添加loongarch64支持
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-11-25 08:35:48 +00:00
沈仲伟
4b60fbfb08 add support loongarch64
(cherry picked from commit b518d14017e2df4a353ddaff0e6256a16ac90137)
2024-11-25 15:27:15 +08:00
openeuler-ci-bot
8068141704
!139 [sync] PR-132: add gcc-c++ to BuildRequires for ppc64le
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-06-26 10:15:20 +00:00
peng_zou
e9cb580433 add gcc-c++ to BuildRequires for ppc64le
(cherry picked from commit 9fbce93c90886ce8b6bf5410a631e75edd316cdb)
2024-06-12 14:34:20 +08:00
openeuler-ci-bot
b7d99b7d52
!135 [sync] PR-129: ignore initcall5 section to adapt 6.6 kernel
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-06-12 06:23:06 +00:00
c00662745
b274c7aabe ignore initcall5 section to adapt 6.6 kernel
(cherry picked from commit 179aede8ec6c91f83162658ff29dc2ff20589615)
2024-06-12 11:46:49 +08:00
openeuler-ci-bot
0bbbe4a9d2
!130 [sync] PR-127: adapt arm64 dynamic ftrace call with 2 nops
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-06-12 03:43:26 +00:00
c00662745
fa3e3405d8 adapt arm64 dynamic ftrace call with 2 nops
(cherry picked from commit 284e07e60bf9e1b50018f5e6edced15d3578fb25)
2024-06-11 19:12:54 +08:00
openeuler-ci-bot
95b877649f
!124 [sync] PR-121: fix function ptr relocation and strip .BTF section for ko
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-05-09 07:44:36 +00:00
caixiaomeng 00662745
f37905512b fix function ptr relocation and strip .BTF section for ko
(cherry picked from commit ebcfccbc3f99eb9e95ce40deaba685b7d4b86b29)
2024-05-09 15:10:37 +08:00
5 changed files with 197 additions and 2 deletions

View File

@ -0,0 +1,37 @@
From c5bdb0c5b87ca1b94b59f88b548b9f2c263ef2df Mon Sep 17 00:00:00 2001
From: shenzhongwei <shenzhongwei@kylinos.cn>
Date: Tue, 14 May 2024 15:50:15 +0800
Subject: [PATCH] add loongarch64 support
---
kpatch-build/Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile
index f24165b..f042a6a 100644
--- a/kpatch-build/Makefile
+++ b/kpatch-build/Makefile
@@ -13,6 +13,11 @@ SOURCES = create-diff-object.c kpatch-elf.c \
SOURCES += insn/insn.c insn/inat.c
INSN = insn/insn.o insn/inat.o
insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS))
+ifeq ($(ARCH),loongarch64)
+SOURCES += insn/insn.c insn/inat.c
+INSN = insn/insn.o insn/inat.o
+insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS))
+endif
ifeq ($(ARCH),ppc64le)
SOURCES += gcc-plugins/ppc64le-plugin.c
PLUGIN = gcc-plugins/ppc64le-plugin.so
@@ -22,7 +27,7 @@ PLUGIN_CFLAGS := $(filter-out -Wconversion, $(CFLAGS))
PLUGIN_CFLAGS += -shared -I$(GCC_PLUGINS_DIR)/include \
-Igcc-plugins -fPIC -fno-rtti -O2 -Wall
endif
-ifeq ($(filter $(ARCH),s390x x86_64 ppc64le aarch64 riscv64),)
+ifeq ($(filter $(ARCH),s390x x86_64 ppc64le aarch64 riscv64 loongarch64),)
$(error Unsupported architecture ${ARCH}, check https://github.com/dynup/kpatch/#supported-architectures)
endif
--
2.43.0

View File

@ -0,0 +1,55 @@
From e8674bab4db104357780db9b960b78938fac5a6d Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Wed, 22 May 2024 20:31:59 +0800
Subject: [PATCH] huawei adapt arm64 dynamic ftrace call with 2 nops
---
kpatch-build/create-diff-object.c | 5 +++++
kpatch-build/kpatch-build | 1 +
2 files changed, 6 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 73b8337..f1dfc1d 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -242,6 +242,7 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf)
struct symbol *sym;
unsigned int expected_offset;
unsigned int directcall_offset = 16;
+ unsigned int dynamic_ftracecall_offset = 8;
list_for_each_entry(sym, &kelf->symbols, list) {
if (is_bundleable(sym)) {
@@ -253,6 +254,7 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf)
expected_offset = 0;
if (sym->sym.st_value != expected_offset &&
+ !(getenv("CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS") && sym->sym.st_value == dynamic_ftracecall_offset) &&
!(getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS") && sym->sym.st_value == directcall_offset)) {
ERROR("symbol %s at offset %lu within section %s, expected %u",
sym->name, sym->sym.st_value,
@@ -3446,6 +3448,9 @@ static int function_ptr_rela(const struct rela *rela)
if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS"))
entry_offset = 16;
+ if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS"))
+ entry_offset = 8;
+
return (rela_toc && rela_toc->sym->type == STT_FUNC &&
!rela_toc->sym->parent &&
(rela_toc->addend == (int)rela_toc->sym->sym.st_value ||
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index edc05b3..886a753 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -1181,6 +1181,7 @@ else
fi
grep -q "CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=1
+grep -q "CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=1
# unsupported kernel option checking
[[ -n "$CONFIG_DEBUG_INFO_SPLIT" ]] && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported"
--
2.33.0

View File

@ -0,0 +1,40 @@
From 9a1729d47ea279a63c29e45ffee9892f95ed18c2 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 6 May 2024 19:18:02 +0800
Subject: [PATCH] fix function ptr relocation and strip .BTF section for ko
---
kpatch-build/create-diff-object.c | 2 +-
kpatch-build/kpatch-build | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 5de19f4..73b8337 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3444,7 +3444,7 @@ static int function_ptr_rela(const struct rela *rela)
int entry_offset = 0;
if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS"))
- entry_offset = 20;
+ entry_offset = 16;
return (rela_toc && rela_toc->sym->type == STT_FUNC &&
!rela_toc->sym->parent &&
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 17cb83d..edc05b3 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -1555,6 +1555,9 @@ if [[ "$USE_KLP" -eq 1 ]]; then
[[ "$rc" -ne 0 ]] && die "create-klp-module: exited with return code: $rc"
fi
+objcopy --remove-section=.BTF "$TEMPDIR/patch/$MODNAME.ko" "$TEMPDIR/patch/${MODNAME}_tmp.ko"
+mv "$TEMPDIR/patch/${MODNAME}_tmp.ko" "$TEMPDIR/patch/$MODNAME.ko"
+
if [[ -n "$CONFIG_MODVERSIONS" ]]; then
# Check that final module does not reference symbols with different version
# than the target kernel
--
2.33.0

View File

@ -0,0 +1,29 @@
From bad5b93c1fa85cc4b71533284064fd0af1bab464 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Fri, 24 May 2024 14:45:55 +0800
Subject: [PATCH] ignore initcall5 section to adapt 6.6 kernel
---
kpatch-build/create-diff-object.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index f1dfc1d..4c029ae 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2035,8 +2035,12 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf)
int kpatch_include_new_static_var(struct kpatch_elf *kelf)
{
struct symbol *sym;
+ char *initcall_prefix = "__initcall__kmod";
list_for_each_entry(sym, &kelf->symbols, list) {
+ if (strncmp(sym->name, initcall_prefix, strlen(initcall_prefix)) == 0) {
+ continue;
+ }
if (sym->status == NEW &&
sym->bind == STB_LOCAL &&
(sym->type == STT_OBJECT ||
--
2.33.0

View File

@ -1,7 +1,7 @@
Name: kpatch
Epoch: 1
Version: 0.9.9
Release: 4
Release: 9
Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2
@ -52,14 +52,18 @@ Patch0036:0036-create-diff-object-ignore-entsize-change-of-.return_.patch
Patch0037:0037-add-initial-riscv64-support.patch
Patch0038:0038-Fix-undefined-behavior-problem-when-using-list_forea.patch
Patch0039:0039-build-support-for-building-with-clang.patch
Patch0040:0001-add-loongarch64-support.patch
Patch9001:huawei-fix-function-ptr-relocation.patch
Patch9002:huawei-lookup.c-ignore-BTF-ID-when-matching-locals.patch
Patch9003:huawei-adapt-kpatch-to-6.6-kernel-and-fix-bundle-symbols-ch.patch
Patch9004:huawei-fix-function-ptr-relocation-and-strip-.BTF-section-f.patch
Patch9005:huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch
Patch9006:huawei-ignore-initcall5-section-to-adapt-6.6-kernel.patch
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
%ifarch ppc64le
BuildRequires: gcc-plugin-devel
BuildRequires: gcc-plugin-devel gcc-c++
%endif
Requires: bc make gcc patch bison flex openssl-devel
Recommends: %{name}-help = %{version}-%{release}
@ -119,6 +123,36 @@ popd
%{_mandir}/man1/*.1.gz
%changelog
* Fri May 24 2024 shenzhongwei <shenzhongwei@kylinos.cn> - 1:0.9.9-9
- Type:update
- CVE:NA
- SUG:NA
- DESC:add support loongarch64
* Wed Jun 12 2024 peng.zou <peng.zou@shingroup.cn> - 1:0.9.9-8
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add gcc-c++ to BuildRequires for ppc64le
* Fri May 24 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.9-7
- Type: bugfix
- CVE:NA
- SUG:NA
- DESC:ignore initcall5 section to adapt 6.6 kernel
* Wed May 22 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.9-6
- Type: bugfix
- CVE:NA
- SUG:NA
- DESC:adapt arm64 dynamic ftrace call with 2 nops
* Mon May 6 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.9-5
- Type: bugfix
- CVE:NA
- SUG:NA
- DESC:fix function ptr relocation and strip .BTF section for ko
* Tue Apr 30 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.9-4
- Type: bugfix
- CVE:NA