2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

2337 Commits

Author SHA1 Message Date
Alexander Kartashov
3f12d688ae sys_mmap: fixed the error detection logic.
The current sys_mmap error analysis code doesn't work on 32-bit architectures
with 3G/1G userspace/kernel virtual address space split since the syscall
allocates anonymous memory above the first 2G of the address space ---
such an address is a negative integer so it's interpreted as a error code.
The problem isn't encountered on x86-64 becauase it doesn't use negative
virtual addresses in the userspace.

The 3G/1G split is used because memory allocation is currently broken for other
values of the split on ARM: the value of TASK_UNMAPPED_BASE (arch/arm/include/asm/memory.h)
isn't page-aligned if other split value is used so the value of the field
mm_struct::mmap_base is initialized with a page-unaligned value by
the function arch_pick_mmap_layout() (arch/arm/mm/mmap.c) in some circumstances
that breaks page-alignment checks in the kernel memory management code.

This patch modifies sys_mmap return value analysis code replacing tests
for negativeness of the signed return value with tests that checks that
the return value isn't greater than TASK_SIZE.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:41:58 +04:00
Alexander Kartashov
b1e8f70b05 restorer: reduce the shift value to fit the error code into ARM long integer.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:41:15 +04:00
Alexander Kartashov
7b7a08dde5 auxv: save and restore AUXV's in a machine-independent way.
The size of an auxv is the machine pointer but a 64-bit integer is reserved
in a MmEntry protobuf message to store an auxv. Moreover the number of auxv's
varies from one architecture to another. So the following is proposed
to alleviate the issue.

* Introduced the type auxv_t representing a machine-pointer sized integer.

* The size of auxv array is extracted from a MmEntry message instead of using
  the value of the macro AT_VECTOR_SIZE.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:40:33 +04:00
Alexander Kartashov
cbffef75b7 cr-restore.c: wrapped the restorer blob trampoline assembly into the macro JUMP_TO_RESTORER_BLOB.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:39:23 +04:00
Alexander Kartashov
ba602791fd restorer: wrapped the assembly code executed on a rt_sigreturn failure into the macro ARCH_FAIL_CORE_RESTORE.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:39:14 +04:00
Alexander Kartashov
e37c15629c restorer: wrapped the assembly code calling sys_clone into the macro RUN_CLONE_RESTORE_FN.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:39:12 +04:00
Alexander Kartashov
1e5635daaf restorer: wrapped the assembly calling sys_rt_sigreturn into the macro ARCH_RT_SIGRETURN.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:39:08 +04:00
Alexander Kartashov
abc622b360 restorer: moved the routine restore_fpu() to the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:37:38 +04:00
Alexander Kartashov
ea6ab14d13 restorer: moved the routine restore_gpregs() to the file arch/x86/restorer.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:37:31 +04:00
Alexander Kartashov
c074dc5810 include/restorer.h: moved machine-dependent sigframe structs to the file arch/x86/include/asm/restorer.h.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:34:12 +04:00
Alexander Kartashov
91504f5282 include/restorer.h: moved machine-independent sigframe structs to the file include/sigframe.h.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:33:59 +04:00
Alexander Kartashov
f35661d164 cr-dump.c: moved the function core_free_entry() into the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:27:55 +04:00
Alexander Kartashov
d2dfdeffd9 cr-dump.c: moved thread core initialization into the function arch_alloc_thread_info().
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:27:53 +04:00
Alexander Kartashov
1c8be2b945 cr-dump.c: moved the routine get_task_regs() to the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:27:49 +04:00
Alexander Kartashov
f032e67ae3 parasite-syscall.c: moved the routine syscall_seized() into the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:26:46 +04:00
Alexander Kartashov
3b4aa70aef parasite-syscall.c: moved the routine parasite_setup_regs() to the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:26:41 +04:00
Alexander Kartashov
ec64246863 parasite-syscall.c: moved the syscall instructions into the file arch/x86/crtools.c.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:26:31 +04:00
Alexander Kartashov
aa9ea9209e cr: don't touch VM above TASK_SIZE.
VM above TASK_SIZE is read-only but some areas are mapped on ARM
into the process address space.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:23:48 +04:00
Alexander Kartashov
7758a43bd7 sys_getpgid: fixed the syscall prototype since it actually has one argument.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:15:22 +04:00
Alexander Kartashov
8863d8dd7f multiarch: introduced the multiarch support into the build system.
* The linker script pie/pie.lds.S is generated from the template
  pie/pie.lds.S.in by prepending the output architecture specification.
  The output architecture is defined by the variable LDARCH.

* Blobs are generated by objcopy instead of ld because the ARM linker
  fails to produce a binary when supplied a script.
  (See http://lists.gnu.org/archive/html/bug-binutils/2008-10/msg00091.html).

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:08:17 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Andrey Vagin
3716fd67c1 zdtm: check only existent capabilities
Kernel started with 3.8-rc1 are not report non-existent caps in
/proc/pid/status, so crtools doesn't dump/restore such caps.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-28 23:47:01 +04:00
Cyrill Gorcunov
a1144f9fd1 zdtm: mountpoints -- Explicitly remove old /dev/null
We should explicitly unlink old /dev/null instance, otherwise
if such device already exist we might hit a problem as

 | (00.002984) 7412 fdinfo 0: pos: 0x               0 flags:           100002/0
 | (00.003015) Dumping path for 0 fd via self 42 [/dev/null]
 | (00.003025) Error (files-reg.c:422): Unaccessible path opened 2049:109720, need 5:10
 | (00.003033) Error (cr-dump.c:1565): Dump files (pid: 7412) failed with -1

Reported-by: Alexander Kartashov <alekskartashov@parallels.com>
Tested-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-26 20:00:46 +04:00
Pavel Emelyanov
087739d402 rst: Remove xid_fail
It was required as a temp stub for MySQL restore. Now it
just spoils the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-26 18:15:03 +03:00
Andrey Vagin
25af1beec4 make: s/tproxyd/crtools
tproxyd is another project.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-26 13:03:43 +04:00
Andrey Vagin
134937bc87 make: add ability to collect code coverage (v2)
gcc is executed with the option --coverage.
lcov creates HTML pages containing the source code annotated with
coverage information.

make GCOV=1
make test
make gcov
Look at gcov/html/index.html

v2: declare the weak __gcov_flush

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:43:14 +04:00
Konstantin Khlebnikov
162cb47930 x86/syscalls-x86-64.sh: fix bashisms
syscalls-x86-64.sh: 3: syscalls-x86-64.sh: Syntax error: "(" unexpected

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:41:51 +04:00
Cyrill Gorcunov
81f7f70386 pie: Don't forget to include sub-text sections into the blob
I've just got an interesting built problem which I never saw
before (and which I can't reporoduce at moment):

 | `.text.unlikely' referenced in section `.text' of parasite.o: defined in discarded section `.text.unlikely' of parasite.o

Including sub-text sections is a good thing anyway.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:41:10 +04:00
Cyrill Gorcunov
830d92b0f0 headers: Unify include guards (in comments) and a few fixes
- fix names in comments
 - add empty lines where needed
 - fix rbtree.h
 - fix syscall-types.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:40:24 +04:00
Cyrill Gorcunov
439637fb07 parasite-syscall: Drop redundant \Space in parasite_ctl structure
No func changes

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:39:55 +04:00
Pavel Emelyanov
b4c2160449 hdrs: Fixup reinclusion preprocessor constants
Make them look like __CR_<smth>_H__ with

sed -e '1,2s/#\(ifndef\|define\) _\?_\?\(CR_\)\?/#\1 __CR_/' -e '1,2s/_H_\?_\?.*$/_H__/'

on every header file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-24 15:36:14 +04:00
Andrey Vagin
6a25678243 restore: remove an unused field from task_restore_core_args
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:32 +04:00
Andrey Vagin
9cd9a93e79 restore: unify handling of thread args of leaders and other threads
Currently we have an array for thread_args, but leader's thread_args
is a part of task_args.
Here is two problems. The array has a space for leader's thread args,
but it is unused. Code which fills thread args is duplicated two
times. This patch fixed both problem. It replaces thread_args on a
pointer from task_args and deletes code, which fills leaders
thread_args.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:23 +04:00
Andrey Vagin
ff9a760bcd restore: fill up thread_args a bit earlier
It's preparation for the next patch.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:16 +04:00
Andrey Vagin
48d0e78e36 crtools: change the minimal address for the restorer blob
It should be bigger than CONFIG_LSM_MMAP_MIN_ADDR.

v2: set a correct value

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:14 +04:00
Cyrill Gorcunov
6089f8c5a5 zdtm: Enable mmx00/sse00/sse20 tests
Since we supprt FPU c/r now we can run
these tests.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:50 +04:00
Cyrill Gorcunov
c7cc08b811 zdtm: Enable fpu01 test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:48 +04:00
Cyrill Gorcunov
ee9277562f zdtm: Add fpu01 test
This test loads ymm0/ymm7 registers and check if after
restore the contents is not changed.

The test requires xsave capability to present on the
test system, thus if we figure out that there is no
suitable cpu provided we skip the test.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:47 +04:00
Cyrill Gorcunov
5e9a65878c zdtm: Enable fpu00 test-case
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:46 +04:00
Cyrill Gorcunov
4685b56336 zdtm: Add cpuid.h
The test for fpu transition will require to do
a runtime check for the cpu features it's running
on. For this sake we need to use cpuid. Thus make
it more widely available by providing in the general
header.

The code is adopted from the linux kernel code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:44 +04:00
Cyrill Gorcunov
3eb28f9fbc restore: Restore FPU state
Since at moment we stick with sigreturn restore
we need to form a proper FPU frame and set a pointer
to it inside sigreturn frame.

For this sake we read the FPU image and here are two
cases are possible

 - no fpu data at all -- nothing to restore, simpliest
   case

 - xsave frame is present but the host cpu supports only
   fxsave instruction: we refuse to continue, since it means
   there are no ymm registers on the machine where we're trying
   to restore

 - fxsave frame is present but the host cpu has xsave feature:
   at moment we refuse to continue, requiring complete match
   between "checkpoint and restore hosts", but in real we could
   extend logic and form complete xsave frame from fxsave and
   continue processing

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:43 +04:00
Cyrill Gorcunov
9fee76bd31 restore: Reserve space in restorer for FPU frame
For code simplicity we reserve the maximum size which
might be needed to form an FPU frame (ie for both
xsave and fxsave operations).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:42 +04:00
Cyrill Gorcunov
10f22fe9ee restore: Change rt_sigcontext::fpstate to void *
It will be carrying xsave or fxsave frame.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:41 +04:00
Cyrill Gorcunov
c1f7ab2150 checkpoint: Add dumping of FPU state
The dumping of FPU state is done with help of ptrace
facility. There are two cases which we need to handle
depending on which features are available on host machine

1) The dump via ptrace(PTRACE_GETFPREGS ...)

   In this case the kernel will use fxsave approach
   inside the kenrel and provides us back the data
   encoded in i387_fxsave_struct format.

2) The dump via ptrace(PTRACE_GETREGSET ...)

   In this case the kernel will use xsave approach
   inside the kernel and provides us back the data
   encoded in xsave_struct format.

In any case we decode data and save it in protobuf format.
This is why core.proto file has been extended to keep new
entries.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:39 +04:00
Cyrill Gorcunov
8b93676d90 dump: Move assign_reg/assign_array closer to place where they are used
And don't forget to undef them once they are not needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:38 +04:00
Cyrill Gorcunov
1256c390b6 dump: Drop FPU padding allocation
Actually it was never used, just drop it.
Because of backward compatibility problem we
can't just zap it in protofile.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:37 +04:00
Cyrill Gorcunov
41ebf5c377 cpu: Add testing if host cpu is suitable to FPU c/r
The cpu we're running on must at least support fxsave feature.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:36 +04:00
Cyrill Gorcunov
cf2e6c54c9 cpu: Add code to fetch/test cpuinfo data
This patch add ability to test /proc/cpuinfo data
we're interested in at the moment.

The code provides the following functionality

 - cpu_init, to parse cpuinfo and check if the
   host cpu we're running on is suitable enough
   for FPU checkpoint/restore. If FPU present then
   there must be at least fxsave capability present

 - cpu_set_feature/cpu_has_feature helpers which
   provides to test certain bits and set them where
   needed (we need to set bits when parse cpuinfo)

Note, we reserve space for all cpuinfo bits known
by the kernel at moment, while use only three FPU
related bits for a while. This is done because we might
need to use or find out other features in future.

After all it's just 40 bytes of memory needed to keep
all possible bits.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:34 +04:00
Cyrill Gorcunov
666f4ebbe9 fpu: Add fpu.h header
We will need these structures for restore FPU
state via sigframe, as as we decode data provided
by ptrace.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:33 +04:00
Andrey Vagin
2701316b46 dump: remove debug messages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-20 16:08:12 +04:00