2 * Userspace implementations of fallback calls
4 * Copyright (C) 2017 Cavium, Inc.
5 * Copyright (C) 2012 ARM Limited
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.
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.
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/>.
19 * Author: Will Deacon <will.deacon@arm.com>
20 * Rewriten into C by: Andrew Pinski <apinski@cavium.com>
23 #ifndef __VDSO_COMPILER_H
24 #define __VDSO_COMPILER_H
26 #include <asm/barrier.h> /* for isb() & dmb() */
27 #include <asm/param.h> /* for HZ */
28 #include <asm/unistd32.h>
29 #include <linux/compiler.h>
31 #ifdef CONFIG_ARM_ARCH_TIMER
32 #define ARCH_PROVIDES_TIMER
35 /* can not include linux/time.h because of too much architectural cruft */
37 #define NSEC_PER_SEC 1000000000L
40 /* can not include linux/jiffies.h because of too much architectural cruft */
42 #define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ)
45 /* can not include linux/hrtimer.h because of too much architectural cruft */
47 #define LOW_RES_NSEC TICK_NSEC
48 #ifdef ARCH_PROVIDES_TIMER
49 #ifdef CONFIG_HIGH_RES_TIMERS
50 # define HIGH_RES_NSEC 1
51 # define MONOTONIC_RES_NSEC HIGH_RES_NSEC
53 # define MONOTONIC_RES_NSEC LOW_RES_NSEC
58 #define DEFINE_FALLBACK(name, type_arg1, name_arg1, type_arg2, name_arg2) \
59 static notrace long name##_fallback(type_arg1 _##name_arg1, \
60 type_arg2 _##name_arg2) \
62 register type_arg1 name_arg1 asm("r0") = _##name_arg1; \
63 register type_arg2 name_arg2 asm("r1") = _##name_arg2; \
64 register long ret asm ("r0"); \
65 register long nr asm("r7") = __NR_##name; \
70 : "r" (name_arg1), "r" (name_arg2), "r" (nr) \
77 * AArch32 implementation of arch_counter_get_cntvct() suitable for vdso
79 static __always_inline notrace u64
arch_vdso_read_counter(void)
83 /* Read the virtual counter. */
85 asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (res
));
91 * Can not include asm/processor.h to pick this up because of all the
92 * architectural components also included, so we open code a copy.
94 static inline void cpu_relax(void)
96 asm volatile("yield" ::: "memory");
100 #if __LINUX_ARM_ARCH__ >= 8
101 #define smp_rmb() dmb(ishld) /* ok on ARMv8 */
103 #define smp_rmb() dmb(ish) /* ishld does not exist on ARMv7 */
106 /* Avoid unresolved references emitted by GCC */
108 void __aeabi_unwind_cpp_pr0(void)
112 void __aeabi_unwind_cpp_pr1(void)
116 void __aeabi_unwind_cpp_pr2(void)
120 #endif /* __VDSO_COMPILER_H */