xref: /openbmc/qemu/linux-user/aarch64/vdso.S (revision 878502e5)
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
251:	.string	"GNU"
262:	.align	3
273:	.long	GNU_PROPERTY_AARCH64_FEATURE_1_AND
28	.long	5f - 4f
294:	.long	GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT
305:	.align	3
316:
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
47endf	\name
48.endm
49
50	.cfi_startproc
51
52vdso_syscall __kernel_gettimeofday, __NR_gettimeofday
53vdso_syscall __kernel_clock_gettime, __NR_clock_gettime
54vdso_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	svc	#0
75endf	__kernel_rt_sigreturn
76