criu/include
Cyrill Gorcunov 2ea781a9ea syscalls: Complete redesign v9
At early days we've been using only a few syscalls
which together with debug compiler options always
produce relative addresses for memory variables used
in parasite and restorer blobs. Thus it came in unnoticed
that there is something worng with syscalls declarations
we use.

Basically all our syscalls are just a wrappers over inline
assembly code in form of

static long syscall2(int nr, long arg0, long arg1)
{
	long ret;
	asm volatile(
		"movl %1, %%eax		\t\n"
		"movq %2, %%rdi		\t\n"
		"movq %3, %%rsi		\t\n"
		"syscall		\t\n"
		"movq %%rax, %0		\t\n"
		: "=r"(ret)
		: "g" ((int)nr), "g" (arg0), "g" (arg1)
		: "rax", "rdi", "rsi", "memory");
	return ret;
}

so every argument treated to be plain long (even if the call
sematics implies it's a memory address passed but not some
integer direct value) and transferred via general purpose
register.

As being mentioned it caused no problems when debug options
specified at compile time, the compiler do not tries to optimize
addressing but generates code which always compute them.

The situation is changed if one is building crtools with
optimization enabled -- the compiler finds that arguments
are rather plain long numbers and might pass direct addresses
of variables, instead of generating relative addresses
(because function declarations have no pointers and 'g' in cope
 with 'mov' is used, which is of course wrong).

To fix all this -- now syscalls declarations are generated from
syscall.def file and function arguments are passed in conform
with x86-64 ABI.

This shrinks amount of source code needed to declare syscalls
and opens a way to use optimization.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 18:23:19 +04:00
..
atomic.h Gather futex helpers into lock.h 2011-12-26 23:54:18 +04:00
bitops.h restore: Add mutexes via futex syscall and order threads creation 2011-11-18 16:09:01 +04:00
compiler.h files: Use sys_kcmp to find file descriptor duplicates v4 2012-02-28 19:13:47 +04:00
crtools.h files: Collect fdinfo-s on per-pstree_item list 2012-04-18 16:24:08 +04:00
file-ids.h vma: Remove FDINFO_MAP fd type 2012-04-09 12:57:38 +04:00
files.h files: Simplify fd-s restore 2012-04-18 16:27:46 +04:00
image.h magics: Move them one tab right 2012-04-13 18:02:50 +04:00
inet_diag.h Trivial whitespace cleanup 2012-01-30 21:29:42 +04:00
ipc_ns.h show: Introduce ->show callback for fdset 2012-03-27 12:01:14 +04:00
kcmp-ids.h kcmp: Introduce generic object ID generator 2012-04-09 18:01:18 +04:00
libnetlink.h net: Define named constant for nlmsg_seq 2011-12-27 20:13:18 +04:00
linkage.h parasite: Move bootstrap code into parasite-head-x86-64.S 2012-04-18 18:22:52 +04:00
list.h list: Cleanup spaces/tabs mess 2012-02-01 14:38:49 +04:00
lock.h lock: Restore ability to abort on futex waiting 2012-04-05 14:07:39 +04:00
log.h log: log-engine slight redesign 2012-03-02 01:05:43 +04:00
memcpy_64.h Add builtin_memcpy helper 2012-03-29 15:14:06 +04:00
namespaces.h show: Introduce ->show callback for fdset 2012-03-27 12:01:14 +04:00
parasite-syscall.h fd: Handle close-on-exec bits 2012-04-10 18:36:59 +04:00
parasite.h parasite: Move bootstrap code into parasite-head-x86-64.S 2012-04-18 18:22:52 +04:00
proc_parse.h proc: Make small stat parsing read pgid and sid 2012-04-11 22:09:12 +04:00
processor-flags.h Add processor-flags.h 2012-02-14 17:18:08 +04:00
ptrace.h xids: Save pgid and sid on pstree_Item and pstree_entry 2012-04-11 22:10:09 +04:00
rbtree.h rb: Drop rb_attach_node 2012-03-28 20:28:29 +04:00
restorer-log.h logfd: Distinguish functions which do setup logdf 2012-03-02 01:05:43 +04:00
restorer.h make: Generate offsets from linked files only 2012-04-18 18:22:15 +04:00
sockets.h files: Generalize file open, get rid of explicit types switch 2012-04-06 20:39:48 +04:00
syscall-types.h syscalls: Move types definitions needed for syscalls into syscall-types.h 2012-04-18 12:25:17 +04:00
syscall-x86-64.def syscalls: Complete redesign v9 2012-04-18 18:23:19 +04:00
sysctl.h show: Use pr_msg for showing contents on console 2012-03-02 11:12:59 +04:00
types.h types: Add F_GETOWNER_UIDS opcode 2012-04-12 12:27:54 +04:00
unix_diag.h sockets: Update unix_diag.h 2012-01-10 17:26:50 +04:00
util-net.h util-net: Make send/recv fds carry fd flags in message 2012-04-10 18:36:13 +04:00
util.h util: Extend reopen_fd_as_safe 2012-04-16 12:35:51 +04:00
uts_ns.h show: Introduce ->show callback for fdset 2012-03-27 12:01:14 +04:00