This patch adds support for libhugetlbfs linking on s390 for binutils >= 2.17
with the --hugetlbfs-align option. No custom linker scripts are provided, so
CUSTOM_LDSCRIPTS is set to "no" and the deprecated --hugetlbfs-link option is
not supported on s390.

Signed-off-by: Gerald Schaefer <gerald.schae...@de.ibm.com>
---
 HOWTO            |  7 ++++---
 Makefile         |  4 +++-
 ld.hugetlbfs     |  1 +
 sys-elf64_s390.S | 22 ++++++++++++++++++++++
 sys-elf_s390.S   | 22 ++++++++++++++++++++++
 5 files changed, 52 insertions(+), 4 deletions(-)
 create mode 100644 sys-elf64_s390.S
 create mode 100644 sys-elf_s390.S

diff --git a/HOWTO b/HOWTO
index 8db958d..21eb34e 100644
--- a/HOWTO
+++ b/HOWTO
@@ -43,13 +43,14 @@ Hardware prerequisites
 ----------------------
 
 You will need a CPU with some sort of hugepage support, which is
-handled by your kernel.  The covers recent x86, AMD64 and 64-bit
-PowerPC(R) (POWER4, PPC970 and later) CPUs.
+handled by your kernel.  This covers recent x86, AMD64, 64-bit
+PowerPC(R) (POWER4, PPC970 and later), and IBM System z CPUs.
 
 Currently, only x86, AMD64 and PowerPC are fully supported by
 libhugetlbfs. IA64 and Sparc64 have a working malloc, and SH64
 should also but it has not been tested. IA64, Sparc64, and SH64
-do not support segment remapping at this time.
+do not support segment remapping at this time. IBM System z supports
+malloc and also segment remapping with --hugetlbfs-align.
 
 Kernel prerequisites
 --------------------
diff --git a/Makefile b/Makefile
index 3ec3c15..796b063 100644
--- a/Makefile
+++ b/Makefile
@@ -79,9 +79,11 @@ else
 ifeq ($(ARCH),s390x)
 CC64 = gcc -m64
 CC32 = gcc -m31
+ELF32 = elf_s390
+ELF64 = elf64_s390
 TMPLIB64 = lib64
 TMPLIB32 = lib
-CFLAGS += -DNO_ELFLINK
+CUSTOM_LDSCRIPTS = no
 else
 $(error "Unrecognized architecture ($(ARCH))")
 endif
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index aa25242..199bf97 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -85,6 +85,7 @@ MB=$((1024*1024))
 case "$EMU" in
 elf32ppclinux|elf64ppc)        HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) 
;;
 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 ;;
 esac
 
 if [ "$HTLB_ALIGN" == "slice" ]; then
diff --git a/sys-elf64_s390.S b/sys-elf64_s390.S
new file mode 100644
index 0000000..425a387
--- /dev/null
+++ b/sys-elf64_s390.S
@@ -0,0 +1,22 @@
+/*
+ * libhugetlbfs - direct system call for s390 (64 bit)
+ *
+ * Copyright IBM Corp. 2012
+ * Author(s): Gerald Schaefer <gerald.schae...@de.ibm.com>
+ *
+ * NOTE: Only 4 syscall parameters supported w/o stack access, but this is
+ *       sufficient for the syscalls used so far (__NR_write, __NR_kill and
+ *       __NR_getpid).
+ */
+
+       .text
+
+       .globl  direct_syscall
+direct_syscall:
+       lgr     %r1,%r2
+       lgr     %r2,%r3
+       lgr     %r3,%r4
+       lgr     %r4,%r5
+       lgr     %r5,%r6
+       svc     0
+       br      %r14
diff --git a/sys-elf_s390.S b/sys-elf_s390.S
new file mode 100644
index 0000000..40630d1
--- /dev/null
+++ b/sys-elf_s390.S
@@ -0,0 +1,22 @@
+/*
+ * libhugetlbfs - direct system call for s390 (31 bit)
+ *
+ * Copyright IBM Corp. 2012
+ * Author(s): Gerald Schaefer <gerald.schae...@de.ibm.com>
+ *
+ * NOTE: Only 4 syscall parameters supported w/o stack access, but this is
+ *       sufficient for the syscalls used so far (__NR_write, __NR_kill and
+ *       __NR_getpid).
+ */
+
+       .text
+
+       .globl  direct_syscall
+direct_syscall:
+       lr      %r1,%r2
+       lr      %r2,%r3
+       lr      %r3,%r4
+       lr      %r4,%r5
+       lr      %r5,%r6
+       svc     0
+       br      %r14
-- 
1.7.12.4


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to