Home | History | Annotate | Download | only in vki
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- AMD64/Linux-specific kernel interface.     vki-amd64-linux.h ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2000-2015 Julian Seward
     11       jseward (at) acm.org
     12 
     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.
     17 
     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.
     22 
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     26    02111-1307, USA.
     27 
     28    The GNU General Public License is contained in the file COPYING.
     29 */
     30 
     31 #ifndef __VKI_AMD64_LINUX_H
     32 #define __VKI_AMD64_LINUX_H
     33 
     34 // AMD64 is little-endian.
     35 #define VKI_LITTLE_ENDIAN  1
     36 
     37 //----------------------------------------------------------------------
     38 // From linux-2.6.9/include/asm-x86_64/types.h
     39 //----------------------------------------------------------------------
     40 
     41 typedef unsigned char __vki_u8;
     42 
     43 typedef __signed__ short __vki_s16;
     44 typedef unsigned short __vki_u16;
     45 
     46 typedef __signed__ int __vki_s32;
     47 typedef unsigned int __vki_u32;
     48 
     49 typedef __signed__ long long __vki_s64;
     50 typedef unsigned long long __vki_u64;
     51 
     52 typedef unsigned short vki_u16;
     53 
     54 typedef unsigned int vki_u32;
     55 
     56 //----------------------------------------------------------------------
     57 // From linux-2.6.9/include/asm-x86_64/page.h
     58 //----------------------------------------------------------------------
     59 
     60 #define VKI_PAGE_SHIFT	12
     61 #define VKI_PAGE_SIZE	(1UL << VKI_PAGE_SHIFT)
     62 #define VKI_MAX_PAGE_SHIFT	VKI_PAGE_SHIFT
     63 #define VKI_MAX_PAGE_SIZE	VKI_PAGE_SIZE
     64 
     65 //----------------------------------------------------------------------
     66 // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
     67 //----------------------------------------------------------------------
     68 
     69 #define VKI_SHMLBA  VKI_PAGE_SIZE
     70 
     71 //----------------------------------------------------------------------
     72 // From linux-2.6.9/include/asm-x86_64/signal.h
     73 //----------------------------------------------------------------------
     74 
     75 #define _VKI_NSIG	64
     76 #define _VKI_NSIG_BPW	64
     77 #define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
     78 
     79 typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
     80 
     81 typedef struct {
     82 	unsigned long sig[_VKI_NSIG_WORDS];
     83 } vki_sigset_t;
     84 
     85 #define VKI_SIGHUP		 1
     86 #define VKI_SIGINT		 2
     87 #define VKI_SIGQUIT		 3
     88 #define VKI_SIGILL		 4
     89 #define VKI_SIGTRAP		 5
     90 #define VKI_SIGABRT		 6
     91 #define VKI_SIGBUS		 7
     92 #define VKI_SIGFPE		 8
     93 #define VKI_SIGKILL		 9
     94 #define VKI_SIGUSR1		10
     95 #define VKI_SIGSEGV		11
     96 #define VKI_SIGUSR2		12
     97 #define VKI_SIGPIPE		13
     98 #define VKI_SIGALRM		14
     99 #define VKI_SIGTERM		15
    100 #define VKI_SIGSTKFLT		16
    101 #define VKI_SIGCHLD		17
    102 #define VKI_SIGCONT		18
    103 #define VKI_SIGSTOP		19
    104 #define VKI_SIGTSTP		20
    105 #define VKI_SIGTTIN		21
    106 #define VKI_SIGTTOU		22
    107 #define VKI_SIGURG		23
    108 #define VKI_SIGXCPU		24
    109 #define VKI_SIGXFSZ		25
    110 #define VKI_SIGVTALRM		26
    111 #define VKI_SIGPROF		27
    112 #define VKI_SIGWINCH		28
    113 #define VKI_SIGIO		29
    114 #define VKI_SIGPWR		30
    115 #define VKI_SIGSYS		31
    116 #define	VKI_SIGUNUSED		31
    117 
    118 #define VKI_SIGRTMIN		32
    119 #define VKI_SIGRTMAX		_VKI_NSIG
    120 
    121 #define VKI_SA_NOCLDSTOP	0x00000001
    122 #define VKI_SA_NOCLDWAIT	0x00000002
    123 #define VKI_SA_SIGINFO		0x00000004
    124 #define VKI_SA_ONSTACK		0x08000000
    125 #define VKI_SA_RESTART		0x10000000
    126 #define VKI_SA_NODEFER		0x40000000
    127 #define VKI_SA_RESETHAND	0x80000000
    128 
    129 #define VKI_SA_NOMASK	VKI_SA_NODEFER
    130 #define VKI_SA_ONESHOT	VKI_SA_RESETHAND
    131 
    132 #define VKI_SA_RESTORER	0x04000000
    133 
    134 #define VKI_SS_ONSTACK	1
    135 #define VKI_SS_DISABLE	2
    136 
    137 #define VKI_MINSIGSTKSZ	2048
    138 
    139 #define VKI_SIG_BLOCK          0	/* for blocking signals */
    140 #define VKI_SIG_UNBLOCK        1	/* for unblocking signals */
    141 #define VKI_SIG_SETMASK        2	/* for setting the signal mask */
    142 
    143 typedef void __vki_signalfn_t(int);
    144 typedef __vki_signalfn_t __user *__vki_sighandler_t;
    145 
    146 typedef void __vki_restorefn_t(void);
    147 typedef __vki_restorefn_t __user *__vki_sigrestore_t;
    148 
    149 #define VKI_SIG_DFL	((__vki_sighandler_t)0)	/* default signal handling */
    150 #define VKI_SIG_IGN	((__vki_sighandler_t)1)	/* ignore signal */
    151 
    152 struct vki_sigaction_base {
    153         // [[Nb: a 'k' prefix is added to "sa_handler" because
    154         // bits/sigaction.h (which gets dragged in somehow via signal.h)
    155         // #defines it as something else.  Since that is done for glibc's
    156         // purposes, which we don't care about here, we use our own name.]]
    157 	__vki_sighandler_t ksa_handler;
    158 	unsigned long sa_flags;
    159 	__vki_sigrestore_t sa_restorer;
    160 	vki_sigset_t sa_mask;		/* mask last for extensibility */
    161 };
    162 
    163 /* On Linux we use the same type for passing sigactions to
    164    and from the kernel.  Hence: */
    165 typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
    166 typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
    167 
    168 
    169 typedef struct vki_sigaltstack {
    170 	void __user *ss_sp;
    171 	int ss_flags;
    172 	vki_size_t ss_size;
    173 } vki_stack_t;
    174 
    175 //----------------------------------------------------------------------
    176 // From linux-2.6.9/include/asm-x86_64/sigcontext.h
    177 //----------------------------------------------------------------------
    178 
    179 struct _vki_fpstate {
    180 	__vki_u16	cwd;
    181 	__vki_u16	swd;
    182 	__vki_u16	twd;	/* Note this is not the same as the 32bit/x87/FSAVE twd */
    183 	__vki_u16	fop;
    184 	__vki_u64	rip;
    185 	__vki_u64	rdp;
    186 	__vki_u32	mxcsr;
    187 	__vki_u32	mxcsr_mask;
    188 	__vki_u32	st_space[32];	/* 8*16 bytes for each FP-reg */
    189 	__vki_u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg  */
    190 	__vki_u32	reserved2[24];
    191 };
    192 
    193 struct vki_sigcontext {
    194 	unsigned long r8;
    195 	unsigned long r9;
    196 	unsigned long r10;
    197 	unsigned long r11;
    198 	unsigned long r12;
    199 	unsigned long r13;
    200 	unsigned long r14;
    201 	unsigned long r15;
    202 	unsigned long rdi;
    203 	unsigned long rsi;
    204 	unsigned long rbp;
    205 	unsigned long rbx;
    206 	unsigned long rdx;
    207 	unsigned long rax;
    208 	unsigned long rcx;
    209 	unsigned long rsp;
    210 	unsigned long rip;
    211 	unsigned long eflags;		/* RFLAGS */
    212 	unsigned short cs;
    213 	unsigned short gs;
    214 	unsigned short fs;
    215 	unsigned short __pad0;
    216 	unsigned long err;
    217 	unsigned long trapno;
    218 	unsigned long oldmask;
    219 	unsigned long cr2;
    220 	struct _vki_fpstate __user *fpstate;	/* zero when no FPU context */
    221 	unsigned long reserved1[8];
    222 };
    223 
    224 //----------------------------------------------------------------------
    225 // From linux-2.6.9/include/asm-x86_64/mman.h
    226 //----------------------------------------------------------------------
    227 
    228 #define VKI_PROT_READ	0x1		/* page can be read */
    229 #define VKI_PROT_WRITE	0x2		/* page can be written */
    230 #define VKI_PROT_EXEC	0x4		/* page can be executed */
    231 #define VKI_PROT_NONE	0x0		/* page can not be accessed */
    232 #define VKI_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
    233 #define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
    234 
    235 #define VKI_MAP_SHARED	0x01		/* Share changes */
    236 #define VKI_MAP_PRIVATE	0x02		/* Changes are private */
    237 #define VKI_MAP_FIXED	0x10		/* Interpret addr exactly */
    238 #define VKI_MAP_ANONYMOUS	0x20	/* don't use a file */
    239 #define VKI_MAP_32BIT	0x40		/* only give out 32bit addresses */
    240 #define VKI_MAP_NORESERVE       0x4000  /* don't check for reservations */
    241 
    242 //----------------------------------------------------------------------
    243 // From linux-2.6.9/include/asm-x86_64/fcntl.h
    244 //----------------------------------------------------------------------
    245 
    246 #define VKI_O_ACCMODE	     03
    247 #define VKI_O_RDONLY	     00
    248 #define VKI_O_WRONLY	     01
    249 #define VKI_O_RDWR	     02
    250 #define VKI_O_CREAT	   0100	/* not fcntl */
    251 #define VKI_O_EXCL	   0200	/* not fcntl */
    252 #define VKI_O_TRUNC	  01000	/* not fcntl */
    253 #define VKI_O_APPEND	  02000
    254 #define VKI_O_NONBLOCK	  04000
    255 #define VKI_O_LARGEFILE	0100000
    256 
    257 #define VKI_AT_FDCWD            -100
    258 
    259 #define VKI_F_DUPFD		0	/* dup */
    260 #define VKI_F_GETFD		1	/* get close_on_exec */
    261 #define VKI_F_SETFD		2	/* set/clear close_on_exec */
    262 #define VKI_F_GETFL		3	/* get file->f_flags */
    263 #define VKI_F_SETFL		4	/* set file->f_flags */
    264 #define VKI_F_GETLK		5
    265 #define VKI_F_SETLK		6
    266 #define VKI_F_SETLKW		7
    267 
    268 #define VKI_F_SETOWN		8	/*  for sockets. */
    269 #define VKI_F_GETOWN		9	/*  for sockets. */
    270 #define VKI_F_SETSIG		10	/*  for sockets. */
    271 #define VKI_F_GETSIG		11	/*  for sockets. */
    272 
    273 #define VKI_F_SETOWN_EX		15
    274 #define VKI_F_GETOWN_EX		16
    275 
    276 #define VKI_F_OFD_GETLK		36
    277 #define VKI_F_OFD_SETLK		37
    278 #define VKI_F_OFD_SETLKW	38
    279 
    280 #define VKI_F_OWNER_TID		0
    281 #define VKI_F_OWNER_PID		1
    282 #define VKI_F_OWNER_PGRP	2
    283 
    284 struct vki_f_owner_ex {
    285 	int	type;
    286 	__vki_kernel_pid_t	pid;
    287 };
    288 
    289 #define VKI_FD_CLOEXEC	1	/* actually anything with low bit set goes */
    290 
    291 #define VKI_F_LINUX_SPECIFIC_BASE	1024
    292 
    293 //----------------------------------------------------------------------
    294 // From linux-2.6.9/include/asm-x86_64/resource.h
    295 //----------------------------------------------------------------------
    296 
    297 #define VKI_RLIMIT_DATA		2	/* max data size */
    298 #define VKI_RLIMIT_STACK	3	/* max stack size */
    299 #define VKI_RLIMIT_CORE		4	/* max core file size */
    300 #define VKI_RLIMIT_NOFILE	7	/* max number of open files */
    301 
    302 //----------------------------------------------------------------------
    303 // From linux-2.6.9/include/asm-x86_64/socket.h
    304 //----------------------------------------------------------------------
    305 
    306 #define VKI_SOL_SOCKET	1
    307 
    308 #define VKI_SO_TYPE	3
    309 
    310 #define VKI_SO_ATTACH_FILTER	26
    311 
    312 //----------------------------------------------------------------------
    313 // From linux-2.6.9/include/asm-x86_64/sockios.h
    314 //----------------------------------------------------------------------
    315 
    316 #define VKI_SIOCSPGRP		0x8902
    317 #define VKI_SIOCGPGRP		0x8904
    318 #define VKI_SIOCATMARK		0x8905
    319 #define VKI_SIOCGSTAMP		0x8906		/* Get stamp (timeval) */
    320 #define VKI_SIOCGSTAMPNS	0x8907		/* Get stamp (timespec) */
    321 
    322 //----------------------------------------------------------------------
    323 // From linux-2.6.9/include/asm-x86_64/stat.h
    324 //----------------------------------------------------------------------
    325 
    326 struct vki_stat {
    327 	unsigned long	st_dev;
    328 	unsigned long	st_ino;
    329 	unsigned long	st_nlink;
    330 
    331 	unsigned int	st_mode;
    332 	unsigned int	st_uid;
    333 	unsigned int	st_gid;
    334 	unsigned int	__pad0;
    335 	unsigned long	st_rdev;
    336 	long		st_size;
    337 	long		st_blksize;
    338 	long		st_blocks;	/* Number 512-byte blocks allocated. */
    339 
    340 	unsigned long	st_atime;
    341 	unsigned long 	st_atime_nsec;
    342 	unsigned long	st_mtime;
    343 	unsigned long	st_mtime_nsec;
    344 	unsigned long	st_ctime;
    345 	unsigned long   st_ctime_nsec;
    346   	long		__unused0[3];
    347 };
    348 
    349 //----------------------------------------------------------------------
    350 // From linux-2.6.9/include/asm-x86_64/statfs.h
    351 //----------------------------------------------------------------------
    352 
    353 struct vki_statfs {
    354 	long f_type;
    355 	long f_bsize;
    356 	long f_blocks;
    357 	long f_bfree;
    358 	long f_bavail;
    359 	long f_files;
    360 	long f_ffree;
    361 	__vki_kernel_fsid_t f_fsid;
    362 	long f_namelen;
    363 	long f_frsize;
    364 	long f_spare[5];
    365 };
    366 
    367 //----------------------------------------------------------------------
    368 // From linux-2.6.9/include/asm-x86_64/termios.h
    369 //----------------------------------------------------------------------
    370 
    371 struct vki_winsize {
    372 	unsigned short ws_row;
    373 	unsigned short ws_col;
    374 	unsigned short ws_xpixel;
    375 	unsigned short ws_ypixel;
    376 };
    377 
    378 #define VKI_NCC 8
    379 struct vki_termio {
    380 	unsigned short c_iflag;		/* input mode flags */
    381 	unsigned short c_oflag;		/* output mode flags */
    382 	unsigned short c_cflag;		/* control mode flags */
    383 	unsigned short c_lflag;		/* local mode flags */
    384 	unsigned char c_line;		/* line discipline */
    385 	unsigned char c_cc[VKI_NCC];	/* control characters */
    386 };
    387 
    388 //----------------------------------------------------------------------
    389 // From linux-2.6.9/include/asm-x86_64/termbits.h
    390 //----------------------------------------------------------------------
    391 
    392 typedef unsigned char	vki_cc_t;
    393 typedef unsigned int	vki_tcflag_t;
    394 
    395 #define VKI_NCCS 19
    396 struct vki_termios {
    397 	vki_tcflag_t c_iflag;		/* input mode flags */
    398 	vki_tcflag_t c_oflag;		/* output mode flags */
    399 	vki_tcflag_t c_cflag;		/* control mode flags */
    400 	vki_tcflag_t c_lflag;		/* local mode flags */
    401 	vki_cc_t c_line;		/* line discipline */
    402 	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
    403 };
    404 
    405 
    406 //----------------------------------------------------------------------
    407 // From linux-2.6.9/include/asm-x86_64/ioctl.h
    408 //----------------------------------------------------------------------
    409 
    410 #define _VKI_IOC_NRBITS		8
    411 #define _VKI_IOC_TYPEBITS	8
    412 #define _VKI_IOC_SIZEBITS	14
    413 #define _VKI_IOC_DIRBITS	2
    414 
    415 #define _VKI_IOC_SIZEMASK	((1 << _VKI_IOC_SIZEBITS)-1)
    416 #define _VKI_IOC_DIRMASK	((1 << _VKI_IOC_DIRBITS)-1)
    417 
    418 #define _VKI_IOC_NRSHIFT	0
    419 #define _VKI_IOC_TYPESHIFT	(_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
    420 #define _VKI_IOC_SIZESHIFT	(_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
    421 #define _VKI_IOC_DIRSHIFT	(_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
    422 
    423 #define _VKI_IOC_NONE	0U
    424 #define _VKI_IOC_WRITE	1U
    425 #define _VKI_IOC_READ	2U
    426 
    427 #define _VKI_IOC(dir,type,nr,size) \
    428 	(((dir)  << _VKI_IOC_DIRSHIFT) | \
    429 	 ((type) << _VKI_IOC_TYPESHIFT) | \
    430 	 ((nr)   << _VKI_IOC_NRSHIFT) | \
    431 	 ((size) << _VKI_IOC_SIZESHIFT))
    432 
    433 #define _VKI_IO(type,nr)		_VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
    434 #define _VKI_IOR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ,(type),(nr),sizeof(size))
    435 #define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size))
    436 #define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size))
    437 
    438 #define _VKI_IOC_DIR(nr)		(((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
    439 #define _VKI_IOC_SIZE(nr)		(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
    440 
    441 //----------------------------------------------------------------------
    442 // From linux-2.6.9/include/asm-x86_64/ioctls.h
    443 //----------------------------------------------------------------------
    444 
    445 #define VKI_TCGETS	0x5401
    446 #define VKI_TCSETS	0x5402
    447 #define VKI_TCSETSW	0x5403
    448 #define VKI_TCSETSF	0x5404
    449 #define VKI_TCGETA	0x5405
    450 #define VKI_TCSETA	0x5406
    451 #define VKI_TCSETAW	0x5407
    452 #define VKI_TCSETAF	0x5408
    453 #define VKI_TCSBRK	0x5409
    454 #define VKI_TCXONC	0x540A
    455 #define VKI_TCFLSH	0x540B
    456 #define VKI_TIOCSCTTY	0x540E
    457 #define VKI_TIOCGPGRP	0x540F
    458 #define VKI_TIOCSPGRP	0x5410
    459 #define VKI_TIOCOUTQ	0x5411
    460 #define VKI_TIOCGWINSZ	0x5413
    461 #define VKI_TIOCSWINSZ	0x5414
    462 #define VKI_TIOCMGET	0x5415
    463 #define VKI_TIOCMBIS	0x5416
    464 #define VKI_TIOCMBIC	0x5417
    465 #define VKI_TIOCMSET	0x5418
    466 #define VKI_FIONREAD	0x541B
    467 #define VKI_TIOCLINUX	0x541C
    468 #define VKI_FIONBIO	0x5421
    469 #define VKI_TIOCNOTTY	0x5422
    470 #define VKI_TCSBRKP	0x5425	/* Needed for POSIX tcsendbreak() */
    471 #define VKI_TIOCGPTN	_VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
    472 #define VKI_TIOCSPTLCK	_VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
    473 
    474 #define VKI_FIONCLEX    0x5450
    475 #define VKI_FIOCLEX     0x5451
    476 #define VKI_FIOASYNC	0x5452
    477 #define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
    478 
    479 #define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
    480 
    481 //----------------------------------------------------------------------
    482 // From linux-2.6.9/include/asm-x86_64/poll.h
    483 //----------------------------------------------------------------------
    484 
    485 #define VKI_POLLIN		0x0001
    486 
    487 struct vki_pollfd {
    488 	int fd;
    489 	short events;
    490 	short revents;
    491 };
    492 
    493 //----------------------------------------------------------------------
    494 // From linux-2.6.9/include/asm-x86_64/user.h
    495 //----------------------------------------------------------------------
    496 
    497 struct vki_user_i387_struct {
    498 	unsigned short	cwd;
    499 	unsigned short	swd;
    500 	unsigned short	twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
    501 	unsigned short	fop;
    502 	__vki_u64	rip;
    503 	__vki_u64	rdp;
    504 	__vki_u32	mxcsr;
    505 	__vki_u32	mxcsr_mask;
    506 	__vki_u32	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
    507 	__vki_u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg = 256 bytes */
    508 	__vki_u32	padding[24];
    509 };
    510 
    511 struct vki_user_regs_struct {
    512 	unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10;
    513 	unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax;
    514 	unsigned long rip,cs,eflags;
    515 	unsigned long rsp,ss;
    516   	unsigned long fs_base, gs_base;
    517 	unsigned long ds,es,fs,gs;
    518 };
    519 
    520 //----------------------------------------------------------------------
    521 // From linux-2.6.9/include/asm-x86_64/elf.h
    522 //----------------------------------------------------------------------
    523 
    524 typedef unsigned long vki_elf_greg_t;
    525 
    526 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
    527 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
    528 
    529 typedef struct vki_user_i387_struct vki_elf_fpregset_t;
    530 
    531 //----------------------------------------------------------------------
    532 // From linux-2.6.9/include/asm-x86_64/ucontext.h
    533 //----------------------------------------------------------------------
    534 
    535 struct vki_ucontext {
    536 	unsigned long		uc_flags;
    537 	struct vki_ucontext    *uc_link;
    538 	vki_stack_t		uc_stack;
    539 	struct vki_sigcontext	uc_mcontext;
    540 	vki_sigset_t		uc_sigmask;	/* mask last for extensibility */
    541 };
    542 
    543 //----------------------------------------------------------------------
    544 // From linux-2.6.9/include/asm-x86_64/segment.h
    545 //----------------------------------------------------------------------
    546 
    547 #define VKI_GDT_ENTRY_TLS_ENTRIES 3
    548 
    549 #define VKI_GDT_ENTRY_TLS_MIN 11
    550 #define VKI_GDT_ENTRY_TLS_MAX 13
    551 
    552 //----------------------------------------------------------------------
    553 // From linux-2.6.11.9/include/asm-x86_64/prctl.h
    554 //----------------------------------------------------------------------
    555 
    556 #define VKI_ARCH_SET_GS 0x1001
    557 #define VKI_ARCH_SET_FS 0x1002
    558 #define VKI_ARCH_GET_FS 0x1003
    559 #define VKI_ARCH_GET_GS 0x1004
    560 
    561 //----------------------------------------------------------------------
    562 // From linux-2.6.9/include/asm-x86_64/ldt.h
    563 //----------------------------------------------------------------------
    564 
    565 // I think this LDT stuff will have to be reinstated for amd64, but I'm not
    566 // certain.  (Nb: The sys_arch_prctl seems to have replaced
    567 // [gs]et_thread_area syscalls.)
    568 //
    569 // Note that the type here is very slightly different to the
    570 // type for x86 (the final 'lm' field is added);  I'm not sure about the
    571 // significance of that... --njn
    572 
    573 /* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
    574    to confuse and annoy everyone, this is _not_ the same as an
    575    VgLdtEntry and has to be translated into such.  The logic for doing
    576    so, in vg_ldt.c, is copied from the kernel sources.]] */
    577 /* Note also that a comment in ldt.h indicates that the below
    578    contains several fields ignored on 64bit, and that modify_ldt
    579    is rather for 32bit. */
    580 struct vki_user_desc {
    581 	unsigned int  entry_number;
    582 	unsigned long base_addr;
    583 	unsigned int  limit;
    584 	unsigned int  seg_32bit:1;
    585 	unsigned int  contents:2;
    586 	unsigned int  read_exec_only:1;
    587 	unsigned int  limit_in_pages:1;
    588 	unsigned int  seg_not_present:1;
    589 	unsigned int  useable:1;
    590         unsigned int  lm:1;
    591 };
    592 
    593 // [[Nb: for our convenience within Valgrind, use a more specific name]]
    594 typedef struct vki_user_desc vki_modify_ldt_t;
    595 
    596 //----------------------------------------------------------------------
    597 // From linux-2.6.11.2/include/asm-x86_64/ipcbuf.h
    598 //----------------------------------------------------------------------
    599 
    600 struct vki_ipc64_perm
    601 {
    602 	__vki_kernel_key_t	key;
    603 	__vki_kernel_uid32_t	uid;
    604 	__vki_kernel_gid32_t	gid;
    605 	__vki_kernel_uid32_t	cuid;
    606 	__vki_kernel_gid32_t	cgid;
    607 	__vki_kernel_mode_t	mode;
    608 	unsigned short		__pad1;
    609 	unsigned short		seq;
    610 	unsigned short		__pad2;
    611 	unsigned long		__unused1;
    612 	unsigned long		__unused2;
    613 };
    614 
    615 //----------------------------------------------------------------------
    616 // From linux-2.6.11.2/include/asm-x86_64/sembuf.h
    617 //----------------------------------------------------------------------
    618 
    619 struct vki_semid64_ds {
    620 	struct vki_ipc64_perm sem_perm;		/* permissions .. see ipc.h */
    621 	__vki_kernel_time_t	sem_otime;		/* last semop time */
    622 	unsigned long	__unused1;
    623 	__vki_kernel_time_t	sem_ctime;		/* last change time */
    624 	unsigned long	__unused2;
    625 	unsigned long	sem_nsems;		/* no. of semaphores in array */
    626 	unsigned long	__unused3;
    627 	unsigned long	__unused4;
    628 };
    629 
    630 //----------------------------------------------------------------------
    631 // From linux-2.6.11.2/include/asm-x86_64/msgbuf.h
    632 //----------------------------------------------------------------------
    633 
    634 struct vki_msqid64_ds {
    635 	struct vki_ipc64_perm msg_perm;
    636 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
    637 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
    638 	__vki_kernel_time_t msg_ctime;	/* last change time */
    639 	unsigned long  msg_cbytes;	/* current number of bytes on queue */
    640 	unsigned long  msg_qnum;	/* number of messages in queue */
    641 	unsigned long  msg_qbytes;	/* max number of bytes on queue */
    642 	__vki_kernel_pid_t msg_lspid;	/* pid of last msgsnd */
    643 	__vki_kernel_pid_t msg_lrpid;	/* last receive pid */
    644 	unsigned long  __unused4;
    645 	unsigned long  __unused5;
    646 };
    647 
    648 //----------------------------------------------------------------------
    649 // From linux-2.6.11.2/include/asm-x86_64/shmbuf.h
    650 //----------------------------------------------------------------------
    651 
    652 struct vki_shmid64_ds {
    653 	struct vki_ipc64_perm	shm_perm;	/* operation perms */
    654 	vki_size_t		shm_segsz;	/* size of segment (bytes) */
    655 	__vki_kernel_time_t	shm_atime;	/* last attach time */
    656 	__vki_kernel_time_t	shm_dtime;	/* last detach time */
    657 	__vki_kernel_time_t	shm_ctime;	/* last change time */
    658 	__vki_kernel_pid_t	shm_cpid;	/* pid of creator */
    659 	__vki_kernel_pid_t	shm_lpid;	/* pid of last operator */
    660 	unsigned long		shm_nattch;	/* no. of current attaches */
    661 	unsigned long		__unused4;
    662 	unsigned long		__unused5;
    663 };
    664 
    665 struct vki_shminfo64 {
    666 	unsigned long	shmmax;
    667 	unsigned long	shmmin;
    668 	unsigned long	shmmni;
    669 	unsigned long	shmseg;
    670 	unsigned long	shmall;
    671 	unsigned long	__unused1;
    672 	unsigned long	__unused2;
    673 	unsigned long	__unused3;
    674 	unsigned long	__unused4;
    675 };
    676 
    677 //----------------------------------------------------------------------
    678 // From linux-2.6.12.2/include/asm-x86_64/ptrace.h
    679 //----------------------------------------------------------------------
    680 
    681 #define VKI_PTRACE_GETREGS            12
    682 #define VKI_PTRACE_SETREGS            13
    683 #define VKI_PTRACE_GETFPREGS          14
    684 #define VKI_PTRACE_SETFPREGS          15
    685 
    686 //----------------------------------------------------------------------
    687 // From linux-2.6.8.1/include/asm-generic/errno.h
    688 //----------------------------------------------------------------------
    689 
    690 #define	VKI_ENOSYS       38  /* Function not implemented */
    691 #define	VKI_EOVERFLOW    75  /* Value too large for defined data type */
    692 
    693 //----------------------------------------------------------------------
    694 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
    695 //----------------------------------------------------------------------
    696 
    697 #define VKI_TIOCGSERIAL     0x541E
    698 #define VKI_TIOCSSERIAL     0x541F
    699 
    700 //----------------------------------------------------------------------
    701 // And that's it!
    702 //----------------------------------------------------------------------
    703 
    704 #endif // __VKI_AMD64_LINUX_H
    705 
    706 /*--------------------------------------------------------------------*/
    707 /*--- end                                                          ---*/
    708 /*--------------------------------------------------------------------*/
    709