xref: /freebsd/sys/compat/linux/linux_vdso.h (revision 110be11ac9913fb5f26b1456359d25b5740dd615)
1bdc37934SDmitry Chagin /*-
2*c47116e9SDmitry Chagin  * SPDX-License-Identifier: BSD-2-Clause
3*c47116e9SDmitry Chagin  *
41ca6b15bSDmitry Chagin  * Copyright (c) 2013-2021 Dmitry Chagin <dchagin@FreeBSD.org>
5bdc37934SDmitry Chagin  *
6bdc37934SDmitry Chagin  * Redistribution and use in source and binary forms, with or without
7bdc37934SDmitry Chagin  * modification, are permitted provided that the following conditions
8bdc37934SDmitry Chagin  * are met:
9bdc37934SDmitry Chagin  * 1. Redistributions of source code must retain the above copyright
10*c47116e9SDmitry Chagin  *    notice, this list of conditions and the following disclaimer.
11bdc37934SDmitry Chagin  * 2. Redistributions in binary form must reproduce the above copyright
12bdc37934SDmitry Chagin  *    notice, this list of conditions and the following disclaimer in the
13bdc37934SDmitry Chagin  *    documentation and/or other materials provided with the distribution.
14bdc37934SDmitry Chagin  *
15*c47116e9SDmitry Chagin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*c47116e9SDmitry Chagin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*c47116e9SDmitry Chagin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*c47116e9SDmitry Chagin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*c47116e9SDmitry Chagin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*c47116e9SDmitry Chagin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*c47116e9SDmitry Chagin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*c47116e9SDmitry Chagin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*c47116e9SDmitry Chagin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*c47116e9SDmitry Chagin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*c47116e9SDmitry Chagin  * SUCH DAMAGE.
26bdc37934SDmitry Chagin  */
27bdc37934SDmitry Chagin 
28bdc37934SDmitry Chagin #ifndef _LINUX_VDSO_H_
29bdc37934SDmitry Chagin #define	_LINUX_VDSO_H_
30bdc37934SDmitry Chagin 
31bdc37934SDmitry Chagin struct linux_vdso_sym {
32bdc37934SDmitry Chagin 	SLIST_ENTRY(linux_vdso_sym) sym;
33bdc37934SDmitry Chagin 	uint32_t	size;
34bdc37934SDmitry Chagin 	uintptr_t *	ptr;
35bdc37934SDmitry Chagin 	char		symname[];
36bdc37934SDmitry Chagin };
37bdc37934SDmitry Chagin 
389931033bSDmitry Chagin vm_object_t __elfN(linux_shared_page_init)(char **, vm_size_t);
399931033bSDmitry Chagin void	__elfN(linux_shared_page_fini)(vm_object_t, void *, vm_size_t);
409931033bSDmitry Chagin void	__elfN(linux_vdso_fixup)(char *, vm_offset_t);
41bdc37934SDmitry Chagin void	__elfN(linux_vdso_sym_init)(struct linux_vdso_sym *);
42bdc37934SDmitry Chagin 
439931033bSDmitry Chagin int	linux_map_vdso(struct proc *, vm_object_t, vm_offset_t,
449931033bSDmitry Chagin 	    vm_offset_t, struct image_params *);
459931033bSDmitry Chagin 
46bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_INTPTR(name)				\
47bdc37934SDmitry Chagin uintptr_t name;							\
48bdc37934SDmitry Chagin LINUX_VDSO_SYM_DEFINE(name)
49bdc37934SDmitry Chagin 
50bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_CHAR(name)				\
51bdc37934SDmitry Chagin const char * name;						\
52bdc37934SDmitry Chagin LINUX_VDSO_SYM_DEFINE(name)
53bdc37934SDmitry Chagin 
54bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_DEFINE(name)				\
55bdc37934SDmitry Chagin static struct linux_vdso_sym name ## sym = {			\
56bdc37934SDmitry Chagin 	.symname	= #name,				\
57bdc37934SDmitry Chagin 	.size		= sizeof(#name),			\
58bdc37934SDmitry Chagin 	.ptr		= (uintptr_t *)&name			\
59bdc37934SDmitry Chagin };								\
60bdc37934SDmitry Chagin SYSINIT(__elfN(name ## _sym_init), SI_SUB_EXEC,			\
61bdc37934SDmitry Chagin     SI_ORDER_FIRST, __elfN(linux_vdso_sym_init), &name ## sym);	\
62bdc37934SDmitry Chagin struct __hack
63bdc37934SDmitry Chagin 
64bdc37934SDmitry Chagin #endif	/* _LINUX_VDSO_H_ */
65