Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * include/asm-xtensa/uaccess.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * User space memory access functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * These routines provide basic accessing functions to the user memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * space for the kernel. This header file provides functions such as:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * Copyright (C) 2001 - 2005 Tensilica Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #ifndef _XTENSA_ASM_UACCESS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define _XTENSA_ASM_UACCESS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/current.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * These assembly macros mirror the C macros in asm/uaccess.h.  They
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * should always have identical functionality.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * arch/xtensa/kernel/sys.S for usage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define KERNEL_DS	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define USER_DS		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * get_fs reads current->thread.current_ds into a register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * On Entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * 	<ad>	anything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * 	<sp>	stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * On Exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * 	<ad>	contains current->thread.current_ds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	.macro	get_fs	ad, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	GET_CURRENT(\ad,\sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #if THREAD_CURRENT_DS > 1020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	addi	\ad, \ad, TASK_THREAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	l32i	\ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	l32i	\ad, \ad, THREAD_CURRENT_DS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	.endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * set_fs sets current->thread.current_ds to some value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * On Entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *	<at>	anything (temp register)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *	<av>	value to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *	<sp>	stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * On Exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *	<at>	destroyed (actually, current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *	<av>	preserved, value to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.macro	set_fs	at, av, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	GET_CURRENT(\at,\sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	s32i	\av, \at, THREAD_CURRENT_DS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	.endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * kernel_ok determines whether we should bypass addr/size checking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * See the equivalent C-macro version below for clarity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * On success, kernel_ok branches to a label indicated by parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * <success>.  This implies that the macro falls through to the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * insruction on an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Note that while this macro can be used independently, we designed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * in for optimal use in the access_ok macro below (i.e., we fall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * through on error).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * On Entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * 	<at>		anything (temp register)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * 	<success>	label to branch to on success; implies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * 			fall-through macro on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * 	<sp>		stack pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * On Exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * 	<at>		destroyed (actually, current->thread.current_ds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #if ((KERNEL_DS != 0) || (USER_DS == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) # error Assembly macro kernel_ok fails
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	.macro	kernel_ok  at, sp, success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	get_fs	\at, \sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	beqz	\at, \success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	.endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * user_ok determines whether the access to user-space memory is allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * See the equivalent C-macro version below for clarity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * On error, user_ok branches to a label indicated by parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * <error>.  This implies that the macro falls through to the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * instruction on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Note that while this macro can be used independently, we designed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * in for optimal use in the access_ok macro below (i.e., we fall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * through on success).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * On Entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * 	<aa>	register containing memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * 	<as>	register containing memory size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * 	<at>	temp register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * 	<error>	label to branch to on error; implies fall-through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * 		macro on success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * On Exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * 	<aa>	preserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * 	<as>	preserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * 	<at>	destroyed (actually, (TASK_SIZE + 1 - size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.macro	user_ok	aa, as, at, error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	movi	\at, __XTENSA_UL_CONST(TASK_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	bgeu	\as, \at, \error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	sub	\at, \at, \as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	bgeu	\aa, \at, \error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	.endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * access_ok determines whether a memory access is allowed.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * equivalent C-macro version below for clarity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * On error, access_ok branches to a label indicated by parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * <error>.  This implies that the macro falls through to the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * instruction on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * Note that we assume success is the common case, and we optimize the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * branch fall-through case on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * On Entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * 	<aa>	register containing memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * 	<as>	register containing memory size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * 	<at>	temp register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * 	<sp>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * 	<error>	label to branch to on error; implies fall-through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * 		macro on success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * On Exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * 	<aa>	preserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * 	<as>	preserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * 	<at>	destroyed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	.macro	access_ok  aa, as, at, sp, error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	kernel_ok  \at, \sp, .Laccess_ok_\@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	user_ok    \aa, \as, \at, \error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .Laccess_ok_\@:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	.endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #endif	/* _XTENSA_ASM_UACCESS_H */