cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

gettimeofday.h (2739B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2
      3#ifndef __ASM_VDSO_CSKY_GETTIMEOFDAY_H
      4#define __ASM_VDSO_CSKY_GETTIMEOFDAY_H
      5
      6#ifndef __ASSEMBLY__
      7
      8#include <asm/barrier.h>
      9#include <asm/unistd.h>
     10#include <abi/regdef.h>
     11#include <uapi/linux/time.h>
     12
     13#define VDSO_HAS_CLOCK_GETRES	1
     14
     15static __always_inline
     16int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
     17			  struct timezone *_tz)
     18{
     19	register struct __kernel_old_timeval *tv asm("a0") = _tv;
     20	register struct timezone *tz asm("a1") = _tz;
     21	register long ret asm("a0");
     22	register long nr asm(syscallid) = __NR_gettimeofday;
     23
     24	asm volatile ("trap 0\n"
     25		      : "=r" (ret)
     26		      : "r"(tv), "r"(tz), "r"(nr)
     27		      : "memory");
     28
     29	return ret;
     30}
     31
     32static __always_inline
     33long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
     34{
     35	register clockid_t clkid asm("a0") = _clkid;
     36	register struct __kernel_timespec *ts asm("a1") = _ts;
     37	register long ret asm("a0");
     38	register long nr asm(syscallid) = __NR_clock_gettime64;
     39
     40	asm volatile ("trap 0\n"
     41		      : "=r" (ret)
     42		      : "r"(clkid), "r"(ts), "r"(nr)
     43		      : "memory");
     44
     45	return ret;
     46}
     47
     48static __always_inline
     49long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
     50{
     51	register clockid_t clkid asm("a0") = _clkid;
     52	register struct old_timespec32 *ts asm("a1") = _ts;
     53	register long ret asm("a0");
     54	register long nr asm(syscallid) = __NR_clock_gettime;
     55
     56	asm volatile ("trap 0\n"
     57		      : "=r" (ret)
     58		      : "r"(clkid), "r"(ts), "r"(nr)
     59		      : "memory");
     60
     61	return ret;
     62}
     63
     64static __always_inline
     65int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
     66{
     67	register clockid_t clkid asm("a0") = _clkid;
     68	register struct __kernel_timespec *ts asm("a1") = _ts;
     69	register long ret asm("a0");
     70	register long nr asm(syscallid) = __NR_clock_getres_time64;
     71
     72	asm volatile ("trap 0\n"
     73		      : "=r" (ret)
     74		      : "r"(clkid), "r"(ts), "r"(nr)
     75		      : "memory");
     76
     77	return ret;
     78}
     79
     80static __always_inline
     81int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
     82{
     83	register clockid_t clkid asm("a0") = _clkid;
     84	register struct old_timespec32 *ts asm("a1") = _ts;
     85	register long ret asm("a0");
     86	register long nr asm(syscallid) = __NR_clock_getres;
     87
     88	asm volatile ("trap 0\n"
     89		      : "=r" (ret)
     90		      : "r"(clkid), "r"(ts), "r"(nr)
     91		      : "memory");
     92
     93	return ret;
     94}
     95
     96uint64_t csky_pmu_read_cc(void);
     97static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
     98						 const struct vdso_data *vd)
     99{
    100#ifdef CONFIG_CSKY_PMU_V1
    101	return csky_pmu_read_cc();
    102#else
    103	return 0;
    104#endif
    105}
    106
    107static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
    108{
    109	return _vdso_data;
    110}
    111
    112#endif /* !__ASSEMBLY__ */
    113
    114#endif /* __ASM_VDSO_CSKY_GETTIMEOFDAY_H */