[PATCH] Introduce basic riscv64 support

6 views
Skip to first unread message

Alexandre Ghiti

unread,
Mar 9, 2020, 1:39:42 AM3/9/20
to libhugetlbfs @ googlegroups . com, Alexandre Ghiti
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 <al...@ghiti.fr>
---
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 */
--
2.20.1

Eric B Munson

unread,
Mar 9, 2020, 10:35:04 AM3/9/20
to Alexandre Ghiti, libhugetlbfs @ googlegroups . com
On Mon, 09 Mar 2020, Alexandre Ghiti wrote:

> 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 <al...@ghiti.fr>

Applied, thanks

Eric
Reply all
Reply to author
Forward
0 new messages