aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/vdso
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/arm64/kernel/vdso
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'arch/arm64/kernel/vdso')
-rw-r--r--arch/arm64/kernel/vdso/Makefile63
-rwxr-xr-xarch/arm64/kernel/vdso/gen_vdso_offsets.sh15
-rw-r--r--arch/arm64/kernel/vdso/gettimeofday.S246
-rw-r--r--arch/arm64/kernel/vdso/note.S28
-rw-r--r--arch/arm64/kernel/vdso/sigreturn.S37
-rw-r--r--arch/arm64/kernel/vdso/vdso.S33
-rw-r--r--arch/arm64/kernel/vdso/vdso.lds.S100
7 files changed, 0 insertions, 522 deletions
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
deleted file mode 100644
index d8064af42e6..00000000000
--- a/arch/arm64/kernel/vdso/Makefile
+++ /dev/null
@@ -1,63 +0,0 @@
1#
2# Building a vDSO image for AArch64.
3#
4# Author: Will Deacon <will.deacon@arm.com>
5# Heavily based on the vDSO Makefiles for other archs.
6#
7
8obj-vdso := gettimeofday.o note.o sigreturn.o
9
10# Build rules
11targets := $(obj-vdso) vdso.so vdso.so.dbg
12obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
13
14ccflags-y := -shared -fno-common -fno-builtin
15ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \
16 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
17
18obj-y += vdso.o
19extra-y += vdso.lds vdso-offsets.h
20CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
21
22# Force dependency (incbin is bad)
23$(obj)/vdso.o : $(obj)/vdso.so
24
25# Link rule for the .so file, .lds has to be first
26$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
27 $(call if_changed,vdsold)
28
29# Strip rule for the .so file
30$(obj)/%.so: OBJCOPYFLAGS := -S
31$(obj)/%.so: $(obj)/%.so.dbg FORCE
32 $(call if_changed,objcopy)
33
34# Generate VDSO offsets using helper script
35gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
36quiet_cmd_vdsosym = VDSOSYM $@
37define cmd_vdsosym
38 $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \
39 cp $@ include/generated/
40endef
41
42$(obj)/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
43 $(call if_changed,vdsosym)
44
45# Assembly rules for the .S files
46$(obj-vdso): %.o: %.S
47 $(call if_changed_dep,vdsoas)
48
49# Actual build commands
50quiet_cmd_vdsold = VDSOL $@
51 cmd_vdsold = $(CC) $(c_flags) -Wl,-T $^ -o $@
52quiet_cmd_vdsoas = VDSOA $@
53 cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<
54
55# Install commands for the unstripped file
56quiet_cmd_vdso_install = INSTALL $@
57 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
58
59vdso.so: $(obj)/vdso.so.dbg
60 @mkdir -p $(MODLIB)/vdso
61 $(call cmd,vdso_install)
62
63vdso_install: vdso.so
diff --git a/arch/arm64/kernel/vdso/gen_vdso_offsets.sh b/arch/arm64/kernel/vdso/gen_vdso_offsets.sh
deleted file mode 100755
index 01924ff071a..00000000000
--- a/arch/arm64/kernel/vdso/gen_vdso_offsets.sh
+++ /dev/null
@@ -1,15 +0,0 @@
1#!/bin/sh
2
3#
4# Match symbols in the DSO that look like VDSO_*; produce a header file
5# of constant offsets into the shared object.
6#
7# Doing this inside the Makefile will break the $(filter-out) function,
8# causing Kbuild to rebuild the vdso-offsets header file every time.
9#
10# Author: Will Deacon <will.deacon@arm.com
11#
12
13LC_ALL=C
14sed -n -e 's/^00*/0/' -e \
15's/^\([0-9a-fA-F]*\) . VDSO_\([a-zA-Z0-9_]*\)$/\#define vdso_offset_\2\t0x\1/p'
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index 8bf658d974f..00000000000
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ /dev/null
@@ -1,246 +0,0 @@
1/*
2 * Userspace implementations of gettimeofday() and friends.
3 *
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Will Deacon <will.deacon@arm.com>
19 */
20
21#include <linux/linkage.h>
22#include <asm/asm-offsets.h>
23#include <asm/unistd.h>
24
25#define NSEC_PER_SEC_LO16 0xca00
26#define NSEC_PER_SEC_HI16 0x3b9a
27
28vdso_data .req x6
29use_syscall .req w7
30seqcnt .req w8
31
32 .macro seqcnt_acquire
339999: ldr seqcnt, [vdso_data, #VDSO_TB_SEQ_COUNT]
34 tbnz seqcnt, #0, 9999b
35 dmb ishld
36 ldr use_syscall, [vdso_data, #VDSO_USE_SYSCALL]
37 .endm
38
39 .macro seqcnt_read, cnt
40 dmb ishld
41 ldr \cnt, [vdso_data, #VDSO_TB_SEQ_COUNT]
42 .endm
43
44 .macro seqcnt_check, cnt, fail
45 cmp \cnt, seqcnt
46 b.ne \fail
47 .endm
48
49 .text
50
51/* int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); */
52ENTRY(__kernel_gettimeofday)
53 .cfi_startproc
54 mov x2, x30
55 .cfi_register x30, x2
56
57 /* Acquire the sequence counter and get the timespec. */
58 adr vdso_data, _vdso_data
591: seqcnt_acquire
60 cbnz use_syscall, 4f
61
62 /* If tv is NULL, skip to the timezone code. */
63 cbz x0, 2f
64 bl __do_get_tspec
65 seqcnt_check w9, 1b
66
67 /* Convert ns to us. */
68 mov x13, #1000
69 lsl x13, x13, x12
70 udiv x11, x11, x13
71 stp x10, x11, [x0, #TVAL_TV_SEC]
722:
73 /* If tz is NULL, return 0. */
74 cbz x1, 3f
75 ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST]
76 seqcnt_read w9
77 seqcnt_check w9, 1b
78 stp w4, w5, [x1, #TZ_MINWEST]
793:
80 mov x0, xzr
81 ret x2
824:
83 /* Syscall fallback. */
84 mov x8, #__NR_gettimeofday
85 svc #0
86 ret x2
87 .cfi_endproc
88ENDPROC(__kernel_gettimeofday)
89
90/* int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); */
91ENTRY(__kernel_clock_gettime)
92 .cfi_startproc
93 cmp w0, #CLOCK_REALTIME
94 ccmp w0, #CLOCK_MONOTONIC, #0x4, ne
95 b.ne 2f
96
97 mov x2, x30
98 .cfi_register x30, x2
99
100 /* Get kernel timespec. */
101 adr vdso_data, _vdso_data
1021: seqcnt_acquire
103 cbnz use_syscall, 7f
104
105 bl __do_get_tspec
106 seqcnt_check w9, 1b
107
108 cmp w0, #CLOCK_MONOTONIC
109 b.ne 6f
110
111 /* Get wtm timespec. */
112 ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC]
113
114 /* Check the sequence counter. */
115 seqcnt_read w9
116 seqcnt_check w9, 1b
117 b 4f
1182:
119 cmp w0, #CLOCK_REALTIME_COARSE
120 ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
121 b.ne 8f
122
123 /* Get coarse timespec. */
124 adr vdso_data, _vdso_data
1253: seqcnt_acquire
126 ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC]
127
128 /* Get wtm timespec. */
129 ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC]
130
131 /* Check the sequence counter. */
132 seqcnt_read w9
133 seqcnt_check w9, 3b
134
135 cmp w0, #CLOCK_MONOTONIC_COARSE
136 b.ne 6f
1374:
138 /* Add on wtm timespec. */
139 add x10, x10, x13
140 lsl x14, x14, x12
141 add x11, x11, x14
142
143 /* Normalise the new timespec. */
144 mov x15, #NSEC_PER_SEC_LO16
145 movk x15, #NSEC_PER_SEC_HI16, lsl #16
146 lsl x15, x15, x12
147 cmp x11, x15
148 b.lt 5f
149 sub x11, x11, x15
150 add x10, x10, #1
1515:
152 cmp x11, #0
153 b.ge 6f
154 add x11, x11, x15
155 sub x10, x10, #1
156
1576: /* Store to the user timespec. */
158 lsr x11, x11, x12
159 stp x10, x11, [x1, #TSPEC_TV_SEC]
160 mov x0, xzr
161 ret x2
1627:
163 mov x30, x2
1648: /* Syscall fallback. */
165 mov x8, #__NR_clock_gettime
166 svc #0
167 ret
168 .cfi_endproc
169ENDPROC(__kernel_clock_gettime)
170
171/* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */
172ENTRY(__kernel_clock_getres)
173 .cfi_startproc
174 cbz w1, 3f
175
176 cmp w0, #CLOCK_REALTIME
177 ccmp w0, #CLOCK_MONOTONIC, #0x4, ne
178 b.ne 1f
179
180 ldr x2, 5f
181 b 2f
1821:
183 cmp w0, #CLOCK_REALTIME_COARSE
184 ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
185 b.ne 4f
186 ldr x2, 6f
1872:
188 stp xzr, x2, [x1]
189
1903: /* res == NULL. */
191 mov w0, wzr
192 ret
193
1944: /* Syscall fallback. */
195 mov x8, #__NR_clock_getres
196 svc #0
197 ret
1985:
199 .quad CLOCK_REALTIME_RES
2006:
201 .quad CLOCK_COARSE_RES
202 .cfi_endproc
203ENDPROC(__kernel_clock_getres)
204
205/*
206 * Read the current time from the architected counter.
207 * Expects vdso_data to be initialised.
208 * Clobbers the temporary registers (x9 - x15).
209 * Returns:
210 * - w9 = vDSO sequence counter
211 * - (x10, x11) = (ts->tv_sec, shifted ts->tv_nsec)
212 * - w12 = cs_shift
213 */
214ENTRY(__do_get_tspec)
215 .cfi_startproc
216
217 /* Read from the vDSO data page. */
218 ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST]
219 ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC]
220 ldp w11, w12, [vdso_data, #VDSO_CS_MULT]
221 seqcnt_read w9
222
223 /* Read the virtual counter. */
224 isb
225 mrs x15, cntvct_el0
226
227 /* Calculate cycle delta and convert to ns. */
228 sub x10, x15, x10
229 /* We can only guarantee 56 bits of precision. */
230 movn x15, #0xff00, lsl #48
231 and x10, x15, x10
232 mul x10, x10, x11
233
234 /* Use the kernel time to calculate the new timespec. */
235 mov x11, #NSEC_PER_SEC_LO16
236 movk x11, #NSEC_PER_SEC_HI16, lsl #16
237 lsl x11, x11, x12
238 add x15, x10, x14
239 udiv x14, x15, x11
240 add x10, x13, x14
241 mul x13, x14, x11
242 sub x11, x15, x13
243
244 ret
245 .cfi_endproc
246ENDPROC(__do_get_tspec)
diff --git a/arch/arm64/kernel/vdso/note.S b/arch/arm64/kernel/vdso/note.S
deleted file mode 100644
index b82c85e5d97..00000000000
--- a/arch/arm64/kernel/vdso/note.S
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Copyright (C) 2012 ARM Limited
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Will Deacon <will.deacon@arm.com>
17 *
18 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
19 * Here we can supply some information useful to userland.
20 */
21
22#include <linux/uts.h>
23#include <linux/version.h>
24#include <linux/elfnote.h>
25
26ELFNOTE_START(Linux, 0, "a")
27 .long LINUX_VERSION_CODE
28ELFNOTE_END
diff --git a/arch/arm64/kernel/vdso/sigreturn.S b/arch/arm64/kernel/vdso/sigreturn.S
deleted file mode 100644
index 20d98effa7d..00000000000
--- a/arch/arm64/kernel/vdso/sigreturn.S
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Sigreturn trampoline for returning from a signal when the SA_RESTORER
3 * flag is not set.
4 *
5 * Copyright (C) 2012 ARM Limited
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Will Deacon <will.deacon@arm.com>
20 */
21
22#include <linux/linkage.h>
23#include <asm/unistd.h>
24
25 .text
26
27 nop
28ENTRY(__kernel_rt_sigreturn)
29 .cfi_startproc
30 .cfi_signal_frame
31 .cfi_def_cfa x29, 0
32 .cfi_offset x29, 0 * 8
33 .cfi_offset x30, 1 * 8
34 mov x8, #__NR_rt_sigreturn
35 svc #0
36 .cfi_endproc
37ENDPROC(__kernel_rt_sigreturn)
diff --git a/arch/arm64/kernel/vdso/vdso.S b/arch/arm64/kernel/vdso/vdso.S
deleted file mode 100644
index 60c1db54b41..00000000000
--- a/arch/arm64/kernel/vdso/vdso.S
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (C) 2012 ARM Limited
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Will Deacon <will.deacon@arm.com>
17 */
18
19#include <linux/init.h>
20#include <linux/linkage.h>
21#include <linux/const.h>
22#include <asm/page.h>
23
24 __PAGE_ALIGNED_DATA
25
26 .globl vdso_start, vdso_end
27 .balign PAGE_SIZE
28vdso_start:
29 .incbin "arch/arm64/kernel/vdso/vdso.so"
30 .balign PAGE_SIZE
31vdso_end:
32
33 .previous
diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
deleted file mode 100644
index 8154b8d1c82..00000000000
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * GNU linker script for the VDSO library.
3*
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Will Deacon <will.deacon@arm.com>
19 * Heavily based on the vDSO linker scripts for other archs.
20 */
21
22#include <linux/const.h>
23#include <asm/page.h>
24#include <asm/vdso.h>
25
26OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", "elf64-littleaarch64")
27OUTPUT_ARCH(aarch64)
28
29SECTIONS
30{
31 . = VDSO_LBASE + SIZEOF_HEADERS;
32
33 .hash : { *(.hash) } :text
34 .gnu.hash : { *(.gnu.hash) }
35 .dynsym : { *(.dynsym) }
36 .dynstr : { *(.dynstr) }
37 .gnu.version : { *(.gnu.version) }
38 .gnu.version_d : { *(.gnu.version_d) }
39 .gnu.version_r : { *(.gnu.version_r) }
40
41 .note : { *(.note.*) } :text :note
42
43 . = ALIGN(16);
44
45 .text : { *(.text*) } :text =0xd503201f
46 PROVIDE (__etext = .);
47 PROVIDE (_etext = .);
48 PROVIDE (etext = .);
49
50 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
51 .eh_frame : { KEEP (*(.eh_frame)) } :text
52
53 .dynamic : { *(.dynamic) } :text :dynamic
54
55 .rodata : { *(.rodata*) } :text
56
57 _end = .;
58 PROVIDE(end = .);
59
60 . = ALIGN(PAGE_SIZE);
61 PROVIDE(_vdso_data = .);
62
63 /DISCARD/ : {
64 *(.note.GNU-stack)
65 *(.data .data.* .gnu.linkonce.d.* .sdata*)
66 *(.bss .sbss .dynbss .dynsbss)
67 }
68}
69
70/*
71 * We must supply the ELF program headers explicitly to get just one
72 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
73 */
74PHDRS
75{
76 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
77 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
78 note PT_NOTE FLAGS(4); /* PF_R */
79 eh_frame_hdr PT_GNU_EH_FRAME;
80}
81
82/*
83 * This controls what symbols we export from the DSO.
84 */
85VERSION
86{
87 LINUX_2.6.39 {
88 global:
89 __kernel_rt_sigreturn;
90 __kernel_gettimeofday;
91 __kernel_clock_gettime;
92 __kernel_clock_getres;
93 local: *;
94 };
95}
96
97/*
98 * Make the sigreturn code visible to the kernel.
99 */
100VDSO_sigtramp = __kernel_rt_sigreturn;