xref: /linux/arch/loongarch/include/asm/vdso/vdso.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Author: Huacai Chen <chenhuacai@loongson.cn>
4  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5  */
6 
7 #ifndef _ASM_VDSO_VDSO_H
8 #define _ASM_VDSO_VDSO_H
9 
10 #ifndef __ASSEMBLY__
11 
12 #include <asm/asm.h>
13 #include <asm/page.h>
14 #include <asm/vdso.h>
15 
16 struct vdso_pcpu_data {
17 	u32 node;
18 } ____cacheline_aligned_in_smp;
19 
20 struct loongarch_vdso_data {
21 	struct vdso_pcpu_data pdata[NR_CPUS];
22 	struct vdso_rng_data rng_data;
23 };
24 
25 /*
26  * The layout of vvar:
27  *
28  *                      high
29  * +---------------------+--------------------------+
30  * | loongarch vdso data | LOONGARCH_VDSO_DATA_SIZE |
31  * +---------------------+--------------------------+
32  * |  time-ns vdso data  |        PAGE_SIZE         |
33  * +---------------------+--------------------------+
34  * |  generic vdso data  |        PAGE_SIZE         |
35  * +---------------------+--------------------------+
36  *                      low
37  */
38 #define LOONGARCH_VDSO_DATA_SIZE PAGE_ALIGN(sizeof(struct loongarch_vdso_data))
39 #define LOONGARCH_VDSO_DATA_PAGES (LOONGARCH_VDSO_DATA_SIZE >> PAGE_SHIFT)
40 
41 enum vvar_pages {
42 	VVAR_GENERIC_PAGE_OFFSET,
43 	VVAR_TIMENS_PAGE_OFFSET,
44 	VVAR_LOONGARCH_PAGES_START,
45 	VVAR_LOONGARCH_PAGES_END = VVAR_LOONGARCH_PAGES_START + LOONGARCH_VDSO_DATA_PAGES - 1,
46 	VVAR_NR_PAGES,
47 };
48 
49 #define VVAR_SIZE (VVAR_NR_PAGES << PAGE_SHIFT)
50 
51 extern struct loongarch_vdso_data _loongarch_data __attribute__((visibility("hidden")));
52 
53 #endif /* __ASSEMBLY__ */
54 
55 #endif
56