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) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Access to user system call parameters and results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright IBM Corp. 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef _ASM_SYSCALL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _ASM_SYSCALL_H	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <uapi/linux/audit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) extern const unsigned long sys_call_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) extern const unsigned long sys_call_table_emu[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static inline long syscall_get_nr(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 				  struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	return test_pt_regs_flag(regs, PIF_SYSCALL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		(regs->int_code & 0xffff) : -1;
^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) static inline void syscall_rollback(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 				    struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	regs->gprs[2] = regs->orig_gpr2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static inline long syscall_get_error(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				     struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	unsigned long error = regs->gprs[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (test_tsk_thread_flag(task, TIF_31BIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		 * and will match correctly in comparisons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		error = (long)(int)error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return IS_ERR_VALUE(error) ? error : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline long syscall_get_return_value(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 					    struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return regs->gprs[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static inline void syscall_set_return_value(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 					    struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 					    int error, long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	regs->gprs[2] = error ? error : val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static inline void syscall_get_arguments(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 					 struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 					 unsigned long *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned long mask = -1UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	unsigned int n = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (test_tsk_thread_flag(task, TIF_31BIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		mask = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	while (n-- > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		if (n > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			args[n] = regs->gprs[2 + n] & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	args[0] = regs->orig_gpr2 & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static inline void syscall_set_arguments(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 					 struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 					 const unsigned long *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	unsigned int n = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	while (n-- > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		if (n > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			regs->gprs[2 + n] = args[n];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	regs->orig_gpr2 = args[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static inline int syscall_get_arch(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (test_tsk_thread_flag(task, TIF_31BIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		return AUDIT_ARCH_S390;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	return AUDIT_ARCH_S390X;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif	/* _ASM_SYSCALL_H */