aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/vdso64
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2008-12-25 07:38:36 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-12-25 07:38:55 -0500
commitb020632e40c3ed5e8c0c066d022672907e8401cf (patch)
treed7f805bd27e8378436fbba7e7457afbd10c22ed8 /arch/s390/kernel/vdso64
parentfc5243d98ac2575ad14a974b3c097e9ba874c03d (diff)
[S390] introduce vdso on s390
Add a vdso to speed up gettimeofday and clock_getres/clock_gettime for CLOCK_REALTIME/CLOCK_MONOTONIC. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/vdso64')
-rw-r--r--arch/s390/kernel/vdso64/Makefile55
-rw-r--r--arch/s390/kernel/vdso64/clock_getres.S39
-rw-r--r--arch/s390/kernel/vdso64/clock_gettime.S89
-rw-r--r--arch/s390/kernel/vdso64/gettimeofday.S56
-rw-r--r--arch/s390/kernel/vdso64/note.S12
-rw-r--r--arch/s390/kernel/vdso64/vdso64.lds.S138
-rw-r--r--arch/s390/kernel/vdso64/vdso64_wrapper.S13
7 files changed, 402 insertions, 0 deletions
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
new file mode 100644
index 000000000000..6fc8e829258c
--- /dev/null
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -0,0 +1,55 @@
1# List of files in the vdso, has to be asm only for now
2
3obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o
4
5# Build rules
6
7targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
8obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
9
10KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
11KBUILD_AFLAGS_64 += -m64 -s
12
13KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
14KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin
15KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
16 $(call ld-option, -Wl$(comma)--hash-style=sysv)
17
18$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
19$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
20
21obj-y += vdso64_wrapper.o
22extra-y += vdso64.lds
23CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
24
25# Force dependency (incbin is bad)
26$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
27
28# link rule for the .so file, .lds has to be first
29$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64)
30 $(call if_changed,vdso64ld)
31
32# strip rule for the .so file
33$(obj)/%.so: OBJCOPYFLAGS := -S
34$(obj)/%.so: $(obj)/%.so.dbg FORCE
35 $(call if_changed,objcopy)
36
37# assembly rules for the .S files
38$(obj-vdso64): %.o: %.S
39 $(call if_changed_dep,vdso64as)
40
41# actual build commands
42quiet_cmd_vdso64ld = VDSO64L $@
43 cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
44quiet_cmd_vdso64as = VDSO64A $@
45 cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
46
47# install commands for the unstripped file
48quiet_cmd_vdso_install = INSTALL $@
49 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
50
51vdso64.so: $(obj)/vdso64.so.dbg
52 @mkdir -p $(MODLIB)/vdso
53 $(call cmd,vdso_install)
54
55vdso_install: vdso64.so
diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S
new file mode 100644
index 000000000000..488e31a3c0e7
--- /dev/null
+++ b/arch/s390/kernel/vdso64/clock_getres.S
@@ -0,0 +1,39 @@
1/*
2 * Userland implementation of clock_getres() for 64 bits processes in a
3 * s390 kernel for use in the vDSO
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#include <asm/vdso.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15
16 .text
17 .align 4
18 .globl __kernel_clock_getres
19 .type __kernel_clock_getres,@function
20__kernel_clock_getres:
21 .cfi_startproc
22 cghi %r2,CLOCK_REALTIME
23 je 0f
24 cghi %r2,CLOCK_MONOTONIC
25 jne 2f
260: ltgr %r3,%r3
27 jz 1f /* res == NULL */
28 larl %r1,3f
29 lg %r0,0(%r1)
30 xc 0(8,%r3),0(%r3) /* set tp->tv_sec to zero */
31 stg %r0,8(%r3) /* store tp->tv_usec */
321: lghi %r2,0
33 br %r14
342: lghi %r1,__NR_clock_getres /* fallback to svc */
35 svc 0
36 br %r14
373: .quad CLOCK_REALTIME_RES
38 .cfi_endproc
39 .size __kernel_clock_getres,.-__kernel_clock_getres
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
new file mode 100644
index 000000000000..738a410b7eb2
--- /dev/null
+++ b/arch/s390/kernel/vdso64/clock_gettime.S
@@ -0,0 +1,89 @@
1/*
2 * Userland implementation of clock_gettime() for 64 bits processes in a
3 * s390 kernel for use in the vDSO
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#include <asm/vdso.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15
16 .text
17 .align 4
18 .globl __kernel_clock_gettime
19 .type __kernel_clock_gettime,@function
20__kernel_clock_gettime:
21 .cfi_startproc
22 larl %r5,_vdso_data
23 cghi %r2,CLOCK_REALTIME
24 je 4f
25 cghi %r2,CLOCK_MONOTONIC
26 jne 9f
27
28 /* CLOCK_MONOTONIC */
29 ltgr %r3,%r3
30 jz 3f /* tp == NULL */
310: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
32 tmll %r4,0x0001 /* pending update ? loop */
33 jnz 0b
34 stck 48(%r15) /* Store TOD clock */
35 lg %r1,48(%r15)
36 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
37 mghi %r1,1000
38 srlg %r1,%r1,12 /* cyc2ns(clock,cycle_delta) */
39 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + xtime */
40 lg %r0,__VDSO_XTIME_SEC(%r5)
41 alg %r1,__VDSO_WTOM_NSEC(%r5) /* + wall_to_monotonic */
42 alg %r0,__VDSO_WTOM_SEC(%r5)
43 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
44 jne 0b
45 larl %r5,10f
461: clg %r1,0(%r5)
47 jl 2f
48 slg %r1,0(%r5)
49 aghi %r0,1
50 j 1b
512: stg %r0,0(%r3) /* store tp->tv_sec */
52 stg %r1,8(%r3) /* store tp->tv_nsec */
533: lghi %r2,0
54 br %r14
55
56 /* CLOCK_REALTIME */
574: ltr %r3,%r3 /* tp == NULL */
58 jz 8f
595: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
60 tmll %r4,0x0001 /* pending update ? loop */
61 jnz 5b
62 stck 48(%r15) /* Store TOD clock */
63 lg %r1,48(%r15)
64 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
65 mghi %r1,1000
66 srlg %r1,%r1,12 /* cyc2ns(clock,cycle_delta) */
67 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + xtime */
68 lg %r0,__VDSO_XTIME_SEC(%r5)
69 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
70 jne 5b
71 larl %r5,10f
726: clg %r1,0(%r5)
73 jl 7f
74 slg %r1,0(%r5)
75 aghi %r0,1
76 j 6b
777: stg %r0,0(%r3) /* store tp->tv_sec */
78 stg %r1,8(%r3) /* store tp->tv_nsec */
798: lghi %r2,0
80 br %r14
81
82 /* Fallback to system call */
839: lghi %r1,__NR_clock_gettime
84 svc 0
85 br %r14
86
8710: .quad 1000000000
88 .cfi_endproc
89 .size __kernel_clock_gettime,.-__kernel_clock_gettime
diff --git a/arch/s390/kernel/vdso64/gettimeofday.S b/arch/s390/kernel/vdso64/gettimeofday.S
new file mode 100644
index 000000000000..f873e75634e1
--- /dev/null
+++ b/arch/s390/kernel/vdso64/gettimeofday.S
@@ -0,0 +1,56 @@
1/*
2 * Userland implementation of gettimeofday() for 64 bits processes in a
3 * s390 kernel for use in the vDSO
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#include <asm/vdso.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15
16 .text
17 .align 4
18 .globl __kernel_gettimeofday
19 .type __kernel_gettimeofday,@function
20__kernel_gettimeofday:
21 .cfi_startproc
22 larl %r5,_vdso_data
230: ltgr %r3,%r3 /* check if tz is NULL */
24 je 1f
25 mvc 0(8,%r3),__VDSO_TIMEZONE(%r5)
261: ltgr %r2,%r2 /* check if tv is NULL */
27 je 4f
28 lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
29 tmll %r4,0x0001 /* pending update ? loop */
30 jnz 0b
31 stck 48(%r15) /* Store TOD clock */
32 lg %r1,48(%r15)
33 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
34 mghi %r1,1000
35 srlg %r1,%r1,12 /* cyc2ns(clock,cycle_delta) */
36 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + xtime.tv_nsec */
37 lg %r0,__VDSO_XTIME_SEC(%r5) /* xtime.tv_sec */
38 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
39 jne 0b
40 larl %r5,5f
412: clg %r1,0(%r5)
42 jl 3f
43 slg %r1,0(%r5)
44 aghi %r0,1
45 j 2b
463: stg %r0,0(%r2) /* store tv->tv_sec */
47 slgr %r0,%r0 /* tv_nsec -> tv_usec */
48 ml %r0,8(%r5)
49 srlg %r0,%r0,6
50 stg %r0,8(%r2) /* store tv->tv_usec */
514: lghi %r2,0
52 br %r14
535: .quad 1000000000
54 .long 274877907
55 .cfi_endproc
56 .size __kernel_gettimeofday,.-__kernel_gettimeofday
diff --git a/arch/s390/kernel/vdso64/note.S b/arch/s390/kernel/vdso64/note.S
new file mode 100644
index 000000000000..79a071e4357e
--- /dev/null
+++ b/arch/s390/kernel/vdso64/note.S
@@ -0,0 +1,12 @@
1/*
2 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
3 * Here we can supply some information useful to userland.
4 */
5
6#include <linux/uts.h>
7#include <linux/version.h>
8#include <linux/elfnote.h>
9
10ELFNOTE_START(Linux, 0, "a")
11 .long LINUX_VERSION_CODE
12ELFNOTE_END
diff --git a/arch/s390/kernel/vdso64/vdso64.lds.S b/arch/s390/kernel/vdso64/vdso64.lds.S
new file mode 100644
index 000000000000..9f5979d102a9
--- /dev/null
+++ b/arch/s390/kernel/vdso64/vdso64.lds.S
@@ -0,0 +1,138 @@
1/*
2 * This is the infamous ld script for the 64 bits vdso
3 * library
4 */
5#include <asm/vdso.h>
6
7OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
8OUTPUT_ARCH(s390:64-bit)
9ENTRY(_start)
10
11SECTIONS
12{
13 . = VDSO64_LBASE + SIZEOF_HEADERS;
14
15 .hash : { *(.hash) } :text
16 .gnu.hash : { *(.gnu.hash) }
17 .dynsym : { *(.dynsym) }
18 .dynstr : { *(.dynstr) }
19 .gnu.version : { *(.gnu.version) }
20 .gnu.version_d : { *(.gnu.version_d) }
21 .gnu.version_r : { *(.gnu.version_r) }
22
23 .note : { *(.note.*) } :text :note
24
25 . = ALIGN(16);
26 .text : {
27 *(.text .stub .text.* .gnu.linkonce.t.*)
28 } :text
29 PROVIDE(__etext = .);
30 PROVIDE(_etext = .);
31 PROVIDE(etext = .);
32
33 /*
34 * Other stuff is appended to the text segment:
35 */
36 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
37 .rodata1 : { *(.rodata1) }
38
39 .dynamic : { *(.dynamic) } :text :dynamic
40
41 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
42 .eh_frame : { KEEP (*(.eh_frame)) } :text
43 .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
44
45 .rela.dyn ALIGN(8) : { *(.rela.dyn) }
46 .got ALIGN(8) : { *(.got .toc) }
47
48 _end = .;
49 PROVIDE(end = .);
50
51 /*
52 * Stabs debugging sections are here too.
53 */
54 .stab 0 : { *(.stab) }
55 .stabstr 0 : { *(.stabstr) }
56 .stab.excl 0 : { *(.stab.excl) }
57 .stab.exclstr 0 : { *(.stab.exclstr) }
58 .stab.index 0 : { *(.stab.index) }
59 .stab.indexstr 0 : { *(.stab.indexstr) }
60 .comment 0 : { *(.comment) }
61
62 /*
63 * DWARF debug sections.
64 * Symbols in the DWARF debugging sections are relative to the
65 * beginning of the section so we begin them at 0.
66 */
67 /* DWARF 1 */
68 .debug 0 : { *(.debug) }
69 .line 0 : { *(.line) }
70 /* GNU DWARF 1 extensions */
71 .debug_srcinfo 0 : { *(.debug_srcinfo) }
72 .debug_sfnames 0 : { *(.debug_sfnames) }
73 /* DWARF 1.1 and DWARF 2 */
74 .debug_aranges 0 : { *(.debug_aranges) }
75 .debug_pubnames 0 : { *(.debug_pubnames) }
76 /* DWARF 2 */
77 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
78 .debug_abbrev 0 : { *(.debug_abbrev) }
79 .debug_line 0 : { *(.debug_line) }
80 .debug_frame 0 : { *(.debug_frame) }
81 .debug_str 0 : { *(.debug_str) }
82 .debug_loc 0 : { *(.debug_loc) }
83 .debug_macinfo 0 : { *(.debug_macinfo) }
84 /* SGI/MIPS DWARF 2 extensions */
85 .debug_weaknames 0 : { *(.debug_weaknames) }
86 .debug_funcnames 0 : { *(.debug_funcnames) }
87 .debug_typenames 0 : { *(.debug_typenames) }
88 .debug_varnames 0 : { *(.debug_varnames) }
89 /* DWARF 3 */
90 .debug_pubtypes 0 : { *(.debug_pubtypes) }
91 .debug_ranges 0 : { *(.debug_ranges) }
92 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
93
94 . = ALIGN(4096);
95 PROVIDE(_vdso_data = .);
96
97 /DISCARD/ : {
98 *(.note.GNU-stack)
99 *(.branch_lt)
100 *(.data .data.* .gnu.linkonce.d.* .sdata*)
101 *(.bss .sbss .dynbss .dynsbss)
102 }
103}
104
105/*
106 * Very old versions of ld do not recognize this name token; use the constant.
107 */
108#define PT_GNU_EH_FRAME 0x6474e550
109
110/*
111 * We must supply the ELF program headers explicitly to get just one
112 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
113 */
114PHDRS
115{
116 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
117 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
118 note PT_NOTE FLAGS(4); /* PF_R */
119 eh_frame_hdr PT_GNU_EH_FRAME;
120}
121
122/*
123 * This controls what symbols we export from the DSO.
124 */
125VERSION
126{
127 VDSO_VERSION_STRING {
128 global:
129 /*
130 * Has to be there for the kernel to find
131 */
132 __kernel_gettimeofday;
133 __kernel_clock_gettime;
134 __kernel_clock_getres;
135
136 local: *;
137 };
138}
diff --git a/arch/s390/kernel/vdso64/vdso64_wrapper.S b/arch/s390/kernel/vdso64/vdso64_wrapper.S
new file mode 100644
index 000000000000..d8e2ac14d564
--- /dev/null
+++ b/arch/s390/kernel/vdso64/vdso64_wrapper.S
@@ -0,0 +1,13 @@
1#include <linux/init.h>
2#include <asm/page.h>
3
4 .section ".data.page_aligned"
5
6 .globl vdso64_start, vdso64_end
7 .balign PAGE_SIZE
8vdso64_start:
9 .incbin "arch/s390/kernel/vdso64/vdso64.so"
10 .balign PAGE_SIZE
11vdso64_end:
12
13 .previous