What the patch is:
As we all known that libhugetlbfs only supports ppc, s390, sparc, ia64, x86
and x86_64 architecture. This patch make libhugetlbfs avaliable to MIPS
architecture.
What it does:
This patch adds hugepage support to .bss .data .text and .heap segment in
MIPS architecture, fully supports commands like LD_PRELOAD=libhugetlbfs.so
HUGETLB_MORECORE=yes HUGETLB_ELFMAP=RW.
What I did:
1. Fix the test scripts so that it won't attempt to test the old style
linker script based mapping system on MIPS.
2. Update linking script for MIPS platform, including adding arch
support and comment out old style linker script installation
3. Add native syscall function, which is ported from glibc
Known issue:
I test it in a Loongson3A mips platform. here is the uname -a output:
root@10:/home/yuhuang# uname -a
Linux 10.10.1.10 2.6.27.6 SMP Fri Nov 26 11:14:45 CST 2010 mips64 GNU/Linux
Using gcc --verbose I got:
COLLECT_GCC_OPTIONS='-v' '-D__LIBHUGETLBFS__' '-O2' '-g' '-Wall' '-fPIC'
'-o' 'obj64/shm.o' '-c' '-mllsc' '-EL' '-mabi=32'
This indicates that by default abi=32. **********When abi=64 the
compiling result may differ. I am not sure to this**********.
I ever tried to use gcc -mabi=32 and gcc -mabi=64 but got compiling
error. If anyone have any new MIPS compiling enviroment, welcome to
submit the patch if any problem found.
------------------------------patch begin-------------------------------
Make libhugetlbfs avaliable to MIPS architecture.
Signed-off-by: Huang Yu <yuhu...@ncic.ac.cn <mailto:guo...@nrchpc.ac.cn>>
---
diff -ruN libhugetlbfs-2.12-x86/Makefile libhugetlbfs-2.12-mips/Makefile
--- libhugetlbfs-2.12-x86/Makefile 2011-04-02 04:39:44.000000000 +0800
+++ libhugetlbfs-2.12-mips/Makefile 2011-06-24 01:23:32.000000000 +0800
@@ -17,7 +17,7 @@
INSTALL_MAN7 = libhugetlbfs.7
INSTALL_MAN8 = hugectl.8 hugeedit.8 hugeadm.8 cpupcstat.8
LDSCRIPT_TYPES = B BDT
-LDSCRIPT_DIST_ELF = elf32ppclinux elf64ppc elf_i386 elf_x86_64
+LDSCRIPT_DIST_ELF = elf32ppclinux elf64ppc elf_i386 elf_x86_64 elf32ltsmip
INSTALL_OBJSCRIPT = ld.hugetlbfs
VERSION=version.h
SOURCE = $(shell find . -maxdepth 1 ! -name version.h -a -name '*.[h]')
@@ -80,6 +80,14 @@
TMPLIB32 = lib
CFLAGS += -DNO_ELFLINK
else
+ifeq ($(ARCH),mips64)
+CC64 = gcc
+CC32 = gcc
+TMPLIB64 = lib64
+TMPLIB32 = lib
+ELF64= elf64ltsmip
+ELF32= elf32ltsmip
+else
$(error "Unrecognized architecture ($(ARCH))")
endif
endif
@@ -88,6 +96,7 @@
endif
endif
endif
+endif
ifdef CC32
OBJDIRS += obj32
@@ -371,7 +380,9 @@
$(INSTALL) -d $(DESTDIR)$(LDSCRIPTDIR)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 644 -t $(DESTDIR)$(HEADERDIR) $(INSTALL_HEADERS)
+ifneq ($(ARCH),mips64)
$(INSTALL) -m 644 $(INSTALL_LDSCRIPTS:%=ldscripts/%)
$(DESTDIR)$(LDSCRIPTDIR)
+endif
for x in $(INSTALL_OBJSCRIPT); do \
$(INSTALL) -m 755 objscript.$$x $(DESTDIR)$(BINDIR)/$$x; done
cd $(DESTDIR)$(BINDIR) && ln -sf ld.hugetlbfs ld
diff -ruN libhugetlbfs-2.12-x86/ld.hugetlbfs
libhugetlbfs-2.12-mips/ld.hugetlbfs
--- libhugetlbfs-2.12-x86/ld.hugetlbfs 2011-04-02 04:39:44.000000000 +0800
+++ libhugetlbfs-2.12-mips/ld.hugetlbfs 2011-06-23 22:02:27.000000000 +0800
@@ -73,6 +73,7 @@
MB=$((1024*1024))
case "$EMU" in
elf32ppclinux|elf64ppc) HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
+elf32ltsmip|elf64ltsmip) HPAGE_SIZE=$((32*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
esac
diff -ruN libhugetlbfs-2.12-x86/sys-elf32ltsmip.S
libhugetlbfs-2.12-mips/sys-elf32ltsmip.S
--- libhugetlbfs-2.12-x86/sys-elf32ltsmip.S 1970-01-01
08:00:00.000000000 +0800
+++ libhugetlbfs-2.12-mips/sys-elf32ltsmip.S 2011-06-10
08:36:59.000000000 +0800
@@ -0,0 +1,72 @@
+/*
+.text
+.globl direct_syscall
+direct_syscall:
+syscall
+j $ra
+*/
+
+/* code port from
+ * glibc-2.1.3.tar.gz/glibc-2.1.3/sysdeps/mach/mips/syscall.S
+ */
+
+
+#define zero $0 /* wired zero */
+#define AT $1 /* assembler temp - uppercase because of ".set at"
+ */
+#define v0 $2 /* return value */
+#define v1 $3
+#define a0 $4 /* argument registers */
+#define a1 $5
+#define a2 $6
+#define a3 $7
+#define t0 $8 /* caller saved */
+#define t1 $9
+#define t2 $10
+#define t3 $11
+#define t4 $12
+#define t5 $13
+#define t6 $14
+#define t7 $15
+#define s0 $16 /* callee saved */
+#define s1 $17
+#define s2 $18
+#define s3 $19
+#define s4 $20
+#define s5 $21
+#define s6 $22
+#define s7 $23
+#define t8 $24 /* caller saved */
+#define t9 $25
+#define jp $25 /* PIC jump register */
+#define k0 $26 /* kernel scratch */
+#define k1 $27
+#define gp $28 /* global pointer */
+#define sp $29 /* stack pointer */
+#define fp $30 /* frame pointer */
+#define s8 $30 /* same like fp! */
+#define ra $31 /* return address
+ */
+
+
+.text
+.globl direct_syscall
+
+direct_syscall:
+move v0, a0 /* Load system call number from first arg. */
+move a0, a1 /* Move the next three args up a register. */
+move a1, a2
+move a2, a3
+
+/* Load the remaining possible args (up to 11) from the stack. */
+
+ld t0,4*8(sp)
+ld t1,5*8(sp)
+ld t2,6*8(sp)
+ld t3,7*8(sp)
+ld t4,8*8(sp)
+ld t5,9*8(sp)
+ld t6,10*8(sp)
+syscall /* Do the system call. */
+j ra /* Return to caller. */
+
diff -ruN libhugetlbfs-2.12-x86/sys-elf64ltsmip.S
libhugetlbfs-2.12-mips/sys-elf64ltsmip.S
--- libhugetlbfs-2.12-x86/sys-elf64ltsmip.S 1970-01-01
08:00:00.000000000 +0800
+++ libhugetlbfs-2.12-mips/sys-elf64ltsmip.S 2011-06-10
08:37:16.000000000 +0800
@@ -0,0 +1,5 @@
+.text
+.globl direct_syscall
+direct_syscall:
+ syscall
+ j $ra
diff -ruN libhugetlbfs-2.12-x86/tests/Makefile
libhugetlbfs-2.12-mips/tests/Makefile
--- libhugetlbfs-2.12-x86/tests/Makefile 2011-04-02 04:39:44.000000000 +0800
+++ libhugetlbfs-2.12-mips/tests/Makefile 2011-06-24 10:57:03.000000000
+0800
@@ -17,8 +17,14 @@
huge_below_4GB_normal_above
NOLIB_TESTS = malloc malloc_manysmall dummy heapshrink shmoverride_unlinked
LDSCRIPT_TESTS = zero_filesize_segment
+
+ifeq ($(ARCH),mips64)
+HUGELINK_TESTS =
+HUGELINK_RW_TESTS = linkhuge_rw
+else
HUGELINK_TESTS = linkhuge linkhuge_nofd linkshare
HUGELINK_RW_TESTS = linkhuge_rw
+endif
STRESS_TESTS = mmap-gettest mmap-cow shm-gettest shm-getraw shm-fork
# NOTE: all named tests in WRAPPERS must also be named in TESTS
WRAPPERS = quota counters madvise_reserve fadvise_reserve \
diff -ruN libhugetlbfs-2.12-x86/tests/icache-hygiene.c
libhugetlbfs-2.12-mips/tests/icache-hygiene.c
--- libhugetlbfs-2.12-x86/tests/icache-hygiene.c 2011-04-02
04:39:44.000000000 +0800
+++ libhugetlbfs-2.12-mips/tests/icache-hygiene.c 2011-06-23
18:00:45.000000000 +0800
@@ -85,7 +85,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(__s390__) || defined(__s390x__) || defined(__sparc__) ||
defined(__mips__)
/* On powerpc and ia64 and s390, 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.12
------------------------------patch end-------------------------------
at 2011/6/7 21:19, Eric B Munson wrote:
> On Sun, 05 Jun 2011, Yu Huang wrote:
>
>> at 2011/6/4 15:22, David Gibson wrote:
>>> Uh, you need the -u option to diff. Plain-style diffs are more or
>>> less unusable as patches.
>>>
>> Thanks you! Here is a new patch with -u option:
> We need a few more things before we can accept this patch:
>
> 1. A patch leader explaining what the patch is, what it does, and explaining
> anything your did that might be considered odd.
>
> 2. A Signed-off-by: With your name and email. This states that you are the
> original author of this code and you are authorizing the libhugetlbfs
> project to redistribute your code under the terms of the license we use
> (in this case it is the LGPL 2.1)
>
> Thanks,
> Eric
>
>>
>> diff -ruN libhugetlbfs-2.12-x86/ld.hugetlbfs
>> libhugetlbfs-2.12-mips/ld.hugetlbfs
>> --- libhugetlbfs-2.12-x86/ld.hugetlbfs 2011-04-02 04:39:44.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/ld.hugetlbfs 2011-06-10 06:55:26.000000000 +0800
>> @@ -73,6 +73,7 @@
>> MB=$((1024*1024))
>> case "$EMU" in
>> elf32ppclinux|elf64ppc) HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
>> +elf32ltmips|elf64ltmips) HPAGE_SIZE=$((32*$MB)) SLICE_SIZE=$((32*$MB));;
>> elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
>> esac
>>
>> diff -ruN libhugetlbfs-2.12-x86/ldscripts/elf32ltmips.xB
>> libhugetlbfs-2.12-mips/ldscripts/elf32ltmips.xB
>> --- libhugetlbfs-2.12-x86/ldscripts/elf32ltmips.xB 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/ldscripts/elf32ltmips.xB 2011-06-10
>> 06:30:12.000000000 +0800
>> @@ -0,0 +1 @@
>> +
>> diff -ruN libhugetlbfs-2.12-x86/ldscripts/elf32ltmips.xBDT
>> libhugetlbfs-2.12-mips/ldscripts/elf32ltmips.xBDT
>> --- libhugetlbfs-2.12-x86/ldscripts/elf32ltmips.xBDT 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/ldscripts/elf32ltmips.xBDT 2011-06-10
>> 06:30:42.000000000 +0800
>> @@ -0,0 +1 @@
>> +
>> diff -ruN libhugetlbfs-2.12-x86/ldscripts/elf64ltmips.xB
>> libhugetlbfs-2.12-mips/ldscripts/elf64ltmips.xB
>> --- libhugetlbfs-2.12-x86/ldscripts/elf64ltmips.xB 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/ldscripts/elf64ltmips.xB 2011-06-10
>> 06:30:26.000000000 +0800
>> @@ -0,0 +1 @@
>> +
>> diff -ruN libhugetlbfs-2.12-x86/ldscripts/elf64ltmips.xBDT
>> libhugetlbfs-2.12-mips/ldscripts/elf64ltmips.xBDT
>> --- libhugetlbfs-2.12-x86/ldscripts/elf64ltmips.xBDT 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/ldscripts/elf64ltmips.xBDT 2011-06-10
>> 06:30:37.000000000 +0800
>> @@ -0,0 +1 @@
>> +
>> diff -ruN libhugetlbfs-2.12-x86/Makefile libhugetlbfs-2.12-mips/Makefile
>> --- libhugetlbfs-2.12-x86/Makefile 2011-04-02 04:39:44.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/Makefile 2011-06-10 06:55:51.000000000 +0800
>> @@ -17,7 +17,7 @@
>> INSTALL_MAN7 = libhugetlbfs.7
>> INSTALL_MAN8 = hugectl.8 hugeedit.8 hugeadm.8 cpupcstat.8
>> LDSCRIPT_TYPES = B BDT
>> -LDSCRIPT_DIST_ELF = elf32ppclinux elf64ppc elf_i386 elf_x86_64
>> +LDSCRIPT_DIST_ELF = elf32ppclinux elf64ppc elf_i386 elf_x86_64 elf32ltmips
>> INSTALL_OBJSCRIPT = ld.hugetlbfs
>> VERSION=version.h
>> SOURCE = $(shell find . -maxdepth 1 ! -name version.h -a -name '*.[h]')
>> @@ -80,6 +80,13 @@
>> TMPLIB32 = lib
>> CFLAGS += -DNO_ELFLINK
>> else
>> +ifeq ($(ARCH),mips64)
>> +CC64 = gcc
>> +CC32 = gcc
>> +TMPLIB64 = lib64
>> +ELF32= elf32ltmips
>> +ELF64= elf64ltmips
>> +else
>> $(error "Unrecognized architecture ($(ARCH))")
>> endif
>> endif
>> @@ -88,6 +95,7 @@
>> endif
>> endif
>> endif
>> +endif
>>
>> ifdef CC32
>> OBJDIRS += obj32
>> @@ -187,7 +195,11 @@
>> export LIBDIR32
>> export LIBDIR64
>>
>> +ifeq ($(ARCH),mips64)
>> +all: libs tools
>> +else
>> all: libs tests tools
>> +endif
>>
>> .PHONY: tests libs
>>
>> diff -ruN libhugetlbfs-2.12-x86/sys-elf32ltmips.S
>> libhugetlbfs-2.12-mips/sys-elf32ltmips.S
>> --- libhugetlbfs-2.12-x86/sys-elf32ltmips.S 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/sys-elf32ltmips.S 2011-06-10
>> 08:36:59.000000000 +0800
>> @@ -0,0 +1,72 @@
>> +/*
>> +.text
>> +.globl direct_syscall
>> +direct_syscall:
>> +syscall
>> +j $ra
>> +*/
>> +
>> +/* code port from
>> + * glibc-2.1.3.tar.gz/glibc-2.1.3/sysdeps/mach/mips/syscall.S
>> + */
>> +
>> +
>> +#define zero $0 /* wired zero */
>> +#define AT $1 /* assembler temp - uppercase because of ".set at"
>> + */
>> +#define v0 $2 /* return value */
>> +#define v1 $3
>> +#define a0 $4 /* argument registers */
>> +#define a1 $5
>> +#define a2 $6
>> +#define a3 $7
>> +#define t0 $8 /* caller saved */
>> +#define t1 $9
>> +#define t2 $10
>> +#define t3 $11
>> +#define t4 $12
>> +#define t5 $13
>> +#define t6 $14
>> +#define t7 $15
>> +#define s0 $16 /* callee saved */
>> +#define s1 $17
>> +#define s2 $18
>> +#define s3 $19
>> +#define s4 $20
>> +#define s5 $21
>> +#define s6 $22
>> +#define s7 $23
>> +#define t8 $24 /* caller saved */
>> +#define t9 $25
>> +#define jp $25 /* PIC jump register */
>> +#define k0 $26 /* kernel scratch */
>> +#define k1 $27
>> +#define gp $28 /* global pointer */
>> +#define sp $29 /* stack pointer */
>> +#define fp $30 /* frame pointer */
>> +#define s8 $30 /* same like fp! */
>> +#define ra $31 /* return address
>> + */
>> +
>> +
>> +.text
>> +.globl direct_syscall
>> +
>> +direct_syscall:
>> +move v0, a0 /* Load system call number from first arg. */
>> +move a0, a1 /* Move the next three args up a register. */
>> +move a1, a2
>> +move a2, a3
>> +
>> +/* Load the remaining possible args (up to 11) from the stack. */
>> +
>> +ld t0,4*8(sp)
>> +ld t1,5*8(sp)
>> +ld t2,6*8(sp)
>> +ld t3,7*8(sp)
>> +ld t4,8*8(sp)
>> +ld t5,9*8(sp)
>> +ld t6,10*8(sp)
>> +syscall /* Do the system call. */
>> +j ra /* Return to caller. */
>> +
>> diff -ruN libhugetlbfs-2.12-x86/sys-elf64ltmips.S
>> libhugetlbfs-2.12-mips/sys-elf64ltmips.S
>> --- libhugetlbfs-2.12-x86/sys-elf64ltmips.S 1970-01-01
>> 08:00:00.000000000 +0800
>> +++ libhugetlbfs-2.12-mips/sys-elf64ltmips.S 2011-06-10
>> 08:37:16.000000000 +0800
>> @@ -0,0 +1,5 @@
>> +.text
>> +.globl direct_syscall
>> +direct_syscall:
>> + syscall
>> + j $ra
>>
>>
>> --
>>
>>
--
Huang Yu
Institute of Computing Technology of the Chinese Academy of Sciences,
Beijing, China
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel