2 /*--------------------------------------------------------------------*/
3 /*--- x86/Linux-specific kernel interface. vki-x86-linux.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2017 Julian Seward
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __VKI_X86_LINUX_H
30 #define __VKI_X86_LINUX_H
32 // x86 is little-endian.
33 #define VKI_LITTLE_ENDIAN 1
35 //----------------------------------------------------------------------
36 // From linux-2.6.8.1/include/asm-i386/types.h
37 //----------------------------------------------------------------------
39 typedef unsigned char __vki_u8
;
41 typedef __signed__
short __vki_s16
;
42 typedef unsigned short __vki_u16
;
44 typedef __signed__
int __vki_s32
;
45 typedef unsigned int __vki_u32
;
47 typedef __signed__
long long __vki_s64
;
48 typedef unsigned long long __vki_u64
;
50 typedef unsigned short vki_u16
;
52 typedef unsigned int vki_u32
;
54 //----------------------------------------------------------------------
55 // From linux-2.6.8.1/include/asm-i386/page.h
56 //----------------------------------------------------------------------
58 /* PAGE_SHIFT determines the page size */
59 #define VKI_PAGE_SHIFT 12
60 #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
61 #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
62 #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
64 //----------------------------------------------------------------------
65 // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
66 //----------------------------------------------------------------------
68 #define VKI_SHMLBA VKI_PAGE_SIZE
70 //----------------------------------------------------------------------
71 // From linux-2.6.8.1/include/asm-i386/signal.h
72 //----------------------------------------------------------------------
74 #define VKI_MINSIGSTKSZ 2048
76 #define VKI_SIG_BLOCK 0 /* for blocking signals */
77 #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
78 #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
80 /* Type of a signal handler. */
81 typedef void __vki_signalfn_t(int);
82 typedef __vki_signalfn_t __user
*__vki_sighandler_t
;
84 typedef void __vki_restorefn_t(void);
85 typedef __vki_restorefn_t __user
*__vki_sigrestore_t
;
87 #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
88 #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
91 #define _VKI_NSIG_BPW 32
92 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
94 typedef unsigned long vki_old_sigset_t
; /* at least 32 bits */
97 unsigned long sig
[_VKI_NSIG_WORDS
];
102 #define VKI_SIGQUIT 3
104 #define VKI_SIGTRAP 5
105 #define VKI_SIGABRT 6
106 //#define VKI_SIGIOT 6
109 #define VKI_SIGKILL 9
110 #define VKI_SIGUSR1 10
111 #define VKI_SIGSEGV 11
112 #define VKI_SIGUSR2 12
113 #define VKI_SIGPIPE 13
114 #define VKI_SIGALRM 14
115 #define VKI_SIGTERM 15
116 #define VKI_SIGSTKFLT 16
117 #define VKI_SIGCHLD 17
118 #define VKI_SIGCONT 18
119 #define VKI_SIGSTOP 19
120 #define VKI_SIGTSTP 20
121 #define VKI_SIGTTIN 21
122 #define VKI_SIGTTOU 22
123 #define VKI_SIGURG 23
124 #define VKI_SIGXCPU 24
125 #define VKI_SIGXFSZ 25
126 #define VKI_SIGVTALRM 26
127 #define VKI_SIGPROF 27
128 #define VKI_SIGWINCH 28
130 #define VKI_SIGPWR 30
131 #define VKI_SIGSYS 31
132 #define VKI_SIGUNUSED 31
134 /* These should not be considered constants from userland. */
135 #define VKI_SIGRTMIN 32
136 // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
137 #define VKI_SIGRTMAX _VKI_NSIG
139 #define VKI_SA_NOCLDSTOP 0x00000001u
140 #define VKI_SA_NOCLDWAIT 0x00000002u
141 #define VKI_SA_SIGINFO 0x00000004u
142 #define VKI_SA_ONSTACK 0x08000000u
143 #define VKI_SA_RESTART 0x10000000u
144 #define VKI_SA_NODEFER 0x40000000u
145 #define VKI_SA_RESETHAND 0x80000000u
147 #define VKI_SA_NOMASK VKI_SA_NODEFER
148 #define VKI_SA_ONESHOT VKI_SA_RESETHAND
149 //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */
151 #define VKI_SA_RESTORER 0x04000000
153 #define VKI_SS_ONSTACK 1
154 #define VKI_SS_DISABLE 2
156 /* These are 'legacy' sigactions in which the size of sa_mask is fixed
157 (cannot be expanded at any future point) because it is sandwiched
158 between two other fields.
159 (there is identical kludgery in vki-ppc32-linux.h) */
160 struct vki_old_sigaction
{
161 // [[Nb: a 'k' prefix is added to "sa_handler" because
162 // bits/sigaction.h (which gets dragged in somehow via signal.h)
163 // #defines it as something else. Since that is done for glibc's
164 // purposes, which we don't care about here, we use our own name.]]
165 __vki_sighandler_t ksa_handler
;
166 vki_old_sigset_t sa_mask
;
167 unsigned long sa_flags
;
168 __vki_sigrestore_t sa_restorer
;
171 struct vki_sigaction_base
{
172 // [[See comment about extra 'k' above]]
173 __vki_sighandler_t ksa_handler
;
174 unsigned long sa_flags
;
175 __vki_sigrestore_t sa_restorer
;
176 vki_sigset_t sa_mask
; /* mask last for extensibility */
179 /* On Linux we use the same type for passing sigactions to
180 and from the kernel. Hence: */
181 typedef struct vki_sigaction_base vki_sigaction_toK_t
;
182 typedef struct vki_sigaction_base vki_sigaction_fromK_t
;
185 typedef struct vki_sigaltstack
{
191 //----------------------------------------------------------------------
192 // From linux-2.6.8.1/include/asm-i386/sigcontext.h
193 //----------------------------------------------------------------------
196 unsigned short significand
[4];
197 unsigned short exponent
;
201 unsigned short significand
[4];
202 unsigned short exponent
;
203 unsigned short padding
[3];
207 unsigned long element
[4];
210 struct _vki_fpstate
{
211 /* Regular FPU environment */
217 unsigned long dataoff
;
218 unsigned long datasel
;
219 struct _vki_fpreg _st
[8];
220 unsigned short status
;
221 unsigned short magic
; /* 0xffff = regular FPU data only */
223 /* FXSR FPU environment */
224 unsigned long _fxsr_env
[6]; /* FXSR FPU env is ignored */
226 unsigned long reserved
;
227 struct _vki_fpxreg _fxsr_st
[8]; /* FXSR FPU reg data is ignored */
228 struct _vki_xmmreg _xmm
[8];
229 unsigned long padding
[56];
232 struct vki_sigcontext
{
233 unsigned short gs
, __gsh
;
234 unsigned short fs
, __fsh
;
235 unsigned short es
, __esh
;
236 unsigned short ds
, __dsh
;
245 unsigned long trapno
;
248 unsigned short cs
, __csh
;
249 unsigned long eflags
;
250 unsigned long esp_at_signal
;
251 unsigned short ss
, __ssh
;
252 struct _vki_fpstate __user
* fpstate
;
253 unsigned long oldmask
;
257 //----------------------------------------------------------------------
258 // From linux-2.6.8.1/include/asm-i386/mman.h
259 //----------------------------------------------------------------------
261 #define VKI_PROT_NONE 0x0 /* No page permissions */
262 #define VKI_PROT_READ 0x1 /* page can be read */
263 #define VKI_PROT_WRITE 0x2 /* page can be written */
264 #define VKI_PROT_EXEC 0x4 /* page can be executed */
265 #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
266 #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
268 #define VKI_MAP_SHARED 0x01 /* Share changes */
269 #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
270 //#define VKI_MAP_TYPE 0x0f /* Mask for type of mapping */
271 #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
272 #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
273 #define VKI_MAP_NORESERVE 0x4000 /* don't check for reservations */
275 //----------------------------------------------------------------------
276 // From linux-2.6.8.1/include/asm-i386/fcntl.h
277 //----------------------------------------------------------------------
279 #define VKI_O_ACCMODE 03
280 #define VKI_O_RDONLY 00
281 #define VKI_O_WRONLY 01
282 #define VKI_O_RDWR 02
283 #define VKI_O_CREAT 0100 /* not fcntl */
284 #define VKI_O_EXCL 0200 /* not fcntl */
285 #define VKI_O_TRUNC 01000 /* not fcntl */
286 #define VKI_O_APPEND 02000
287 #define VKI_O_NONBLOCK 04000
288 #define VKI_O_DIRECT 040000
289 #define VKI_O_LARGEFILE 0100000
291 #define VKI_AT_FDCWD -100
293 #define VKI_F_DUPFD 0 /* dup */
294 #define VKI_F_GETFD 1 /* get close_on_exec */
295 #define VKI_F_SETFD 2 /* set/clear close_on_exec */
296 #define VKI_F_GETFL 3 /* get file->f_flags */
297 #define VKI_F_SETFL 4 /* set file->f_flags */
298 #define VKI_F_GETLK 5
299 #define VKI_F_SETLK 6
300 #define VKI_F_SETLKW 7
302 #define VKI_F_SETOWN 8 /* for sockets. */
303 #define VKI_F_GETOWN 9 /* for sockets. */
304 #define VKI_F_SETSIG 10 /* for sockets. */
305 #define VKI_F_GETSIG 11 /* for sockets. */
307 #define VKI_F_GETLK64 12 /* using 'struct flock64' */
308 #define VKI_F_SETLK64 13
309 #define VKI_F_SETLKW64 14
311 #define VKI_F_SETOWN_EX 15
312 #define VKI_F_GETOWN_EX 16
314 #define VKI_F_OFD_GETLK 36
315 #define VKI_F_OFD_SETLK 37
316 #define VKI_F_OFD_SETLKW 38
318 #define VKI_F_OWNER_TID 0
319 #define VKI_F_OWNER_PID 1
320 #define VKI_F_OWNER_PGRP 2
322 struct vki_f_owner_ex
{
324 __vki_kernel_pid_t pid
;
327 /* for F_[GET|SET]FL */
328 #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
330 #define VKI_F_LINUX_SPECIFIC_BASE 1024
332 //----------------------------------------------------------------------
333 // From linux-2.6.8.1/include/asm-i386/resource.h
334 //----------------------------------------------------------------------
336 #define VKI_RLIMIT_DATA 2 /* max data size */
337 #define VKI_RLIMIT_STACK 3 /* max stack size */
338 #define VKI_RLIMIT_CORE 4 /* max core file size */
339 #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
341 //----------------------------------------------------------------------
342 // From linux-2.6.8.1/include/asm-i386/socket.h
343 //----------------------------------------------------------------------
345 #define VKI_SOL_SOCKET 1
347 #define VKI_SO_TYPE 3
349 #define VKI_SO_ATTACH_FILTER 26
351 //----------------------------------------------------------------------
352 // From linux-2.6.8.1/include/asm-i386/sockios.h
353 //----------------------------------------------------------------------
355 #define VKI_SIOCSPGRP 0x8902
356 #define VKI_SIOCGPGRP 0x8904
357 #define VKI_SIOCATMARK 0x8905
358 #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
359 #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
361 //----------------------------------------------------------------------
362 // From linux-2.6.8.1/include/asm-i386/stat.h
363 //----------------------------------------------------------------------
366 unsigned long st_dev
;
367 unsigned long st_ino
;
368 unsigned short st_mode
;
369 unsigned short st_nlink
;
370 unsigned short st_uid
;
371 unsigned short st_gid
;
372 unsigned long st_rdev
;
373 unsigned long st_size
;
374 unsigned long st_blksize
;
375 unsigned long st_blocks
;
376 unsigned long st_atime
;
377 unsigned long st_atime_nsec
;
378 unsigned long st_mtime
;
379 unsigned long st_mtime_nsec
;
380 unsigned long st_ctime
;
381 unsigned long st_ctime_nsec
;
382 unsigned long __unused4
;
383 unsigned long __unused5
;
387 unsigned long long st_dev
;
388 unsigned char __pad0
[4];
390 #define STAT64_HAS_BROKEN_ST_INO 1
391 unsigned long __st_ino
;
393 unsigned int st_mode
;
394 unsigned int st_nlink
;
396 unsigned long st_uid
;
397 unsigned long st_gid
;
399 unsigned long long st_rdev
;
400 unsigned char __pad3
[4];
403 unsigned long st_blksize
;
405 unsigned long st_blocks
; /* Number 512-byte blocks allocated. */
406 unsigned long __pad4
; /* future possible st_blocks high bits */
408 unsigned long st_atime
;
409 unsigned long st_atime_nsec
;
411 unsigned long st_mtime
;
412 unsigned int st_mtime_nsec
;
414 unsigned long st_ctime
;
415 unsigned long st_ctime_nsec
;
417 unsigned long long st_ino
;
420 //----------------------------------------------------------------------
421 // From linux-2.6.8.1/include/asm-i386/statfs.h
422 //----------------------------------------------------------------------
424 // [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
433 __vki_kernel_fsid_t f_fsid
;
436 __vki_u32 f_spare
[5];
439 //----------------------------------------------------------------------
440 // From linux-2.6.8.1/include/asm-i386/termios.h
441 //----------------------------------------------------------------------
444 unsigned short ws_row
;
445 unsigned short ws_col
;
446 unsigned short ws_xpixel
;
447 unsigned short ws_ypixel
;
452 unsigned short c_iflag
; /* input mode flags */
453 unsigned short c_oflag
; /* output mode flags */
454 unsigned short c_cflag
; /* control mode flags */
455 unsigned short c_lflag
; /* local mode flags */
456 unsigned char c_line
; /* line discipline */
457 unsigned char c_cc
[VKI_NCC
]; /* control characters */
461 //----------------------------------------------------------------------
462 // From linux-2.6.8.1/include/asm-i386/termbits.h
463 //----------------------------------------------------------------------
465 typedef unsigned char vki_cc_t
;
466 typedef unsigned int vki_tcflag_t
;
470 vki_tcflag_t c_iflag
; /* input mode flags */
471 vki_tcflag_t c_oflag
; /* output mode flags */
472 vki_tcflag_t c_cflag
; /* control mode flags */
473 vki_tcflag_t c_lflag
; /* local mode flags */
474 vki_cc_t c_line
; /* line discipline */
475 vki_cc_t c_cc
[VKI_NCCS
]; /* control characters */
478 //----------------------------------------------------------------------
479 // From linux-2.6.8.1/include/asm-i386/ioctl.h
480 //----------------------------------------------------------------------
482 #define _VKI_IOC_NRBITS 8
483 #define _VKI_IOC_TYPEBITS 8
484 #define _VKI_IOC_SIZEBITS 14
485 #define _VKI_IOC_DIRBITS 2
487 #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1)
488 #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1)
489 #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
490 #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
492 #define _VKI_IOC_NRSHIFT 0
493 #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
494 #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
495 #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
497 #define _VKI_IOC_NONE 0U
498 #define _VKI_IOC_WRITE 1U
499 #define _VKI_IOC_READ 2U
501 #define _VKI_IOC(dir,type,nr,size) \
502 (((dir) << _VKI_IOC_DIRSHIFT) | \
503 ((type) << _VKI_IOC_TYPESHIFT) | \
504 ((nr) << _VKI_IOC_NRSHIFT) | \
505 ((size) << _VKI_IOC_SIZESHIFT))
507 /* used to create numbers */
508 #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
509 #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
510 #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
511 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
513 /* used to decode ioctl numbers.. */
514 #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
515 #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
516 #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
517 #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
519 //----------------------------------------------------------------------
520 // From linux-2.6.8.1/include/asm-i386/ioctls.h
521 //----------------------------------------------------------------------
523 #define VKI_TCGETS 0x5401
524 #define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
525 #define VKI_TCSETSW 0x5403
526 #define VKI_TCSETSF 0x5404
527 #define VKI_TCGETA 0x5405
528 #define VKI_TCSETA 0x5406
529 #define VKI_TCSETAW 0x5407
530 #define VKI_TCSETAF 0x5408
531 #define VKI_TCSBRK 0x5409
532 #define VKI_TCXONC 0x540A
533 #define VKI_TCFLSH 0x540B
534 #define VKI_TIOCSCTTY 0x540E
535 #define VKI_TIOCGPGRP 0x540F
536 #define VKI_TIOCSPGRP 0x5410
537 #define VKI_TIOCOUTQ 0x5411
538 #define VKI_TIOCGWINSZ 0x5413
539 #define VKI_TIOCSWINSZ 0x5414
540 #define VKI_TIOCMGET 0x5415
541 #define VKI_TIOCMBIS 0x5416
542 #define VKI_TIOCMBIC 0x5417
543 #define VKI_TIOCMSET 0x5418
544 #define VKI_FIONREAD 0x541B
545 #define VKI_TIOCLINUX 0x541C
546 #define VKI_FIONBIO 0x5421
547 #define VKI_TIOCNOTTY 0x5422
548 #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
549 #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
550 #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
552 #define VKI_FIONCLEX 0x5450
553 #define VKI_FIOCLEX 0x5451
554 #define VKI_FIOASYNC 0x5452
555 #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
557 #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
559 //----------------------------------------------------------------------
560 // From linux-2.6.8.1/include/asm-i386/poll.h
561 //----------------------------------------------------------------------
563 /* These are specified by iBCS2 */
564 #define VKI_POLLIN 0x0001
572 //----------------------------------------------------------------------
573 // From linux-2.6.8.1/include/asm-i386/user.h
574 //----------------------------------------------------------------------
576 struct vki_user_i387_struct
{
584 long st_space
[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
587 struct vki_user_fxsr_struct
{
598 long st_space
[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
599 long xmm_space
[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
604 * This is the old layout of "struct pt_regs", and
605 * is still the layout used by user mode (the new
606 * pt_regs doesn't have all registers as the kernel
607 * doesn't use the extra segment registers)
609 struct vki_user_regs_struct
{
610 long ebx
, ecx
, edx
, esi
, edi
, ebp
, eax
;
611 unsigned short ds
, __ds
, es
, __es
;
612 unsigned short fs
, __fs
, gs
, __gs
;
614 unsigned short cs
, __cs
;
616 unsigned short ss
, __ss
;
619 //----------------------------------------------------------------------
620 // From linux-2.6.8.1/include/asm-i386/elf.h
621 //----------------------------------------------------------------------
623 typedef unsigned long vki_elf_greg_t
;
625 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
626 typedef vki_elf_greg_t vki_elf_gregset_t
[VKI_ELF_NGREG
];
628 typedef struct vki_user_i387_struct vki_elf_fpregset_t
;
629 typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t
;
631 #define VKI_AT_SYSINFO 32
633 //----------------------------------------------------------------------
634 // From linux-2.6.8.1/include/asm-i386/ucontext.h
635 //----------------------------------------------------------------------
637 struct vki_ucontext
{
638 unsigned long uc_flags
;
639 struct vki_ucontext
*uc_link
;
640 vki_stack_t uc_stack
;
641 struct vki_sigcontext uc_mcontext
;
642 vki_sigset_t uc_sigmask
; /* mask last for extensibility */
645 //----------------------------------------------------------------------
646 // From linux-2.6.8.1/include/asm-i386/segment.h
647 //----------------------------------------------------------------------
649 #define VKI_GDT_ENTRY_TLS_ENTRIES 3
650 #define VKI_GDT_ENTRY_TLS_MIN 6
651 #define VKI_GDT_ENTRY_TLS_MAX (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
653 //----------------------------------------------------------------------
654 // From linux-2.6.8.1/include/asm-i386/ldt.h
655 //----------------------------------------------------------------------
657 /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as
658 to confuse and annoy everyone, this is _not_ the same as an
659 VgLdtEntry and has to be translated into such. The logic for doing
660 so, in vg_ldt.c, is copied from the kernel sources.]] */
661 struct vki_user_desc
{
662 unsigned int entry_number
;
663 unsigned long base_addr
;
665 unsigned int seg_32bit
:1;
666 unsigned int contents
:2;
667 unsigned int read_exec_only
:1;
668 unsigned int limit_in_pages
:1;
669 unsigned int seg_not_present
:1;
670 unsigned int useable
:1;
671 // [[Nb: this field is not in the kernel sources, but it has always
672 // been in the Valgrind sources so I will keep it there in case it's
673 // important... this is an x86-defined data structure so who
674 // knows; maybe it's important to set this field to zero at some
676 unsigned int reserved
:25;
679 // [[Nb: for our convenience within Valgrind, use a more specific name]]
680 typedef struct vki_user_desc vki_modify_ldt_t
;
682 //----------------------------------------------------------------------
683 // From linux-2.6.8.1/include/asm-i386/ipcbuf.h
684 //----------------------------------------------------------------------
686 struct vki_ipc64_perm
688 __vki_kernel_key_t key
;
689 __vki_kernel_uid32_t uid
;
690 __vki_kernel_gid32_t gid
;
691 __vki_kernel_uid32_t cuid
;
692 __vki_kernel_gid32_t cgid
;
693 __vki_kernel_mode_t mode
;
694 unsigned short __pad1
;
696 unsigned short __pad2
;
697 unsigned long __unused1
;
698 unsigned long __unused2
;
701 //----------------------------------------------------------------------
702 // From linux-2.6.8.1/include/asm-i386/sembuf.h
703 //----------------------------------------------------------------------
705 struct vki_semid64_ds
{
706 struct vki_ipc64_perm sem_perm
; /* permissions .. see ipc.h */
707 __vki_kernel_time_t sem_otime
; /* last semop time */
708 unsigned long __unused1
;
709 __vki_kernel_time_t sem_ctime
; /* last change time */
710 unsigned long __unused2
;
711 unsigned long sem_nsems
; /* no. of semaphores in array */
712 unsigned long __unused3
;
713 unsigned long __unused4
;
716 //----------------------------------------------------------------------
717 // From linux-2.6.8.1/include/asm-i386/msgbuf.h
718 //----------------------------------------------------------------------
720 struct vki_msqid64_ds
{
721 struct vki_ipc64_perm msg_perm
;
722 __vki_kernel_time_t msg_stime
; /* last msgsnd time */
723 unsigned long __unused1
;
724 __vki_kernel_time_t msg_rtime
; /* last msgrcv time */
725 unsigned long __unused2
;
726 __vki_kernel_time_t msg_ctime
; /* last change time */
727 unsigned long __unused3
;
728 unsigned long msg_cbytes
; /* current number of bytes on queue */
729 unsigned long msg_qnum
; /* number of messages in queue */
730 unsigned long msg_qbytes
; /* max number of bytes on queue */
731 __vki_kernel_pid_t msg_lspid
; /* pid of last msgsnd */
732 __vki_kernel_pid_t msg_lrpid
; /* last receive pid */
733 unsigned long __unused4
;
734 unsigned long __unused5
;
737 //----------------------------------------------------------------------
738 // From linux-2.6.8.1/include/asm-i386/ipc.h
739 //----------------------------------------------------------------------
741 struct vki_ipc_kludge
{
742 struct vki_msgbuf __user
*msgp
;
749 #define VKI_SEMTIMEDOP 4
750 #define VKI_MSGSND 11
751 #define VKI_MSGRCV 12
752 #define VKI_MSGGET 13
753 #define VKI_MSGCTL 14
756 #define VKI_SHMGET 23
757 #define VKI_SHMCTL 24
760 //----------------------------------------------------------------------
761 // From linux-2.6.8.1/include/asm-i386/shmbuf.h
762 //----------------------------------------------------------------------
764 struct vki_shmid64_ds
{
765 struct vki_ipc64_perm shm_perm
; /* operation perms */
766 vki_size_t shm_segsz
; /* size of segment (bytes) */
767 __vki_kernel_time_t shm_atime
; /* last attach time */
768 unsigned long __unused1
;
769 __vki_kernel_time_t shm_dtime
; /* last detach time */
770 unsigned long __unused2
;
771 __vki_kernel_time_t shm_ctime
; /* last change time */
772 unsigned long __unused3
;
773 __vki_kernel_pid_t shm_cpid
; /* pid of creator */
774 __vki_kernel_pid_t shm_lpid
; /* pid of last operator */
775 unsigned long shm_nattch
; /* no. of current attaches */
776 unsigned long __unused4
;
777 unsigned long __unused5
;
780 struct vki_shminfo64
{
781 unsigned long shmmax
;
782 unsigned long shmmin
;
783 unsigned long shmmni
;
784 unsigned long shmseg
;
785 unsigned long shmall
;
786 unsigned long __unused1
;
787 unsigned long __unused2
;
788 unsigned long __unused3
;
789 unsigned long __unused4
;
792 //----------------------------------------------------------------------
794 //----------------------------------------------------------------------
796 // jrs 20050207: where did all this stuff come from? Is it really
797 // i386 specific, or should it go into the linux-generic category?
798 //struct vki_drm_buf_pub {
799 // Int idx; /**< Index into the master buffer list */
800 // Int total; /**< Buffer size */
801 // Int used; /**< Amount of buffer in use (for DMA) */
802 // void __user *address; /**< Address of buffer */
805 //struct vki_drm_buf_map {
806 // Int count; /**< Length of the buffer list */
807 // void __user *virtual; /**< Mmap'd area in user-virtual */
808 // struct vki_drm_buf_pub __user *list; /**< Buffer information */
811 ///* We need to pay attention to this, because it mmaps memory */
812 //#define VKI_DRM_IOCTL_MAP_BUFS _VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
814 //----------------------------------------------------------------------
815 // From linux-2.6.9/include/asm-i386/ptrace.h
816 //----------------------------------------------------------------------
818 #define VKI_PTRACE_GETREGS 12
819 #define VKI_PTRACE_SETREGS 13
820 #define VKI_PTRACE_GETFPREGS 14
821 #define VKI_PTRACE_SETFPREGS 15
822 #define VKI_PTRACE_GETFPXREGS 18
823 #define VKI_PTRACE_SETFPXREGS 19
824 #define VKI_PTRACE_GET_THREAD_AREA 25
825 #define VKI_PTRACE_SET_THREAD_AREA 26
827 //----------------------------------------------------------------------
828 // From linux-2.6.15.4/include/asm-i386/vm86.h
829 //----------------------------------------------------------------------
831 #define VKI_VM86_PLUS_INSTALL_CHECK 0
832 #define VKI_VM86_ENTER 1
833 #define VKI_VM86_ENTER_NO_BYPASS 2
834 #define VKI_VM86_REQUEST_IRQ 3
835 #define VKI_VM86_FREE_IRQ 4
836 #define VKI_VM86_GET_IRQ_BITS 5
837 #define VKI_VM86_GET_AND_RESET_IRQ 6
839 struct vki_vm86_regs
{
841 * normal regs, with special meaning for the segment descriptors..
856 unsigned short cs
, __csh
;
859 unsigned short ss
, __ssh
;
861 * these are specific to v86 mode:
863 unsigned short es
, __esh
;
864 unsigned short ds
, __dsh
;
865 unsigned short fs
, __fsh
;
866 unsigned short gs
, __gsh
;
869 struct vki_revectored_struct
{
870 unsigned long __map
[8]; /* 256 bits */
873 struct vki_vm86_struct
{
874 struct vki_vm86_regs regs
;
876 unsigned long screen_bitmap
;
877 unsigned long cpu_type
;
878 struct vki_revectored_struct int_revectored
;
879 struct vki_revectored_struct int21_revectored
;
882 struct vki_vm86plus_info_struct
{
883 unsigned long force_return_for_pic
:1;
884 unsigned long vm86dbg_active
:1; /* for debugger */
885 unsigned long vm86dbg_TFpendig
:1; /* for debugger */
886 unsigned long unused
:28;
887 unsigned long is_vm86pus
:1; /* for vm86 internal use */
888 unsigned char vm86dbg_intxxtab
[32]; /* for debugger */
891 struct vki_vm86plus_struct
{
892 struct vki_vm86_regs regs
;
894 unsigned long screen_bitmap
;
895 unsigned long cpu_type
;
896 struct vki_revectored_struct int_revectored
;
897 struct vki_revectored_struct int21_revectored
;
898 struct vki_vm86plus_info_struct vm86plus
;
901 //----------------------------------------------------------------------
902 // From linux-2.6.8.1/include/asm-generic/errno.h
903 //----------------------------------------------------------------------
905 #define VKI_ENOSYS 38 /* Function not implemented */
906 #define VKI_EOVERFLOW 75 /* Value too large for defined data type */
908 //----------------------------------------------------------------------
909 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
910 //----------------------------------------------------------------------
912 #define VKI_TIOCGSERIAL 0x541E
913 #define VKI_TIOCSSERIAL 0x541F
915 //----------------------------------------------------------------------
917 //----------------------------------------------------------------------
919 #endif // __VKI_X86_LINUX_H
921 /*--------------------------------------------------------------------*/
923 /*--------------------------------------------------------------------*/