Linux Audio

Check our new training course

Loading...
v3.5.6
 1/*
 2 * Access to user system call parameters and results
 3 *
 4 *  Copyright IBM Corp. 2008
 5 *  Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
 6 *
 7 * This program is free software; you can redistribute it and/or modify
 8 * it under the terms of the GNU General Public License (version 2 only)
 9 * as published by the Free Software Foundation.
10 */
11
12#ifndef _ASM_SYSCALL_H
13#define _ASM_SYSCALL_H	1
14
 
15#include <linux/sched.h>
16#include <linux/err.h>
17#include <asm/ptrace.h>
18
19/*
20 * The syscall table always contains 32 bit pointers since we know that the
21 * address of the function to be called is (way) below 4GB.  So the "int"
22 * type here is what we want [need] for both 32 bit and 64 bit systems.
23 */
24extern const unsigned int sys_call_table[];
 
25
26static inline long syscall_get_nr(struct task_struct *task,
27				  struct pt_regs *regs)
28{
29	return test_tsk_thread_flag(task, TIF_SYSCALL) ?
30		(regs->int_code & 0xffff) : -1;
31}
32
33static inline void syscall_rollback(struct task_struct *task,
34				    struct pt_regs *regs)
35{
36	regs->gprs[2] = regs->orig_gpr2;
37}
38
39static inline long syscall_get_error(struct task_struct *task,
40				     struct pt_regs *regs)
41{
42	return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0;
43}
44
45static inline long syscall_get_return_value(struct task_struct *task,
46					    struct pt_regs *regs)
47{
48	return regs->gprs[2];
49}
50
51static inline void syscall_set_return_value(struct task_struct *task,
52					    struct pt_regs *regs,
53					    int error, long val)
54{
55	regs->gprs[2] = error ? -error : val;
56}
57
58static inline void syscall_get_arguments(struct task_struct *task,
59					 struct pt_regs *regs,
60					 unsigned int i, unsigned int n,
61					 unsigned long *args)
62{
63	unsigned long mask = -1UL;
64
65	BUG_ON(i + n > 6);
66#ifdef CONFIG_COMPAT
67	if (test_tsk_thread_flag(task, TIF_31BIT))
68		mask = 0xffffffff;
69#endif
70	while (n-- > 0)
71		if (i + n > 0)
72			args[n] = regs->gprs[2 + i + n] & mask;
73	if (i == 0)
74		args[0] = regs->orig_gpr2 & mask;
75}
76
77static inline void syscall_set_arguments(struct task_struct *task,
78					 struct pt_regs *regs,
79					 unsigned int i, unsigned int n,
80					 const unsigned long *args)
81{
82	BUG_ON(i + n > 6);
83	while (n-- > 0)
84		if (i + n > 0)
85			regs->gprs[2 + i + n] = args[n];
86	if (i == 0)
87		regs->orig_gpr2 = args[0];
88}
89
 
 
 
 
 
 
 
 
90#endif	/* _ASM_SYSCALL_H */
v3.15
  1/*
  2 * Access to user system call parameters and results
  3 *
  4 *  Copyright IBM Corp. 2008
  5 *  Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  6 *
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License (version 2 only)
  9 * as published by the Free Software Foundation.
 10 */
 11
 12#ifndef _ASM_SYSCALL_H
 13#define _ASM_SYSCALL_H	1
 14
 15#include <uapi/linux/audit.h>
 16#include <linux/sched.h>
 17#include <linux/err.h>
 18#include <asm/ptrace.h>
 19
 20/*
 21 * The syscall table always contains 32 bit pointers since we know that the
 22 * address of the function to be called is (way) below 4GB.  So the "int"
 23 * type here is what we want [need] for both 32 bit and 64 bit systems.
 24 */
 25extern const unsigned int sys_call_table[];
 26extern const unsigned int sys_call_table_emu[];
 27
 28static inline long syscall_get_nr(struct task_struct *task,
 29				  struct pt_regs *regs)
 30{
 31	return test_tsk_thread_flag(task, TIF_SYSCALL) ?
 32		(regs->int_code & 0xffff) : -1;
 33}
 34
 35static inline void syscall_rollback(struct task_struct *task,
 36				    struct pt_regs *regs)
 37{
 38	regs->gprs[2] = regs->orig_gpr2;
 39}
 40
 41static inline long syscall_get_error(struct task_struct *task,
 42				     struct pt_regs *regs)
 43{
 44	return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0;
 45}
 46
 47static inline long syscall_get_return_value(struct task_struct *task,
 48					    struct pt_regs *regs)
 49{
 50	return regs->gprs[2];
 51}
 52
 53static inline void syscall_set_return_value(struct task_struct *task,
 54					    struct pt_regs *regs,
 55					    int error, long val)
 56{
 57	regs->gprs[2] = error ? -error : val;
 58}
 59
 60static inline void syscall_get_arguments(struct task_struct *task,
 61					 struct pt_regs *regs,
 62					 unsigned int i, unsigned int n,
 63					 unsigned long *args)
 64{
 65	unsigned long mask = -1UL;
 66
 67	BUG_ON(i + n > 6);
 68#ifdef CONFIG_COMPAT
 69	if (test_tsk_thread_flag(task, TIF_31BIT))
 70		mask = 0xffffffff;
 71#endif
 72	while (n-- > 0)
 73		if (i + n > 0)
 74			args[n] = regs->gprs[2 + i + n] & mask;
 75	if (i == 0)
 76		args[0] = regs->orig_gpr2 & mask;
 77}
 78
 79static inline void syscall_set_arguments(struct task_struct *task,
 80					 struct pt_regs *regs,
 81					 unsigned int i, unsigned int n,
 82					 const unsigned long *args)
 83{
 84	BUG_ON(i + n > 6);
 85	while (n-- > 0)
 86		if (i + n > 0)
 87			regs->gprs[2 + i + n] = args[n];
 88	if (i == 0)
 89		regs->orig_gpr2 = args[0];
 90}
 91
 92static inline int syscall_get_arch(void)
 93{
 94#ifdef CONFIG_COMPAT
 95	if (test_tsk_thread_flag(current, TIF_31BIT))
 96		return AUDIT_ARCH_S390;
 97#endif
 98	return sizeof(long) == 8 ? AUDIT_ARCH_S390X : AUDIT_ARCH_S390;
 99}
100#endif	/* _ASM_SYSCALL_H */