xref: /OK3568_Linux_fs/kernel/arch/sh/include/asm/segment.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __ASM_SH_SEGMENT_H
3*4882a593Smuzhiyun #define __ASM_SH_SEGMENT_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #ifndef __ASSEMBLY__
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun typedef struct {
8*4882a593Smuzhiyun 	unsigned long seg;
9*4882a593Smuzhiyun } mm_segment_t;
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /*
14*4882a593Smuzhiyun  * The fs value determines whether argument validity checking should be
15*4882a593Smuzhiyun  * performed or not.  If get_fs() == USER_DS, checking is performed, with
16*4882a593Smuzhiyun  * get_fs() == KERNEL_DS, checking is bypassed.
17*4882a593Smuzhiyun  *
18*4882a593Smuzhiyun  * For historical reasons, these macros are grossly misnamed.
19*4882a593Smuzhiyun  */
20*4882a593Smuzhiyun #define KERNEL_DS	MAKE_MM_SEG(0xFFFFFFFFUL)
21*4882a593Smuzhiyun #ifdef CONFIG_MMU
22*4882a593Smuzhiyun #define USER_DS		MAKE_MM_SEG(PAGE_OFFSET)
23*4882a593Smuzhiyun #else
24*4882a593Smuzhiyun #define USER_DS		KERNEL_DS
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #define get_fs()	(current_thread_info()->addr_limit)
30*4882a593Smuzhiyun #define set_fs(x)	(current_thread_info()->addr_limit = (x))
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
33*4882a593Smuzhiyun #endif /* __ASM_SH_SEGMENT_H */
34