add loongarch support

Signed-off-by: Jingyun Hua <huajingyun@loongson.cn>
This commit is contained in:
Jingyun Hua 2022-12-02 06:52:19 +00:00
parent 15cdcd3453
commit 4b2f1f5aaf
2 changed files with 70 additions and 1 deletions

View File

@ -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 */

View File

@ -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<huajingyun@loongson.cn> - 2.23-3
- add loongarch support
* Fri Oct 21 2022 wuzx<wuzx1226@qq.com> - 2.23-2
- add sw64 patch