1 Star 0 Fork 22

wangqiang/libhugetlbfs

forked from src-openEuler/libhugetlbfs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-add-support-sw64.patch 4.78 KB
一键复制 编辑 原始数据 按行查看 历史
Venland 提交于 2024-05-07 09:39 . upgrade to version 2.24
From 206ee484953757ce62dc6364cb70d16a59a6b45b Mon Sep 17 00:00:00 2001
From: liweigang <liweiganga@uniontech.com>
Date: Mon, 6 May 2024 09:38:25 +0000
Subject: [PATCH] add support sw64
---
Makefile.in | 7 ++++++
ld.hugetlbfs | 4 +--
sys-sw_64elf.S | 36 +++++++++++++++++++++++++++
tests/icache-hygiene.c | 4 +--
tests/mremap-expand-slice-collision.c | 2 +-
5 files changed, 48 insertions(+), 5 deletions(-)
create mode 100644 sys-sw_64elf.S
diff --git a/Makefile.in b/Makefile.in
index 65ae5a4..dfaeaca 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -67,6 +67,12 @@ TMPLIB32 = lib
ELF32 += armelf_linux_eabi
CUSTOM_LDSCRIPTS = no
else
+ifneq (,$(findstring sw_64,$(ARCH)))
+CC64 = $(CC)
+ELF64 = sw_64elf
+TMPLIB64 = lib
+CUSTOM_LDSCRIPTS = no
+else
ifneq (,$(findstring aarch64,$(ARCH)))
CC64 = $(CC)
ELF64 = aarch64elf
@@ -141,6 +147,7 @@ endif
endif
endif
endif
+endif
ifdef CC32
OBJDIRS += obj32
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index 5e4e497..d828f8b 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -117,7 +117,7 @@ elf64ppc|elf64lppc)
fi ;;
elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
elf_s390|elf64_s390) HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
-armelf*_linux_eabi|aarch64elf*|aarch64linux*)
+armelf*_linux_eabi|aarch64elf*|aarch64linux*|sw_64elf*|sw_64linux*)
hpage_kb=$(cat /proc/meminfo | grep Hugepagesize: | awk '{print $2}')
HPAGE_SIZE=$((hpage_kb * 1024))
SLICE_SIZE=$HPAGE_SIZE ;;
@@ -130,7 +130,7 @@ if [ "$HTLB_ALIGN" == "slice" ]; then
# targeting the ARM platform one needs to explicitly set the text segment offset
# otherwise it will be NULL.
case "$EMU" in
- armelf*_linux_eabi|aarch64elf*|aarch64linux*)
+ armelf*_linux_eabi|aarch64elf*|aarch64linux*|sw_64elf*|sw_64linux*)
printf -v TEXTADDR "%x" "$SLICE_SIZE"
HTLBOPTS="$HTLBOPTS -Ttext-segment=$TEXTADDR" ;;
elf_i386) HTLBOPTS="$HTLBOPTS -Ttext-segment=0x08000000" ;;
diff --git a/sys-sw_64elf.S b/sys-sw_64elf.S
new file mode 100644
index 0000000..78e0adf
--- /dev/null
+++ b/sys-sw_64elf.S
@@ -0,0 +1,36 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 2013 Linaro Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+ .text
+
+ .globl direct_syscall
+
+
+direct_syscall:
+ mov $16,$0
+ mov $17,$16
+ mov $18,$17
+ mov $19,$18
+ mov $20,$19
+ mov $21,$20
+ sys_call 0x83
+ ret
+
+#if defined(__linux__) && defined(__ELF__)
+ .section .note.GNU-stack,"",%progbits
+#endif
diff --git a/tests/icache-hygiene.c b/tests/icache-hygiene.c
index 6f0e417..2e872fe 100644
--- a/tests/icache-hygiene.c
+++ b/tests/icache-hygiene.c
@@ -54,7 +54,7 @@ static void cacheflush(void *p)
{
#if defined(__powerpc__)
asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
-#elif defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm__) || defined(__aarch64__) || defined(__sw_64__)
__clear_cache(p, p + COPY_SIZE);
#endif
}
@@ -88,7 +88,7 @@ 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(__riscv) && __riscv_xlen == 64 || __loongarch64)
+ defined(__aarch64__) || defined(__sw_64__) || (defined(__riscv) && __riscv_xlen == 64 || __loongarch64)
/* 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/tests/mremap-expand-slice-collision.c b/tests/mremap-expand-slice-collision.c
index 78c11f2..dc2133c 100644
--- a/tests/mremap-expand-slice-collision.c
+++ b/tests/mremap-expand-slice-collision.c
@@ -38,7 +38,7 @@ void init_slice_boundary(int fd)
unsigned long slice_size;
void *p, *heap;
int i, rc;
-#if defined(__LP64__) && !defined(__aarch64__)
+#if defined(__LP64__) && !defined(__aarch64__) && !defined(__sw_64__)
/* powerpc: 1TB slices starting at 1 TB */
slice_boundary = 0x10000000000;
slice_size = 0x10000000000;
--
2.45.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangqiang95/libhugetlbfs.git
git@gitee.com:wangqiang95/libhugetlbfs.git
wangqiang95
libhugetlbfs
libhugetlbfs
master

搜索帮助