From eabf9565c8052bea995b5ed8a1c582f6edc58358 Mon Sep 17 00:00:00 2001 From: Wenlong Zhang Date: Tue, 9 May 2023 19:36:36 +0800 Subject: [PATCH] Add loongarch64 architecture Signed-off-by: Wenlong Zhang --- 0048-add-loongarch64-support-for-kpatch.patch | 55 +++++++++++++++++++ kpatch.spec | 9 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 0048-add-loongarch64-support-for-kpatch.patch diff --git a/0048-add-loongarch64-support-for-kpatch.patch b/0048-add-loongarch64-support-for-kpatch.patch new file mode 100644 index 0000000..92d9994 --- /dev/null +++ b/0048-add-loongarch64-support-for-kpatch.patch @@ -0,0 +1,55 @@ +From 7f9b752431dde909775fed98df62fd2839bd87f3 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Tue, 9 May 2023 11:30:10 +0000 +Subject: [PATCH] add loongarch64 support for kpatch + +--- + kpatch-build/Makefile | 4 ++++ + kpatch-build/create-diff-object.c | 2 +- + kpatch-build/kpatch-elf.c | 2 +- + 3 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile +index bf18d1c..5668e73 100644 +--- a/kpatch-build/Makefile ++++ b/kpatch-build/Makefile +@@ -30,6 +30,10 @@ GCC_PLUGINS_DIR := $(shell gcc -print-file-name=plugin) + PLUGIN_CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) + PLUGIN_CFLAGS += -shared -I$(GCC_PLUGINS_DIR)/include \ + -Igcc-plugins -fPIC -fno-rtti -O2 -Wall ++else ifeq ($(ARCH),loongarch64) ++SOURCES += insn/insn.c insn/inat.c ++INSN = insn/insn.o insn/inat.o ++insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) + else + $(error Unsupported architecture ${ARCH}, check https://github.com/dynup/kpatch/#supported-architectures) + endif +diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c +index f6f81f1..187079a 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -1688,7 +1688,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf) + continue; + } + +-#if defined(__powerpc64__) || defined(__aarch64__) || defined(__sw_64__) ++#if defined(__powerpc64__) || defined(__aarch64__) || defined(__sw_64__) || (__loongarch64) + add_off = 0; + #else + if (rela->type == R_X86_64_PC32 || +diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c +index 9e30922..abfcc66 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(__sw_64__) ++#if defined(__powerpc64__) || defined(__sw_64__) || (__loongarch64) + list_for_each_entry(rela, &sym->sec->rela->relas, list) { + if (!strcmp(rela->sym->name, "_mcount")) { + sym->has_func_profiling = 1; +-- +2.33.0 + diff --git a/kpatch.spec b/kpatch.spec index c1c1872..a323fe5 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,7 +1,7 @@ Name: kpatch Epoch: 1 Version: 0.9.5 -Release: 7 +Release: 8 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -60,6 +60,7 @@ 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 Patch0047:0047-kpatch-Add-sw64-architecture.patch +Patch0048:0048-add-loongarch64-support-for-kpatch.patch BuildRequires: gcc elfutils-libelf-devel kernel-devel git Requires: bc make gcc patch bison flex openssl-devel @@ -120,6 +121,12 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Mon May 8 2023 Wenlong Zhang - 1:0.9.5-8 +- Type:feature +- CVE:NA +- SUG:NA +- DESC:Add loongarch64 architecture + * Fri Oct 21 2022 wuzx - 1:0.9.5-7 - Type:feature - CVE:NA -- Gitee