cr: generalize the type to store the value of the TLS register

Supported machine architectures provide TLS stogares of different sizes:
the size of the TLS storage in x86-64 is 24 bytes, ARM --- 4 bytes
and upcoming AArch64 --- 8 bytes. This means every supported architecture
needs a specific type to store the value of the TLS register.

This patch reworks the insterface of the routines arch_get_tls()
and restore_tls() passing them the TLS storage by pointer
rather than by value to simplify the TLS stub for x86.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vdso: share the vDSO proxy initialization between all architectures

This patch splits the file arch/x86/vdso.c into machine-independent
and machine-dependent parts by moving the routine vdso_init()
from the file vdso.c. The routine seems to be suitable for all
architectures supporting the vDSO.

The ARM version of the routine is moved to the source vdso-stub.c
that is supposed to be the vDSO proxy stub implementation for
architectures that don't provide the vDSO. The build scripts are
adjusted as well to enable selection between the full-fledged
and stub vDSO proxy implementations.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vdso: make vDSO symbol names architecture-specific

This patch moves the enum VDSO_SYMBOL_* and macros VDSO_SYMBOL_*_NAME
to the x86 specific header since different architectures export
different symbols from their vDSOs.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vdso: rename vdso_x86_symbols to vdso_symbols

This patch makes the name of the vDSO symbol name table
a bit more appropriate for the generic version of
the routine vdso_fill_symtable().

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vdso: wrap the vDSO ELF identifier and symbol name table definitions into the macro

These variables are architecture-specific so they shouldn't appear
in the upcoming generic version of the routine vdso_fill_symtable().

At first glance it seems it's better to make these variables global
and reference them as external in the generic version of the routine.
However experiments with the vDSO restore routine for AArch64 showed
that the AArch64 compiler uses the GOT to access such variables
rendering our blobs unrelocatable.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vdso.c: share the PIE part of the vDSO proxy machinery between all architectures

This patch splits the file arch/x86/vdso-pie.c into machine-dependent
and machine-independent parts by moving the routines vdso_fill_symtable(),
vdso_proxify(), and vdso_remap() to the file pie/vdso.c.

The ARM version of the routines is moved to the source pie/vdso-stub.c
to provide the vDSO proxy stub implementation for architectures
that don't provide the vDSO.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mount: check bondaries in mount_resolve_path

The current code think that /vz/lxc/centos-6-x86_64-root is
in /vz/lxc/centos-6-x86_64.

If the path is not equal to mountpoint, we need to check, that
path contains a slash after mountpoint.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
libcriu: Add criu_set_root to the interface.

This function implements the --root command line option in libcriu.

Signed-off-by: Deyan Doychev <deyandoichev@gmail.com>
Reviewed-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
page-read: remove redundant initialisation

previous init of pr->parent at line 220

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: debug
zdtm: add test cases on TCP_FIN_WAIT* states

TCP_FIN_WAIT1 our side has shutdown, waiting to complete
              transmission of remaining buffered data

TCP_FIN_WAIT2 all buffered data sent, waiting for remote
              to shutdown
zdtm: add test cases on TCP_CLOSE_WAIT and TCP_LAST_ACK states

TCP_CLOSE_WAIT remote side has shutdown and is waiting for
               us to finish writing our data and to shutdown
               (we have to close() to move on to LAST_ACK)

TCP_LAST_ACK   out side has shutdown after remote has
               shutdown.  There may still be data in our
               buffer that we have to finish sending
zdtm: check sockets in the TCP_CLOSING state

TCP_CLOSING both sides have shutdown but we still have
            data we have to finish sending
tcp: add support of intermediate closing states

For restoring this state we need to queue a fin packet in one of both
direction. If we close output direction, a socket turns into FIN-WAIT.
If we close ingoing direction, a socket turns into CLOSE_WAIT.
If we close both directions, a socket turns into onf of LAST_ACK or
CLOSING, it depends on the order of closing.

The size of fin packet is 1, but it can be received, but fin packet
doesn't contain user data. For this reason we need to adjust the size
data in a send queue.

A conntroll message is used for sending fin packet, but it can't contain
real data because of
* fin packet can be sent after real data. In this case we can't return
  an error, because we must return the size of real data, which were sent.
  We can say that fin packet has size 1...
* A send queue is restored in two stages and the repair mode is disabled
  between them, but fin packet can be queued only if a socket is in
  repair mode.

Known issues: sk->shutdown isn't restore yet
tcp: allow to dump intermediate closing states
zdtm: add tests to check closing tcp states