master
s 77 lines 1.79 KB
Raw
1 /*
2 * aarch64 linux replacement vdso.
3 *
4 * Copyright 2023 Linaro, Ltd.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #include <asm/unistd.h>
10
11 /* ??? These are in include/elf.h, which is not ready for inclusion in asm. */
12 #define NT_GNU_PROPERTY_TYPE_0 5
13 #define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
14 #define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
15 #define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
16
17 #define GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT \
18 (GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC)
19
20 .section .note.gnu.property
21 .align 3
22 .long 2f - 1f
23 .long 6f - 3f
24 .long NT_GNU_PROPERTY_TYPE_0
25 1: .string "GNU"
26 2: .align 3
27 3: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND
28 .long 5f - 4f
29 4: .long GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT
30 5: .align 3
31 6:
32
33 .text
34
35 .macro endf name
36 .globl \name
37 .type \name, @function
38 .size \name, . - \name
39 .endm
40
41 .macro vdso_syscall name, nr
42 \name:
43 bti c
44 mov x8, #\nr
45 svc #0
46 ret
47 endf \name
48 .endm
49
50 .cfi_startproc
51
52 vdso_syscall __kernel_gettimeofday, __NR_gettimeofday
53 vdso_syscall __kernel_clock_gettime, __NR_clock_gettime
54 vdso_syscall __kernel_clock_getres, __NR_clock_getres
55
56 .cfi_endproc
57
58
59 /*
60 * TODO: The kernel makes a big deal of turning off the .cfi directives,
61 * because they cause libgcc to crash, but that's because they're wrong.
62 *
63 * For now, elide the unwind info for __kernel_rt_sigreturn and rely on
64 * the libgcc fallback routine as we have always done. This requires
65 * that the code sequence used be exact.
66 *
67 * Add a nop as a spacer to ensure that unwind does not pick up the
68 * unwind info from the preceding syscall.
69 */
70 nop
71 __kernel_rt_sigreturn:
72 /* No BTI C insn here -- we arrive via RET. */
73 mov x8, #__NR_rt_sigreturn
74 sigreturn_region_start:
75 svc #0
76 sigreturn_region_end:
77 endf __kernel_rt_sigreturn