2019-05-28 23:57:09 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-05-23 20:31:24 +07: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 00:50:19 +07: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 20:31:24 +07:00
|
|
|
*/
|
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
#ifndef _ASM_X86_VVAR_H
|
|
|
|
#define _ASM_X86_VVAR_H
|
|
|
|
|
2019-11-12 08:27:10 +07: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 20:31:24 +07:00
|
|
|
*/
|
|
|
|
#define DECLARE_VVAR(offset, type, name) \
|
2011-06-06 00:50:19 +07:00
|
|
|
EMIT_VVAR(name, offset)
|
2011-05-23 20:31:24 +07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2014-05-06 02:19:36 +07:00
|
|
|
extern char __vvar_page;
|
2014-03-18 05:22:07 +07:00
|
|
|
|
|
|
|
#define DECLARE_VVAR(offset, type, name) \
|
2019-06-21 16:52:49 +07:00
|
|
|
extern type vvar_ ## name[CS_BASES] \
|
2019-11-12 08:27:11 +07:00
|
|
|
__attribute__((visibility("hidden"))); \
|
|
|
|
extern type timens_ ## name[CS_BASES] \
|
|
|
|
__attribute__((visibility("hidden"))); \
|
2014-03-18 05:22:07 +07:00
|
|
|
|
|
|
|
#define VVAR(name) (vvar_ ## name)
|
2019-11-12 08:27:11 +07:00
|
|
|
#define TIMENS(name) (timens_ ## name)
|
2014-03-18 05:22:07 +07:00
|
|
|
|
2011-05-23 20:31:24 +07:00
|
|
|
#define DEFINE_VVAR(type, name) \
|
2019-06-21 16:52:49 +07:00
|
|
|
type name[CS_BASES] \
|
2013-08-06 05:02:50 +07:00
|
|
|
__attribute__((section(".vvar_" #name), aligned(16))) __visible
|
2011-05-23 20:31:24 +07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* DECLARE_VVAR(offset, type, name) */
|
|
|
|
|
2019-06-21 16:52:49 +07:00
|
|
|
DECLARE_VVAR(128, struct vdso_data, _vdso_data)
|
2011-05-23 20:31:24 +07:00
|
|
|
|
|
|
|
#undef DECLARE_VVAR
|
2014-03-18 05:22:10 +07:00
|
|
|
|
|
|
|
#endif
|