12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b8b572e1SStephen Rothwell #ifndef _VDSO_DATAPAGE_H
3b8b572e1SStephen Rothwell #define _VDSO_DATAPAGE_H
4b8b572e1SStephen Rothwell #ifdef __KERNEL__
5b8b572e1SStephen Rothwell 
6b8b572e1SStephen Rothwell /*
7b8b572e1SStephen Rothwell  * Copyright (C) 2002 Peter Bergner <bergner@vnet.ibm.com>, IBM
8b8b572e1SStephen Rothwell  * Copyright (C) 2005 Benjamin Herrenschmidy <benh@kernel.crashing.org>,
9b8b572e1SStephen Rothwell  * 		      IBM Corp.
10b8b572e1SStephen Rothwell  */
11b8b572e1SStephen Rothwell 
12b8b572e1SStephen Rothwell 
13b8b572e1SStephen Rothwell /*
14b8b572e1SStephen Rothwell  * Note about this structure:
15b8b572e1SStephen Rothwell  *
16b8b572e1SStephen Rothwell  * This structure was historically called systemcfg and exposed to
17b8b572e1SStephen Rothwell  * userland via /proc/ppc64/systemcfg. Unfortunately, this became an
18b8b572e1SStephen Rothwell  * ABI issue as some proprietary software started relying on being able
19b8b572e1SStephen Rothwell  * to mmap() it, thus we have to keep the base layout at least for a
20b8b572e1SStephen Rothwell  * few kernel versions.
21b8b572e1SStephen Rothwell  *
22b8b572e1SStephen Rothwell  * However, since ppc32 doesn't suffer from this backward handicap,
23b8b572e1SStephen Rothwell  * a simpler version of the data structure is used there with only the
24b8b572e1SStephen Rothwell  * fields actually used by the vDSO.
25b8b572e1SStephen Rothwell  *
26b8b572e1SStephen Rothwell  */
27b8b572e1SStephen Rothwell 
28b8b572e1SStephen Rothwell /*
29b8b572e1SStephen Rothwell  * If the major version changes we are incompatible.
30b8b572e1SStephen Rothwell  * Minor version changes are a hint.
31b8b572e1SStephen Rothwell  */
32b8b572e1SStephen Rothwell #define SYSTEMCFG_MAJOR 1
33b8b572e1SStephen Rothwell #define SYSTEMCFG_MINOR 1
34b8b572e1SStephen Rothwell 
35b8b572e1SStephen Rothwell #ifndef __ASSEMBLY__
36b8b572e1SStephen Rothwell 
37b8b572e1SStephen Rothwell #include <linux/unistd.h>
38597bc5c0SPaul Mackerras #include <linux/time.h>
39ab037dd8SChristophe Leroy #include <vdso/datapage.h>
40b8b572e1SStephen Rothwell 
41f43194e4SRashmica Gupta #define SYSCALL_MAP_SIZE      ((NR_syscalls + 31) / 32)
42b8b572e1SStephen Rothwell 
43b8b572e1SStephen Rothwell /*
44b8b572e1SStephen Rothwell  * So here is the ppc64 backward compatible version
45b8b572e1SStephen Rothwell  */
46b8b572e1SStephen Rothwell 
47b8b572e1SStephen Rothwell #ifdef CONFIG_PPC64
48b8b572e1SStephen Rothwell 
49ab037dd8SChristophe Leroy struct vdso_arch_data {
50b8b572e1SStephen Rothwell 	__u8  eye_catcher[16];		/* Eyecatcher: SYSTEMCFG:PPC64	0x00 */
51b8b572e1SStephen Rothwell 	struct {			/* Systemcfg version numbers	     */
52b8b572e1SStephen Rothwell 		__u32 major;		/* Major number			0x10 */
53b8b572e1SStephen Rothwell 		__u32 minor;		/* Minor number			0x14 */
54b8b572e1SStephen Rothwell 	} version;
55b8b572e1SStephen Rothwell 
56b8b572e1SStephen Rothwell 	/* Note about the platform flags: it now only contains the lpar
5725985edcSLucas De Marchi 	 * bit. The actual platform number is dead and buried
58b8b572e1SStephen Rothwell 	 */
59b8b572e1SStephen Rothwell 	__u32 platform;			/* Platform flags		0x18 */
60b8b572e1SStephen Rothwell 	__u32 processor;		/* Processor type		0x1C */
61b8b572e1SStephen Rothwell 	__u64 processorCount;		/* # of physical processors	0x20 */
62b8b572e1SStephen Rothwell 	__u64 physicalMemorySize;	/* Size of real memory(B)	0x28 */
63ab037dd8SChristophe Leroy 	__u64 tb_orig_stamp;		/* (NU) Timebase at boot	0x30 */
64b8b572e1SStephen Rothwell 	__u64 tb_ticks_per_sec;		/* Timebase tics / sec		0x38 */
65ab037dd8SChristophe Leroy 	__u64 tb_to_xs;			/* (NU) Inverse of TB to 2^20	0x40 */
66ab037dd8SChristophe Leroy 	__u64 stamp_xsec;		/* (NU)				0x48 */
67ab037dd8SChristophe Leroy 	__u64 tb_update_count;		/* (NU) Timebase atomicity ctr	0x50 */
68ab037dd8SChristophe Leroy 	__u32 tz_minuteswest;		/* (NU) Min. west of Greenwich	0x58 */
69ab037dd8SChristophe Leroy 	__u32 tz_dsttime;		/* (NU) Type of dst correction	0x5C */
70b8b572e1SStephen Rothwell 	__u32 dcache_size;		/* L1 d-cache size		0x60 */
71b8b572e1SStephen Rothwell 	__u32 dcache_line_size;		/* L1 d-cache line size		0x64 */
72b8b572e1SStephen Rothwell 	__u32 icache_size;		/* L1 i-cache size		0x68 */
73b8b572e1SStephen Rothwell 	__u32 icache_line_size;		/* L1 i-cache line size		0x6C */
74b8b572e1SStephen Rothwell 
75b8b572e1SStephen Rothwell 	/* those additional ones don't have to be located anywhere
76b8b572e1SStephen Rothwell 	 * special as they were not part of the original systemcfg
77b8b572e1SStephen Rothwell 	 */
78b8b572e1SStephen Rothwell 	__u32 dcache_block_size;		/* L1 d-cache block size     */
79b8b572e1SStephen Rothwell 	__u32 icache_block_size;		/* L1 i-cache block size     */
80b8b572e1SStephen Rothwell 	__u32 dcache_log_block_size;		/* L1 d-cache log block size */
81b8b572e1SStephen Rothwell 	__u32 icache_log_block_size;		/* L1 i-cache log block size */
821bb30b7aSChristophe Leroy 	__u32 syscall_map[SYSCALL_MAP_SIZE];	/* Map of syscalls  */
831bb30b7aSChristophe Leroy 	__u32 compat_syscall_map[SYSCALL_MAP_SIZE];	/* Map of compat syscalls */
84ab037dd8SChristophe Leroy 
85ab037dd8SChristophe Leroy 	struct vdso_data data[CS_BASES];
86b8b572e1SStephen Rothwell };
87b8b572e1SStephen Rothwell 
88b8b572e1SStephen Rothwell #else /* CONFIG_PPC64 */
89b8b572e1SStephen Rothwell 
90b8b572e1SStephen Rothwell /*
91b8b572e1SStephen Rothwell  * And here is the simpler 32 bits version
92b8b572e1SStephen Rothwell  */
93ab037dd8SChristophe Leroy struct vdso_arch_data {
94b8b572e1SStephen Rothwell 	__u64 tb_ticks_per_sec;		/* Timebase tics / sec		0x38 */
951bb30b7aSChristophe Leroy 	__u32 syscall_map[SYSCALL_MAP_SIZE]; /* Map of syscalls */
961bb30b7aSChristophe Leroy 	__u32 compat_syscall_map[0];	/* No compat syscalls on PPC32 */
97ab037dd8SChristophe Leroy 	struct vdso_data data[CS_BASES];
98b8b572e1SStephen Rothwell };
99b8b572e1SStephen Rothwell 
100b8b572e1SStephen Rothwell #endif /* CONFIG_PPC64 */
101b8b572e1SStephen Rothwell 
102ab037dd8SChristophe Leroy extern struct vdso_arch_data *vdso_data;
103b8b572e1SStephen Rothwell 
104ec0895f0SChristophe Leroy #else /* __ASSEMBLY__ */
105ec0895f0SChristophe Leroy 
106*550e6074SChristophe Leroy .macro get_datapage ptr
107ec0895f0SChristophe Leroy 	bcl	20, 31, .+4
108591857b6SChristophe Leroy 999:
109ec0895f0SChristophe Leroy 	mflr	\ptr
110591857b6SChristophe Leroy 	addis	\ptr, \ptr, (_vdso_datapage - 999b)@ha
111591857b6SChristophe Leroy 	addi	\ptr, \ptr, (_vdso_datapage - 999b)@l
112ec0895f0SChristophe Leroy .endm
113ec0895f0SChristophe Leroy 
114b8b572e1SStephen Rothwell #endif /* __ASSEMBLY__ */
115b8b572e1SStephen Rothwell 
116b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
117b8b572e1SStephen Rothwell #endif /* _SYSTEMCFG_H */
118