1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2015 Imagination Technologies
4 * Author: Alex Smith <alex.smith@imgtec.com>
10 #include <linux/mm_types.h>
12 #include <asm/barrier.h>
15 * struct mips_vdso_image - Details of a VDSO image.
16 * @data: Pointer to VDSO image data (page-aligned).
17 * @size: Size of the VDSO image data (page-aligned).
18 * @off_sigreturn: Offset of the sigreturn() trampoline.
19 * @off_rt_sigreturn: Offset of the rt_sigreturn() trampoline.
20 * @mapping: Special mapping structure.
22 * This structure contains details of a VDSO image, including the image data
23 * and offsets of certain symbols required by the kernel. It is generated as
24 * part of the VDSO build process, aside from the mapping page array, which is
25 * populated at runtime.
27 struct mips_vdso_image {
31 unsigned long off_sigreturn;
32 unsigned long off_rt_sigreturn;
34 struct vm_special_mapping mapping;
38 * The following structures are auto-generated as part of the build for each
39 * ABI by genvdso, see arch/mips/vdso/Makefile.
42 extern struct mips_vdso_image vdso_image;
44 #ifdef CONFIG_MIPS32_O32
45 extern struct mips_vdso_image vdso_image_o32;
48 #ifdef CONFIG_MIPS32_N32
49 extern struct mips_vdso_image vdso_image_n32;
53 * union mips_vdso_data - Data provided by the kernel for the VDSO.
54 * @xtime_sec: Current real time (seconds part).
55 * @xtime_nsec: Current real time (nanoseconds part, shifted).
56 * @wall_to_mono_sec: Wall-to-monotonic offset (seconds part).
57 * @wall_to_mono_nsec: Wall-to-monotonic offset (nanoseconds part).
58 * @seq_count: Counter to synchronise updates (odd = updating).
59 * @cs_shift: Clocksource shift value.
60 * @clock_mode: Clocksource to use for time functions.
61 * @cs_mult: Clocksource multiplier value.
62 * @cs_cycle_last: Clock cycle value at last update.
63 * @cs_mask: Clocksource mask value.
64 * @tz_minuteswest: Minutes west of Greenwich (from timezone).
65 * @tz_dsttime: Type of DST correction (from timezone).
67 * This structure contains data needed by functions within the VDSO. It is
68 * populated by the kernel and mapped read-only into user memory. The time
69 * fields are mirrors of internal data from the timekeeping infrastructure.
71 * Note: Care should be taken when modifying as the layout must remain the same
72 * for both 64- and 32-bit (for 32-bit userland on 64-bit kernel).
74 union mips_vdso_data {
79 u64 wall_to_mono_nsec;
93 static inline u32 vdso_data_read_begin(const union mips_vdso_data *data)
98 seq = READ_ONCE(data->seq_count);
99 if (likely(!(seq & 1))) {
100 /* Paired with smp_wmb() in vdso_data_write_*(). */
109 static inline bool vdso_data_read_retry(const union mips_vdso_data *data,
112 /* Paired with smp_wmb() in vdso_data_write_*(). */
114 return unlikely(data->seq_count != start_seq);
117 static inline void vdso_data_write_begin(union mips_vdso_data *data)
121 /* Ensure sequence update is written before other data page values. */
125 static inline void vdso_data_write_end(union mips_vdso_data *data)
127 /* Ensure data values are written before updating sequence again. */
132 #endif /* __ASM_VDSO_H */