2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
14 #include <linux/mm_types.h>
16 #include <asm/barrier.h>
19 * struct mips_vdso_image - Details of a VDSO image.
20 * @data: Pointer to VDSO image data (page-aligned).
21 * @size: Size of the VDSO image data (page-aligned).
22 * @off_sigreturn: Offset of the sigreturn() trampoline.
23 * @off_rt_sigreturn: Offset of the rt_sigreturn() trampoline.
24 * @mapping: Special mapping structure.
26 * This structure contains details of a VDSO image, including the image data
27 * and offsets of certain symbols required by the kernel. It is generated as
28 * part of the VDSO build process, aside from the mapping page array, which is
29 * populated at runtime.
31 struct mips_vdso_image
{
35 unsigned long off_sigreturn
;
36 unsigned long off_rt_sigreturn
;
38 struct vm_special_mapping mapping
;
42 * The following structures are auto-generated as part of the build for each
43 * ABI by genvdso, see arch/mips/vdso/Makefile.
46 extern struct mips_vdso_image vdso_image
;
48 #ifdef CONFIG_MIPS32_O32
49 extern struct mips_vdso_image vdso_image_o32
;
52 #ifdef CONFIG_MIPS32_N32
53 extern struct mips_vdso_image vdso_image_n32
;
57 * union mips_vdso_data - Data provided by the kernel for the VDSO.
58 * @xtime_sec: Current real time (seconds part).
59 * @xtime_nsec: Current real time (nanoseconds part, shifted).
60 * @wall_to_mono_sec: Wall-to-monotonic offset (seconds part).
61 * @wall_to_mono_nsec: Wall-to-monotonic offset (nanoseconds part).
62 * @seq_count: Counter to synchronise updates (odd = updating).
63 * @cs_shift: Clocksource shift value.
64 * @clock_mode: Clocksource to use for time functions.
65 * @cs_mult: Clocksource multiplier value.
66 * @cs_cycle_last: Clock cycle value at last update.
67 * @cs_mask: Clocksource mask value.
68 * @tz_minuteswest: Minutes west of Greenwich (from timezone).
69 * @tz_dsttime: Type of DST correction (from timezone).
71 * This structure contains data needed by functions within the VDSO. It is
72 * populated by the kernel and mapped read-only into user memory. The time
73 * fields are mirrors of internal data from the timekeeping infrastructure.
75 * Note: Care should be taken when modifying as the layout must remain the same
76 * for both 64- and 32-bit (for 32-bit userland on 64-bit kernel).
78 union mips_vdso_data
{
83 u32 wall_to_mono_nsec
;
97 static inline u32
vdso_data_read_begin(const union mips_vdso_data
*data
)
102 seq
= ACCESS_ONCE(data
->seq_count
);
103 if (likely(!(seq
& 1))) {
104 /* Paired with smp_wmb() in vdso_data_write_*(). */
113 static inline bool vdso_data_read_retry(const union mips_vdso_data
*data
,
116 /* Paired with smp_wmb() in vdso_data_write_*(). */
118 return unlikely(data
->seq_count
!= start_seq
);
121 static inline void vdso_data_write_begin(union mips_vdso_data
*data
)
125 /* Ensure sequence update is written before other data page values. */
129 static inline void vdso_data_write_end(union mips_vdso_data
*data
)
131 /* Ensure data values are written before updating sequence again. */
136 #endif /* __ASM_VDSO_H */