adapt arm64 dynamic ftrace call with 2 nops

This commit is contained in:
c00662745 2024-05-22 20:53:57 +08:00
parent 48e93f7b03
commit 284e07e60b
2 changed files with 63 additions and 1 deletions

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

@ -1,7 +1,7 @@
Name: kpatch Name: kpatch
Epoch: 1 Epoch: 1
Version: 0.9.9 Version: 0.9.9
Release: 5 Release: 6
Summary: A Linux dynamic kernel patching infrastructure Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2 License: GPLv2
@ -57,6 +57,7 @@ Patch9001:huawei-fix-function-ptr-relocation.patch
Patch9002:huawei-lookup.c-ignore-BTF-ID-when-matching-locals.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 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 Patch9004:huawei-fix-function-ptr-relocation-and-strip-.BTF-section-f.patch
Patch9005:huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch
BuildRequires: gcc elfutils-libelf-devel kernel-devel git BuildRequires: gcc elfutils-libelf-devel kernel-devel git
%ifarch ppc64le %ifarch ppc64le
@ -120,6 +121,12 @@ popd
%{_mandir}/man1/*.1.gz %{_mandir}/man1/*.1.gz
%changelog %changelog
* 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 * Mon May 6 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.9-5
- Type: bugfix - Type: bugfix
- CVE:NA - CVE:NA