Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/amd64/linux/linux.h
39507 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause
3
*
4
* Copyright (c) 1994-1996 Søren Schmidt
5
* All rights reserved.
6
* Copyright (c) 2013 Dmitry Chagin <[email protected]>
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
#ifndef _AMD64_LINUX_H_
31
#define _AMD64_LINUX_H_
32
33
#include <sys/abi_compat.h>
34
35
#include <compat/linux/linux.h>
36
#include <amd64/linux/linux_syscall.h>
37
38
#define LINUX_LEGACY_SYSCALLS
39
40
#define LINUX_DTRACE linuxulator
41
42
/*
43
* Provide a separate set of types for the Linux types.
44
*/
45
typedef int32_t l_int;
46
typedef int64_t l_long;
47
typedef int16_t l_short;
48
typedef uint32_t l_uint;
49
typedef uint64_t l_ulong;
50
typedef uint16_t l_ushort;
51
52
typedef l_ulong l_uintptr_t;
53
typedef l_long l_clock_t;
54
typedef l_int l_daddr_t;
55
typedef l_uint l_gid_t;
56
typedef l_ushort l_gid16_t;
57
typedef l_uint l_uid_t;
58
typedef l_ushort l_uid16_t;
59
typedef l_ulong l_ino_t;
60
typedef l_int l_key_t;
61
typedef l_long l_loff_t;
62
typedef l_uint l_mode_t;
63
typedef l_long l_off_t;
64
typedef l_int l_pid_t;
65
typedef l_ulong l_size_t;
66
typedef l_long l_ssize_t;
67
typedef l_long l_suseconds_t;
68
typedef l_long l_time_t;
69
typedef l_int l_timer_t;
70
typedef l_int l_mqd_t;
71
typedef l_size_t l_socklen_t;
72
typedef l_ulong l_fd_mask;
73
74
#include <compat/linux/linux_siginfo.h>
75
76
typedef struct {
77
l_int val[2];
78
} l_fsid_t;
79
80
typedef struct {
81
l_time_t tv_sec;
82
l_suseconds_t tv_usec;
83
} l_timeval;
84
85
#define l_fd_set fd_set
86
87
/*
88
* Miscellaneous
89
*/
90
#define LINUX_AT_COUNT 21 /* Count of used aux entry types.
91
* Keep this synchronized with
92
* linux_copyout_auxargs() code.
93
*/
94
95
struct l___sysctl_args
96
{
97
l_uintptr_t name;
98
l_int nlen;
99
l_uintptr_t oldval;
100
l_uintptr_t oldlenp;
101
l_uintptr_t newval;
102
l_size_t newlen;
103
l_ulong __spare[4];
104
};
105
106
/* Resource limits */
107
#define LINUX_RLIMIT_CPU 0
108
#define LINUX_RLIMIT_FSIZE 1
109
#define LINUX_RLIMIT_DATA 2
110
#define LINUX_RLIMIT_STACK 3
111
#define LINUX_RLIMIT_CORE 4
112
#define LINUX_RLIMIT_RSS 5
113
#define LINUX_RLIMIT_NPROC 6
114
#define LINUX_RLIMIT_NOFILE 7
115
#define LINUX_RLIMIT_MEMLOCK 8
116
#define LINUX_RLIMIT_AS 9 /* Address space limit */
117
118
#define LINUX_RLIM_NLIMITS 10
119
120
struct l_rlimit {
121
l_ulong rlim_cur;
122
l_ulong rlim_max;
123
};
124
125
/*
126
* stat family of syscalls
127
*/
128
struct l_timespec {
129
l_time_t tv_sec;
130
l_long tv_nsec;
131
};
132
133
struct l_newstat {
134
l_ulong st_dev;
135
l_ino_t st_ino;
136
l_ulong st_nlink;
137
l_uint st_mode;
138
l_uid_t st_uid;
139
l_gid_t st_gid;
140
l_uint __st_pad0;
141
l_ulong st_rdev;
142
l_off_t st_size;
143
l_long st_blksize;
144
l_long st_blocks;
145
struct l_timespec st_atim;
146
struct l_timespec st_mtim;
147
struct l_timespec st_ctim;
148
l_long __unused1;
149
l_long __unused2;
150
l_long __unused3;
151
};
152
153
/* sigaction flags */
154
#define LINUX_SA_NOCLDSTOP 0x00000001
155
#define LINUX_SA_NOCLDWAIT 0x00000002
156
#define LINUX_SA_SIGINFO 0x00000004
157
#define LINUX_SA_RESTORER 0x04000000
158
#define LINUX_SA_ONSTACK 0x08000000
159
#define LINUX_SA_RESTART 0x10000000
160
#define LINUX_SA_INTERRUPT 0x20000000
161
#define LINUX_SA_NOMASK 0x40000000
162
#define LINUX_SA_ONESHOT 0x80000000
163
164
/* sigaltstack */
165
#define LINUX_MINSIGSTKSZ 2048
166
167
typedef void (*l_handler_t)(l_int);
168
169
typedef struct {
170
l_handler_t lsa_handler;
171
l_ulong lsa_flags;
172
l_uintptr_t lsa_restorer;
173
l_sigset_t lsa_mask;
174
} l_sigaction_t;
175
176
typedef struct {
177
l_uintptr_t ss_sp;
178
l_int ss_flags;
179
l_size_t ss_size;
180
} l_stack_t;
181
182
/*
183
* mount flags
184
*/
185
#define LINUX_MS_RDONLY 0x0001
186
#define LINUX_MS_NOSUID 0x0002
187
#define LINUX_MS_NODEV 0x0004
188
#define LINUX_MS_NOEXEC 0x0008
189
#define LINUX_MS_REMOUNT 0x0020
190
191
union l_semun {
192
l_int val;
193
l_uintptr_t buf;
194
l_uintptr_t array;
195
l_uintptr_t __buf;
196
l_uintptr_t __pad;
197
};
198
199
#define LINUX_ARCH_SET_GS 0x1001
200
#define LINUX_ARCH_SET_FS 0x1002
201
#define LINUX_ARCH_GET_FS 0x1003
202
#define LINUX_ARCH_GET_GS 0x1004
203
#define LINUX_ARCH_CET_STATUS 0x3001
204
205
#define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r))
206
207
/* This corresponds to 'struct user_regs_struct' in Linux. */
208
struct linux_pt_regset {
209
l_ulong r15;
210
l_ulong r14;
211
l_ulong r13;
212
l_ulong r12;
213
l_ulong rbp;
214
l_ulong rbx;
215
l_ulong r11;
216
l_ulong r10;
217
l_ulong r9;
218
l_ulong r8;
219
l_ulong rax;
220
l_ulong rcx;
221
l_ulong rdx;
222
l_ulong rsi;
223
l_ulong rdi;
224
l_ulong orig_rax;
225
l_ulong rip;
226
l_ulong cs;
227
l_ulong eflags;
228
l_ulong rsp;
229
l_ulong ss;
230
l_ulong fs_base;
231
l_ulong gs_base;
232
l_ulong ds;
233
l_ulong es;
234
l_ulong fs;
235
l_ulong gs;
236
};
237
238
#ifdef _KERNEL
239
struct reg;
240
struct syscall_info;
241
242
void bsd_to_linux_regset(const struct reg *b_reg,
243
struct linux_pt_regset *l_regset);
244
void linux_to_bsd_regset(struct reg *b_reg,
245
const struct linux_pt_regset *l_regset);
246
void linux_ptrace_get_syscall_info_machdep(const struct reg *reg,
247
struct syscall_info *si);
248
int linux_ptrace_getregs_machdep(struct thread *td, pid_t pid,
249
struct linux_pt_regset *l_regset);
250
int linux_ptrace_peekuser(struct thread *td, pid_t pid,
251
void *addr, void *data);
252
int linux_ptrace_pokeuser(struct thread *td, pid_t pid,
253
void *addr, void *data);
254
#endif /* _KERNEL */
255
256
#endif /* !_AMD64_LINUX_H_ */
257
258