2019-05-29 00:57:09 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-05-23 21:31:24 +08:00
|
|
|
/*
|
|
|
|
* vvar.h: Shared vDSO/kernel variable declarations
|
|
|
|
* Copyright (c) 2011 Andy Lutomirski
|
|
|
|
*
|
|
|
|
* A handful of variables are accessible (read-only) from userspace
|
|
|
|
* code in the vsyscall page and the vdso. They are declared here.
|
|
|
|
* Some other file must define them with DEFINE_VVAR.
|
|
|
|
*
|
|
|
|
* In normal kernel code, they are used like any other variable.
|
|
|
|
* In user code, they are accessed through the VVAR macro.
|
|
|
|
*
|
2011-06-06 01:50:19 +08:00
|
|
|
* These variables live in a page of kernel data that has an extra RO
|
|
|
|
* mapping for userspace. Each variable needs a unique offset within
|
|
|
|
* that page; specify that offset with the DECLARE_VVAR macro. (If
|
|
|
|
* you mess up, the linker will catch it.)
|
2011-05-23 21:31:24 +08:00
|
|
|
*/
|
|
|
|
|
2014-03-18 06:22:10 +08:00
|
|
|
#ifndef _ASM_X86_VVAR_H
|
|
|
|
#define _ASM_X86_VVAR_H
|
|
|
|
|
2019-11-12 09:27:10 +08:00
|
|
|
#ifdef EMIT_VVAR
|
|
|
|
/*
|
|
|
|
* EMIT_VVAR() is used by the kernel linker script to put vvars in the
|
|
|
|
* right place. Also, it's used by kernel code to import offsets values.
|
2011-05-23 21:31:24 +08:00
|
|
|
*/
|
|
|
|
#define DECLARE_VVAR(offset, type, name) \
|
2011-06-06 01:50:19 +08:00
|
|
|
EMIT_VVAR(name, offset)
|
2011-05-23 21:31:24 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2014-05-06 03:19:36 +08:00
|
|
|
extern char __vvar_page;
|
2014-03-18 06:22:07 +08:00
|
|
|
|
|
|
|
#define DECLARE_VVAR(offset, type, name) \
|
2019-06-21 17:52:49 +08:00
|
|
|
extern type vvar_ ## name[CS_BASES] \
|
2019-11-12 09:27:11 +08:00
|
|
|
__attribute__((visibility("hidden"))); \
|
|
|
|
extern type timens_ ## name[CS_BASES] \
|
|
|
|
__attribute__((visibility("hidden"))); \
|
2014-03-18 06:22:07 +08:00
|
|
|
|
|
|
|
#define VVAR(name) (vvar_ ## name)
|
2019-11-12 09:27:11 +08:00
|
|
|
#define TIMENS(name) (timens_ ## name)
|
2014-03-18 06:22:07 +08:00
|
|
|
|
2011-05-23 21:31:24 +08:00
|
|
|
#define DEFINE_VVAR(type, name) \
|
2019-06-21 17:52:49 +08:00
|
|
|
type name[CS_BASES] \
|
2013-08-06 06:02:50 +08:00
|
|
|
__attribute__((section(".vvar_" #name), aligned(16))) __visible
|
2011-05-23 21:31:24 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* DECLARE_VVAR(offset, type, name) */
|
|
|
|
|
2019-06-21 17:52:49 +08:00
|
|
|
DECLARE_VVAR(128, struct vdso_data, _vdso_data)
|
2011-05-23 21:31:24 +08:00
|
|
|
|
|
|
|
#undef DECLARE_VVAR
|
2014-03-18 06:22:10 +08:00
|
|
|
|
|
|
|
#endif
|