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

4796 Commits

Author SHA1 Message Date
Cyrill Gorcunov
1e7bbd35de restore: Add threads restoration
Now threads restortion (and TLS as well) works.
Threads test reports the following

    2775 (main): Counter value:    3 tls_data =    1
    2775 (main): ( 0) fsgs_base 7f9597aa46f0
    2775 (main): ( 0) fsgs_base        0
    2775 (thr3): Counter value:    4 tls_data =    4
    2775 (thr3): ( 0) fsgs_base 42c57940
    2775 (thr3): ( 0) fsgs_base        0
    2775 (thr2): Counter value:    3 tls_data =    2
    2775 (thr2): ( 0) fsgs_base 42456940
    2775 (thr2): ( 0) fsgs_base        0
    2775 (thr1): Counter value:    4 tls_data =    3
    2775 (thr1): ( 0) fsgs_base 40c62940
    2775 (thr1): ( 0) fsgs_base        0
    2775 (main): Counter value:    4 tls_data =    1
    2775 (main): ( 0) fsgs_base 7f9597aa46f0
    2775 (main): ( 0) fsgs_base        0
    2775 (thr1): Counter value:    5 tls_data =    3
    2775 (thr1): ( 0) fsgs_base 40c62940
    2775 (thr1): ( 0) fsgs_base        0

as expected.

This commits merges all preliminary commits into
the final one (sigreturn branch was always experimental
and forced update).

Still some problems remain:

1) While creating threads with clone() the
   flags are to be revisited. We use some predefined
   set here but it's not really correct.

2) No setup of pids in PCB thread zone.

3) No restore of FPU.

But at least on some basic tasks restore works well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-12 19:26:40 +04:00
Cyrill Gorcunov
db2064811d dump: Add missing newline in error message
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-09 13:00:12 +04:00
Cyrill Gorcunov
0a26593a3b dump, restore: Add blocked signals mask
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-09 00:29:41 +04:00
Cyrill Gorcunov
73e64bec27 restorer: Setup task data via prctl
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 18:25:02 +04:00
Cyrill Gorcunov
566a900e4e restore: Use prctl for vDSO restoration
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 17:53:47 +04:00
Cyrill Gorcunov
a4d37dcf67 kernel: Add patches needed
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 17:53:17 +04:00
Cyrill Gorcunov
76df6d9ed5 syscalls: Add sys_prctl helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 16:39:21 +04:00
Cyrill Gorcunov
b50ee4a175 Update kernel area
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 15:16:06 +04:00
Cyrill Gorcunov
83c209ef07 Move vma prot setup into parsing helper
To shrink restorer code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 13:54:01 +04:00
Cyrill Gorcunov
35502c4564 restore: Add PROT_GROWSDOWN for stack area
Since we stick with x86 for a while.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 13:48:10 +04:00
Cyrill Gorcunov
0355f1d23a dump: Don't fail on dumping paths for anon shared mappings
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 13:25:15 +04:00
Cyrill Gorcunov
c07a4b2caa restore: Don't forget to close file descriptors on VMAs
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 12:20:28 +04:00
Cyrill Gorcunov
b9d0883d76 dump: Anonymous shared mappings should have MAP_ANONYMOUS flag
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 12:19:43 +04:00
Cyrill Gorcunov
20c3bf1033 restore: 32k of stack memory is enough
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 01:44:40 +04:00
Cyrill Gorcunov
099c9c0016 dump: Don't forget to save MAP_ANONYMOUS if it was there
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 00:39:21 +04:00
Cyrill Gorcunov
275e97c77d restore: Increase the stack size for cloned processes
Wasted a couple of hours trying to resolve this non-obvious
issue. It's because bootstrapping the restorer code might
requre more memory than 16K on stack. Strictly speaking
we need a compile time constant here and BUG_ON.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 22:58:18 +04:00
Cyrill Gorcunov
b78c664bca restore: Fixup pstree reading
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 20:18:38 +04:00
Cyrill Gorcunov
3b7a4cbe09 restorer: Start using sigreturn_restore
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 19:14:28 +04:00
Cyrill Gorcunov
7e481f89f9 restore: Add GS-TLS handling
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 17:44:24 +04:00
Cyrill Gorcunov
da8f61c1c8 dump: Add GS-TLS handling
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 17:44:00 +04:00
Cyrill Gorcunov
1f7018a15c restore: Update fsindex and fs base in sake of TLS
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 17:34:59 +04:00
Cyrill Gorcunov
8a8850d146 dump: Dump TLS via sys_arch_prctl
As such -- no need for kernel patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 16:29:36 +04:00
Cyrill Gorcunov
3725fd326d syscalls: Add sys_arch_prctl helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 15:24:07 +04:00
Cyrill Gorcunov
d6e7afe3d8 syscalls: Add sys_set/get_thread_area helpers
They are actually banned in kernel for now, but
we might end up needing them, so better to have
them in-place.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 14:47:04 +04:00
Cyrill Gorcunov
cb7a9a524d restore: Add restorer bootstrap mmap hint
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-06 01:49:57 +04:00
Cyrill Gorcunov
b69aeb9a26 restore: Don't continue on opening vmas file failure
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-05 01:39:21 +04:00
Cyrill Gorcunov
34c72fc9f6 restore: Add some more debug printing
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-04 18:45:47 +04:00
Cyrill Gorcunov
bf30aa1130 restore: Drop unused struct partial_pt_regs
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 19:31:07 +04:00
Cyrill Gorcunov
2ae009ac1b restore: Don't forget to free temporary self VMAs
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 19:11:27 +04:00
Cyrill Gorcunov
9e5b145aff restore: Drop dead code, comments
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 18:24:23 +04:00
Cyrill Gorcunov
f63777d2be restorer: Setup rt_sigframe to a proper address
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 15:24:40 +04:00
Cyrill Gorcunov
345834ecee test: Add prints out in static test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 15:24:08 +04:00
Cyrill Gorcunov
489745f235 restore: A number of fixups and debug printing
An idea is to align restorer size to be sure it
wont be stripped in a middle of code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 11:58:45 +04:00
Cyrill Gorcunov
ed3c4fbacf syscalls: Get rid of mnemonic names for registers
Use explicit registers name instead just to be sure it
wont cause side effects on most gcc versions.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-03 11:55:29 +04:00
Cyrill Gorcunov
48371f729a test: Add static sleep test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-31 20:37:50 +04:00
Cyrill Gorcunov
6898d7f113 restore: Drop a few more write_hex_n
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-31 18:35:16 +04:00
Cyrill Gorcunov
6a3c7ab3b9 restore: Drop no longer needed printing
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-31 18:19:53 +04:00
Cyrill Gorcunov
bf41dcac48 syscalls: Get rid of register variables
It's been found that gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
ignores register variables so to be on a safe side rewrite
syscalls with inline assembly without them.

nb: gcc version 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC)
compiles them correctly.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-31 16:33:43 +04:00
Cyrill Gorcunov
5b6748b4c9 restore: Call for sigreturn
Prepare the stack value and do a syscall.
Still it fails because of stack corruption
I think and due to lack of setup of several
important values on thread-info area.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-29 20:42:45 +04:00
Cyrill Gorcunov
a50600c7f4 restore: Copy gprs to frame
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-29 01:43:43 +04:00
Cyrill Gorcunov
b99eae2809 restore: Add some more structures for frame setup
Some of them are already in system header files
but until I debug all things I simply picked up
kernel's definitions just to be more-less safe.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-29 01:13:32 +04:00
Cyrill Gorcunov
a74f379d60 syscall: Add sys_unlink
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-28 14:03:59 +04:00
Cyrill Gorcunov
b9004db89f restore: Align self-length on 16 bytes bound
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-28 00:47:56 +04:00
Cyrill Gorcunov
040131fd3b restore: Print out current pid in testing purpose
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-28 00:40:41 +04:00
Cyrill Gorcunov
98cf8f1a0f syscall: Add getpid syscall
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-28 00:40:20 +04:00
Cyrill Gorcunov
50d6423bc1 restore: Handle read-only VMAs
If VMA is read-only we need to make it
writable while read its contents, then
we should drop write permission.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-28 00:27:03 +04:00
Cyrill Gorcunov
5f91037703 restore: Implement local_sleep helper
Use it instead of pause insns to not burn cpu cycles.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-27 23:15:11 +04:00
Cyrill Gorcunov
8523721592 restore: Use MAP_ANONYMOUS for VMAs mapping for testing purpose
While files are not restored yet this flag is needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-27 23:01:34 +04:00
Cyrill Gorcunov
1cf388798d restorer: More readable tracepoints
And a pause at the end.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-27 19:55:42 +04:00
Cyrill Gorcunov
3c88046a18 restorer: Start real mapping restore procedure
At moment fails, but just to have a reference point.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-27 19:39:08 +04:00