diff --git a/libhugetlbfs-riscv64-support.patch b/libhugetlbfs-riscv64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce9351d2685aa90c5ea510fd688df434a98ded6c --- /dev/null +++ b/libhugetlbfs-riscv64-support.patch @@ -0,0 +1,98 @@ +From a529598dd256c79799d5e43e6d79146ca15f1c16 Mon Sep 17 00:00:00 2001 +From: Alexandre Ghiti +Date: Mon, 9 Mar 2020 01:39:36 -0400 +Subject: [PATCH] Introduce basic riscv64 support + +This simply adds syscall assembly routine, icache-hygiene behaviour and +the building of the library for riscv64. +It passes most of the tests, the 12 below fails being from linkhuge* +tests that require custom linker script not present in this patch: + +********** TEST SUMMARY +* 2M +* 32-bit 64-bit +* Total testcases: 0 93 +* Skipped: 0 0 +* PASS: 0 68 +* FAIL: 0 12 +* Killed by signal: 0 1 +* Bad configuration: 0 1 +* Expected FAIL: 0 0 +* Unexpected PASS: 0 0 +* Test not present: 0 11 +* Strange test result: 0 0 +********** + +Signed-off-by: Alexandre Ghiti +Signed-off-by: Eric B Munson +--- + Makefile | 7 +++++++ + sys-elf_riscv64.S | 20 ++++++++++++++++++++ + tests/icache-hygiene.c | 2 +- + 3 files changed, 28 insertions(+), 1 deletion(-) + create mode 100644 sys-elf_riscv64.S + +diff --git a/Makefile b/Makefile +index a107a62..4b562d9 100644 +--- a/Makefile ++++ b/Makefile +@@ -111,6 +111,12 @@ ELF32 = elf_s390 + TMPLIB32 = lib + CUSTOM_LDSCRIPTS = no + else ++ifeq ($(ARCH),riscv64) ++CC64 = $(CC) ++ELF64 = elf_riscv64 ++TMPLIB64 = lib64 ++CUSTOM_LDSCRIPTS = no ++else + $(error "Unrecognized architecture ($(ARCH))") + endif + endif +@@ -123,6 +129,7 @@ endif + endif + endif + endif ++endif + + ifdef CC32 + OBJDIRS += obj32 +diff --git a/sys-elf_riscv64.S b/sys-elf_riscv64.S +new file mode 100644 +index 0000000..ec4adc2 +--- /dev/null ++++ b/sys-elf_riscv64.S +@@ -0,0 +1,20 @@ ++/* ++ * libhugetlbfs - direct system call for riscv64 ++ * ++ * Author(s): Alexandre Ghiti ++ */ ++ .text ++ ++ .globl direct_syscall ++direct_syscall: ++ mv a7, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, a4 ++ ecall ++ 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 caacab0..394d900 100644 +--- a/tests/icache-hygiene.c ++++ b/tests/icache-hygiene.c +@@ -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(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) + /* 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 4e49f7b95eaa810fab80a8ca4754228f0a3eaa0a..9e72477eb7b93afaae63b8bb5e69249028538909 100644 --- a/libhugetlbfs.spec +++ b/libhugetlbfs.spec @@ -2,7 +2,7 @@ Name: libhugetlbfs Version: 2.22 -Release: 1 +Release: 2 Summary: A library which provides easy access to huge pages of memory License: LGPLv2+ URL: https://github.com/libhugetlbfs/libhugetlbfs @@ -13,6 +13,7 @@ Patch0000: 0000-build_flags.patch Patch9000:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED.patch Patch9001:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED-2.patch Patch9002:libhugetlbfs-make-cflags.patch +Patch9003:libhugetlbfs-riscv64-support.patch BuildRequires: gcc glibc-devel glibc-static @@ -84,6 +85,12 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf %changelog +* Fri Oct 31 2020 dengguangxing - 2.22-2 +- Type:enhancement +- ID:NA +- SUG:restart +- DESC:add riscv64 platform support + * Fri Apr 24 2020 lihongjiang - 2.22-1 - Type:enhancement - ID:NA