blob: 3f32dfc2ab7350b6130bcfca317932f431d6cb99 [file] [log] [blame]
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -04001/*
2 * vvar.h: Shared vDSO/kernel variable declarations
3 * Copyright (c) 2011 Andy Lutomirski
4 * Subject to the GNU General Public License, version 2
5 *
6 * A handful of variables are accessible (read-only) from userspace
7 * code in the vsyscall page and the vdso. They are declared here.
8 * Some other file must define them with DEFINE_VVAR.
9 *
10 * In normal kernel code, they are used like any other variable.
11 * In user code, they are accessed through the VVAR macro.
12 *
Andy Lutomirski9fd67b42011-06-05 13:50:19 -040013 * These variables live in a page of kernel data that has an extra RO
14 * mapping for userspace. Each variable needs a unique offset within
15 * that page; specify that offset with the DECLARE_VVAR macro. (If
16 * you mess up, the linker will catch it.)
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040017 */
18
Stefani Seibold7c031562014-03-17 23:22:10 +010019#ifndef _ASM_X86_VVAR_H
20#define _ASM_X86_VVAR_H
21
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040022#if defined(__VVAR_KERNEL_LDS)
23
24/* The kernel linker script defines its own magic to put vvars in the
25 * right place.
26 */
27#define DECLARE_VVAR(offset, type, name) \
Andy Lutomirski9fd67b42011-06-05 13:50:19 -040028 EMIT_VVAR(name, offset)
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040029
30#else
31
Andy Lutomirskif40c3302014-05-05 12:19:36 -070032extern char __vvar_page;
Stefani Seiboldef721982014-03-17 23:22:07 +010033
34#define DECLARE_VVAR(offset, type, name) \
35 extern type vvar_ ## name __attribute__((visibility("hidden")));
36
37#define VVAR(name) (vvar_ ## name)
38
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040039#define DEFINE_VVAR(type, name) \
Andy Lutomirski9fd67b42011-06-05 13:50:19 -040040 type name \
Andi Kleen28596b62013-08-05 15:02:50 -070041 __attribute__((section(".vvar_" #name), aligned(16))) __visible
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040042
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040043#endif
44
45/* DECLARE_VVAR(offset, type, name) */
46
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040047DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data)
48
49#undef DECLARE_VVAR
Stefani Seibold7c031562014-03-17 23:22:10 +010050
51#endif