2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

8088 Commits

Author SHA1 Message Date
Dmitry Safonov
66929a661c compel: plugins -- Add fds plugin
This is fd passing via unix sockets (scm creds) suitable for use
by parasite code.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:10 +03:00
Dmitry Safonov
048c5073cf compel: plugins,std -- Use sys_recvfrom instead of recv
prologue.h defines sys_recv() macro - let's use it by now

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
a1d931c354 compel: plugins -- Add shmem plugin
The shmem pluging allows creation of shared memory segment between
parasite code and the caller.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
5cf76474f1 compel: plugins,std -- Add prologue.S
The prologue includes routines needed for parasite blob to work
and is always included with the std plugin.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
7eee9d5c3d compel: plugins -- Add prologue.h from compel, drop hand-made prologue_init_args
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
23fcca8e87 compel: Makefile.compel -- Remove second GEN msg
Fixes:
  GEN      compel/include/version.h
  GEN      compel/include/version.h

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
338f3aa7b7 compel: make -- Add general assembly flags
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Dmitry Safonov
12ca38255c compel: remove not needed from uapi
Delete plugins/include/asm/std directory - let it be without plugin name.
Make symlinks to reuse criu's files, except those, which will
be deleted after libcompel from criu (like syscalls).

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
20d5bb140d compel: plusings -- Add std plugin
The plugin provides basic features as string copying, syscalls, printing.
Not used on its own by now but will be shipping by default with other
plugins.

With great help from Dmitry Safonov.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
a437c2d969 compel: Add plugins header
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
3b0c8dbd48 compel: Reshuffle the directories structure
Here we rather suffle source code into directories
preparing ground for future work.

Basically all this files movements should end up in the
following compel/ tree structure

compel/
├── arch
│   ├── aarch64
│   │   ├── plugins
│   │   │   └── std
│   │   └── src
│   │       └── lib
│   ├── arm
	...
│   ├── ppc64
	...
│   └── x86
	...

	This is architectural part, where each arch consists of
	plugins/, and src/. src/ stands for code needed by compel
	cli + lib

├── include
│   ├── compiler.h -> ../../criu/include/compiler.h
│   ├── elf32-types.h
│   ├── elf64-types.h
│   ├── int.h -> ../../criu/include/asm-generic/int.h
│   ├── piegen.h
│   ├── shmem.h
│   └── uapi
│       ├── compel.h
│       └── plugins.h

	Common includes + uapi

├── plugins
│   ├── fds
│   ├── shmem
│   └── std

	Plugins source code

└── src
    ├── lib
    │   ├── handle-elf-32.c -> handle-elf.c
    │   ├── handle-elf-32-host.c -> handle-elf-32.c
    │   ├── handle-elf.c
    │   └── handle-elf-host.c -> handle-elf.c

	compel library

    ├── main.c
    ├── main-host.c -> main.c

	compel cli

    └── shared
        └── fds.c

	shared code between plugins and compel cli

Note: cross-compile won't work for a while.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
596767d5f7 compel: uapi -- Add standalone headers
Will be used later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Cyrill Gorcunov
2acc20056b compel: build -- Add @sublevel
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
745b26a7a2 compel: abort PIE generation on undefined/external symbols
As we meet this before, I think, we should abort generation here.
No point for making PIE with external symbols for us (at least, yet),
so let's break build than find the problem at runtime.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
693f56fdd8 parasite-vdso: vdso_map_compat under CONFIG_COMPAT
It's used in restorer to map compatible vDSO blob.
When !CONFIG_COMPAT it's not needed and even more:
vdso_fill_symtable_compat is macro and is undefined in that
case. It will never shoot, as compat_vdso is always false
for that case, but get rid of it.
  I also need to leave CONFIG_X86_64 here, as arch_prctl()
is not defined for x86_32.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
281572bd70 pie: provide callbacks for stack-protector
The other way to solve this is to compile shared between
CRIU and PIEs objects twice: without stack-protection and
with environment choice. But I don't think it worth it.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
3c85c5350a make/x86: get cflags for ia32 from compel tool
I think, we could transpher also `-m elf_i386' and `-m32' to
compel output - but only in case if we will not support
native x86_32 in compel (as they are wrong for native build).
Or introduce something like compat_ia32 in compel option, not sure.
Left in makefile for a while.
  Also it would be good to remove $(LD_R) in makefile and use
compel output for ldflags, but that will be valid only when compel
will support arm arch.

Fixes (with the following patches):
  GEN      criu/pie/parasite-compat-blob.h
parasite_compat_blob: Error (compel/handle-elf-32.c:322): Unexpected undefined symbol: `__stack_chk_fail'. External symbol in PIE?

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
ec58dcab74 parasite/x86: introduce&use builtin_memset
Don't use compiler-provided memset in parasite.

Fixes: commit 86434deba0b4 ("x86: dump TLS entries from GDT").

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
74c0a70223 criu: wrap compatible code with CONFIG_COMPAT
As we will not support *native* 32-bit i386 build, I dropped some
ifdefs, introducing instead of ifdef(CONFIG_X86_64) --
ifdef(CONFIG_COMPAT).

CRIU should build now without ia32 Glibc and gcc-multilib support.
Maybe I should add some warning that the build is made without
compatible task support (or criu check should print that),
will do as compat patches hit master.

Fixes: #181

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
31d394bc55 feature-test: add CONFIG_COMPAT compile option
I'll wrap all compatible code in this CONFIG_COMPAT define.
As I'll wrap also compatible parasite generation in this,
it's also makefile variable, rather than just C define.
The test itself consists of including stubs-32.h, which is
glibc6-i686 presence test and is compiled with -m32 option,
which is test for gcc-multilib.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Laurent Dufour
b6b2290f87 parasite: simplify syscall check
In is_required_syscall() req_sysnr is set according to the native mode
so we can check the syscall number directly against it.

No functional change expected.

Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
bbf29e89b4 make: drop compel/compel dependency for all target
Target criu depends on all, so this is redundant and makes noise:
if you had typed `make` without arguments, it has built compel firstly,
if you had typed `make criu`, it has built protobuf images firstly.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Cyrill Gorcunov
abca195ef2 criu: arch, x86 -- Rename registers mode
@gpregs_case is a bit vague name, lets
define traditional @mode here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
5c7e141b34 parasite-syscall: refactor dumping of posix timers
Tried hard to save compile-time static type checking and make code
more readable, hiding native/compat details in macros.
I think, it's better now.

Also BTW fixes: #188 (and compatible zdtm test)

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
5141d3238a cr-exec: check syscall's number right before injecting it
So, I made a mistake in find_syscall: it can't use arch_task_compatible
to find out in which mode the application is (native/compat).
The reason is that arch_task_compatible uses PTRACE_GETREGSET.
And at the moment of find_syscall we haven't yet seized the task.

In this patch I move syscall's number check right before injecting
a syscall, where we have parasite_ctl with all needed information
about task's mode.
This makes error-path for wrong syscall number longer and subtler
(includes curing now), but I think it's a corner-case, so as
it makes error-less path to execute_syscall shorter and without
additional ptrace syscalls, it's better.

Reported-by: Andrew Vagin <avagin@virtuozzo.com>
Cc: Andrew Vagin <avagin@virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
8f6800db83 x86/ptrace: describe failures from errno
ptrace_get_regs correctly returns error code in case of failure,
but for debugging reasons let's add error printing in case of
PTRACE_GETREGSET failed right after the call to ptrace().

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Andrew Vagin
cd073d3e88 parasite: pass parameter regs as pointer
CID 163751 (#1 of 1): Big parameter passed by value (PASS_BY_VALUE)
pass_by_value: Passing parameter regs of type user_regs_struct_t (size 224 bytes) by value.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Cyrill Gorcunov
c36515ad41 criu: arch, x86 -- A few style tuneup in mixed call code
- use entry/end from linkage
 - use macros for segments
 - use C style comments

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Tested-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
acfd9a3ebe vdso: suppress not ELF vDSO error
When mapping compatible vDSO in restorer blob (with vdso_map_compat),
we don't know if the kernel will map firstly vvar pages or vdso pages.
So we attempt search by checking ELF header magic on those pages.
Which leads to following "errors", which this patch hides:
pie: 1: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 1: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 7: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 7: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 6: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 6: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 4: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 5: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 4: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 5: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
(for two vvar pages and 5 processes being restored).

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
a8ae7b4eea signal/x86-32: use packed for compat rt_sigaction
Otherwise compiler nicely align it for us on 24 bytes.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:07 +03:00
Dmitry Safonov
3f1ac58c33 restore/x86: call int80 for compat sigaction restore
The kernel patch "x86/signal: add SA_{X32,IA32}_ABI sa_flags" makes
signal's ABI the same as sigaction's syscall ABI instead of per-thread's
TIF_IA32 flag.
So for delivering signals with compatible ABI, we need to call
sigaction through raw int80 exception.
This patch restores signals with int80: cr-restore part and PIE restorer's
part lay in sigaction_compat.c, which compiled for criu binary and for
restorer PIE.
The PIE's part is needed strictly for setting SIGCHLD handler, other
signal handlers are set in cr-restore (as it was before).

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
19e4ab4f5a zdtm: add compatible tests building
`make test COMPAT_TEST=y` will build all executable tests as i386 ELFs.

For building tests, need the following libraries from multilib:
libaio.i686 libaio-devel.i686 libcap-devel.i686 libcap.i686

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
ae119678ea x86: restore TLS
Put dumped TLS descriptors back to GDT.
Do it only if it was present.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
2bcfa2c1fc x86: dump TLS entries from GDT
Dump TLS with the help of SYS_get_thread_area.
Primary for 32-bit applications, but this also may be used by
mixed 64/32 bit code. I do not enable dumping for 64 bit unless
we'll meet such code, but include 3 user_desc entries of TLS
as not present in 64-bit images.
That's arguable and I may include user_descs only for compat tasks.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
b1cc99844f x86/call32: reserve space for saving 64-bit sp on 32-bit stack
I prefer this to be done in callee, than in caller for simplicity.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
75281003bd x86: add helpers to call 32-bit code from 64-bit
I need it to call sigaction from 32-bit code as kernel will
set sigframe ABI according to sigaction call ABI.
Also I will call {get,set}_thread_area to restore TLS entries.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
928fe9be0e restorer: refill symtable for rt-vdso
Otherwise, we still have parsed x86_64 vdso symtable.
After this:
  pie: 17917: vdso: Mapping compatible vDSO at 0x25000
  pie: 17917: vdso: Parsing at 0x25000 0x29000
  pie: 17917: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic m>
  pie: 17917: ismatch
  pie: 17917: vdso: Parsing at 0x26000 0x29000
  pie: 17917: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic m>
  pie: 17917: ismatch
  pie: 17917: vdso: Parsing at 0x27000 0x29000
  pie: 17917: vdso: PT_LOAD p_vaddr: 0x0
  pie: 17917: vdso: DT_HASH: 0xb4
  pie: 17917: vdso: DT_STRTAB: 0x1c0
  pie: 17917: vdso: DT_SYMTAB: 0x130
  pie: 17917: vdso: DT_STRSZ: 0x95
  pie: 17917: vdso: DT_SYMENT: 0x10
  pie: 17917: vdso: nbucket 0x3 nchain 0x9 bucket 0x270bc chain 0x270c8

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
f52ea57df3 pie/restorer: add vdso_fill_symtable_compat for 32-bit vdso
While restorering compatible application on x86-64, we need
to parse 32-bit vDSO. By that reason I need _three_ compiled
object versions for util-vdso:
- for native parasite it's util-vdso.o
- for compatible parasite it's compat/util-vdso.o
- for restorer it's util-vdso.o and util-vdso-elf32.o

Note, that I can't link compat/util-vdso.o to restorer, as it's
i386 ELF which ld can't link to x86_64 ELF file.

TODO: maybe I'll need to refactor and introduce generic
CONFIG_COMPAT instead of those defined(CONFIG_X86_32).

Fixes:
  pie: 27504: vdso: Mapping compatible vDSO at 0x25000
  pie: 27504: Remap 0x7f3de3efa000->0x8048000 len 0x1000
  ...
  pie: 27504: vdso: Parsing at 0xf7776000 0xf7778000
  pie: 27504: Error (pie/util-vdso.c:87): vdso: Elf header magic mismatch
  pie: 27504: Error (pie/restorer.c:1540): Restorer fail 27504
  (00.029188) Error (cr-restore.c:988): 27504 exited, status=1
  (00.033072) Error (cr-restore.c:1870): Restoring FAILED.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
2457ce6f6d restore: add arch_prctl mapping compatible vDSO
Map here instead of park before unmap.
TODO: need to check that mapped size is smaller than x86_64 vDSO.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
64d39a20df restorer: unmapping native blob in compat task
We need to do it in pure ia32 asm.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:06 +03:00
Dmitry Safonov
c7c63a3e8b vdso: try_fill_symtable always for compat tasks
Their vDSO's pfn differ from native tasks.

TODO: compute on dump compatible vDSO's pfn.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:05 +03:00
Dmitry Safonov
5877e70e7e x86: change k_rtsigset_t sig type
As it has equall size for compat/native tasks.
Fixes for compatible tasks:
pie: Daemon waits for command
(00.009247) Fetched ack: 7 7 0
pie: __fetched msg: 9 0 0
pie: Error (pie/parasite.c:106): sys_sigaction failed (-22)
pie: __sent ack msg: 9 9 -22
pie: Error (pie/parasite.c:725): Close the control socket for writing

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:05 +03:00
Dmitry Safonov
3c09c15daf page-xfer: dump compatible iovec
Change page_xfer_dump_pages the way it could handle compatible iovs.
Separated hole dumping in page_xfer_dump_hole and introduced
iterator function get_iov which will return native iovec,
converting compatible iovec if needed.

Fixes:
(00.009060) Fetched ack: 7 7 0
(00.009061) Transfering pages:
(00.009062) 	buf 16/16
(00.009063) 	p 0x100008048000 [32841]
(00.009101) Error (page-xfer.c:504): Only 65536 of 17592320561152 bytes have been spliced
(00.009253) page-pipe: Killing page pipe
(00.009263) ----------------------------------------

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:02 +03:00
Dmitry Safonov
aefed47f8f page-pipe: add compatible iovec
struct iovec may have different size for dumpee.
But that reason, pages dump will fail (with added debug to pie):
(00.011440) page-pipe: Page pipe:
(00.011441) page-pipe: * 1 pipes 8/523 iovs:
(00.011442) page-pipe: 	buf 16 pages, 8 iovs:
(00.011444) page-pipe: 		0x8048000 3
(00.011446) page-pipe: 		0xf7512000 1
(00.011447) page-pipe: 		0xf76ca000 4
(00.011449) page-pipe: 		0xf76cf000 1
(00.011450) page-pipe: 		0xf76dc000 2
(00.011452) page-pipe: 		0xf76e1000 1
(00.011454) page-pipe: 		0xf7702000 2
(00.011455) page-pipe: 		0xffdad000 2
(00.011470) page-pipe: * 0 holes:
(00.011471) PPB: 16 pages 8 segs 16 pipe 0 off
(00.011476) Sent msg to daemon 8 0 0
pie: __fetched msg: 8 0 0
(00.011479) Wait for ack 8 on daemon socket
pie: sys_vmsplice for 16 pages 8 segs 0 off
pie:  buf 16 pages, 8 iovs:
pie: 	0x8048000 0
pie: 	0x3000 0
pie: 	0xf7512000 0
pie: 	0x1000 0
pie: 	0xf76ca000 0
pie: 	0x4000 0
pie: 	0xf76cf000 0
pie: 	0x1000 0
pie: Error (pie/parasite.c:93): Can't splice pages to pipe (0/16)
pie: __sent ack msg: 8 8 -1

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:57:01 +03:00
Dmitry Safonov
8e329bde93 parasite-syscall: deserialize compat parasite's answers
Compatible parasite will use standard types, which are sized
as _args_compat structures in "parasite-compat.h".
Sometimes I miss high-level overloading in C.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00
Dmitry Safonov
2c0d72fd10 kdat: add compat_sigreturn feature
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00
Dmitry Safonov
6b9780ca76 x86/crtools: log dumping task's mode
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00
Dmitry Safonov
094afe856b syscalls: add __NR(syscall, compat) wrapper
Generic code uses raw syscall numbers for:
 - syscall_seized, to execute through parasite control needed syscall;
 - parasite_stop_on_syscall, to trap couple of tasks on needed syscall.

As syscall numbers may differ (and differ for x86) between native and
compatible mode, we need proper syscall wrapper here.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00
Dmitry Safonov
f6126361a2 parasite-head-32: fix cmd & args load
Seems like, offset was broken. And it had typo: leal -> movl
(according to 64-bit parasite header), as cmd parameter is int
(not pointer to int) in parasite_service:
int __used __parasite_entry parasite_service(unsigned int cmd, void *args)
Fixed - loads good now.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00
Dmitry Safonov
b6aca38d14 x86/restorer: add sigreturn to compat mode
Do pure 32-bit sigreturn.
Change code selector, do 0x80 rt_sigreturn.
We should have here remapped 32-bit vDSO, all should be fine.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:40:36 +03:00