From 148cc77f65d47fbe9f0967bf00b35dc8801d8fcc Mon Sep 17 00:00:00 2001 From: Jingyun Hua Date: Fri, 2 Dec 2022 06:52:19 +0000 Subject: [PATCH] add loongarch support Signed-off-by: Jingyun Hua (cherry picked from commit 4b2f1f5aafcb6372e63856a59d3280711be02b12) --- add-loongarch-support.patch | 65 +++++++++++++++++++++++++++++++++++++ libhugetlbfs.spec | 6 +++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 add-loongarch-support.patch diff --git a/add-loongarch-support.patch b/add-loongarch-support.patch new file mode 100644 index 0000000..e314df9 --- /dev/null +++ b/add-loongarch-support.patch @@ -0,0 +1,65 @@ +diff --git a/Makefile b/Makefile +index 6ab7ae2..7c0ca79 100644 +--- a/Makefile ++++ b/Makefile +@@ -123,6 +123,12 @@ ELF64 = elf_riscv64 + TMPLIB64 = lib64 + CUSTOM_LDSCRIPTS = no + else ++ifeq ($(ARCH),loongarch64) ++CC64 = $(CC) ++ELF64 = elf_loongarch ++TMPLIB64 = lib64 ++CUSTOM_LDSCRIPTS = no ++else + $(error "Unrecognized architecture ($(ARCH))") + endif + endif +@@ -137,6 +143,7 @@ endif + endif + endif + endif ++endif + + ifdef CC32 + OBJDIRS += obj32 +diff --git a/sys-elf_loongarch.S b/sys-elf_loongarch.S +new file mode 100644 +index 0000000..47fde55 +--- /dev/null ++++ b/sys-elf_loongarch.S +@@ -0,0 +1,20 @@ ++/* ++ * libhugetlbfs - direct system call for LoongArch ++ * ++ * Author(s): Wenlong Zhang ++ */ ++ .text ++ ++ .globl direct_syscall ++direct_syscall: ++ move $a7, $a0 ++ move $a0, $a1 ++ move $a1, $a2 ++ move $a2, $a3 ++ move $a3, $a4 ++ syscall 0 ++ jr $ra ++ ++#if defined(__linux__) && defined(__ELF__) ++ .section .note.GNU-stack,"",%progbits ++#endif +diff --git a/tests/icache-hygiene.c b/tests/icache-hygiene.c +index 5b4b8db..98522bb 100644 +--- a/tests/icache-hygiene.c ++++ b/tests/icache-hygiene.c +@@ -88,7 +88,8 @@ static void sig_handler(int signum, siginfo_t *si, void *uc) + { + #if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \ + defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \ +- defined(__aarch64__) || defined(__sw_64__) || (defined(__riscv) && __riscv_xlen == 64) ++ defined(__aarch64__) || defined(__sw_64__) || (defined(__riscv) && __riscv_xlen == 64) || \ ++ defined(__loongarch__) + /* On powerpc, ia64, s390 and Aarch64, 0 bytes are an illegal + * instruction, so, if the icache is cleared properly, we SIGILL + * as soon as we jump into the cleared page */ diff --git a/libhugetlbfs.spec b/libhugetlbfs.spec index c63b10d..780bcf2 100644 --- a/libhugetlbfs.spec +++ b/libhugetlbfs.spec @@ -2,7 +2,7 @@ Name: libhugetlbfs Version: 2.23 -Release: 2 +Release: 3 Summary: A library which provides easy access to huge pages of memory License: LGPLv2+ URL: https://github.com/libhugetlbfs/libhugetlbfs @@ -11,6 +11,7 @@ Source0: https://github.com/libhugetlbfs/libhugetlbfs/releases/download/%{versi Patch0: 0000-build_flags.patch Patch1: Disable-hugepage-backed-malloc-if-__morecore-is-not-.patch Patch2: libhugetlbfs-2.23-sw.patch +Patch3: add-loongarch-support.patch #Patch9000:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED.patch #Patch9001:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED-2.patch @@ -87,6 +88,9 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf %changelog +* Fri Dec 2 2022 huajingyun - 2.23-3 +- add loongarch support + * Fri Oct 21 2022 wuzx - 2.23-2 - add sw64 patch -- Gitee