The section 5.2.1.2 of the AAPCS says that the stack must be 8-byte aligned
and this rule is broken when the thread restore_task_with_children()
is forked by the function fork_with_pid() since the variable ca
and its field stack are likely to be 4-byte aligned.
This patch forces 8-byte alingment of the field cr_clone_arg::stack.
This made the following tests pass on ARM:
* static/shm,
* static/ipc_namespace.
Particulary the unaligned stack results in incorrect passing
of the 64-bit argument to the function snprintf() in the function
sysctl_write_u64().
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
No need for multiple sed calls, better pass
all options in once.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Andrew Vagin pointed out that the static testsuite compilation
may run as standalone so the variable ARCH won't be available.
This patch introduces the facility test/zdtm/Makefile.inc
designated to detect the target machine automatically
if the variable ARCH isn't defined. This makefile is supposed
to be included into all test subsuite Makefiles.
Andrew Vagin also pointed out that machine-dependent tests
may be added into non-static subsuites as well so the macro
adding machine-specific headers into CPPFLAGS goes to
the file test/zdtm/Makefile.inc.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This patch introduce dependencies on .c files
generation parsing import keywords in .proto
files.
In particular, the core.proto file refers to
core-x86.proto which means we need to generate
.[c|h] files from core-x86.proto earlier than
handlig of core.proto.
A positive side effect of this patch is that
the compilation is independent now of order the
proto files are declated in the make file.
Instead of currently present manual order
PROTO_FILES += core-x86.proto
PROTO_FILES += core-arm.proto
PROTO_FILES += core.proto
one can write it in any arrangement, say
PROTO_FILES += core.proto
PROTO_FILES += core-arm.proto
PROTO_FILES += core-x86.proto
and it still be resolved correctly.
BUT beware of circular import directives,
we can't handle them now.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Some protobuf files do import another files so
we should generate dependencies and rebuild
the program when needed.
For example core.proto imports core-x86.proto
and core-arm.proto, thus if any of them are
changed the final core.pb-c.c should be regenerated.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's known to work on x86-64 so make the build procedure
a bit faster here.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Actually the former code was being expanding
uname_M variable which is not set that early
(this was not a problem since we assign it a
line below, still it was a dead code which
should be fixed).
Also update
| ifeq ($(findstring arm,$(ARCH)),arm)
to simple
| ifeq ($(ARCH),arm)
Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
To unweave arch dependent part from general core.proto file.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We do check for proper architectrue in a makefile,
no need for additional guards.
After all porting the project for x86-32 is a far more
bigger than "just implement proper core for parts covered
by #else /* CONFIG_X86_64 */".
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Since we don't support x86-32 yet, issue an error early.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The file lib/atomic.h is the only machine-dependent file in the test suite
that breaks compilation of the test static/session01 on ARM.
The file is moved into a separate directory and the build system is modified
accordingly to prevent this.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
All tests which executed in pid namespaces can be executed in parallel.
$ make zdtm_ns
real 0m54.806s
user 0m2.779s
sys 0m4.338s
$ make -j zdtm_ns
real 0m11.587s
user 0m3.361s
sys 0m5.134s
Another feature of this patch is that the subset of parallel tests is
executed before the subset of sequential tests.
If a first subset are not failed, the second one has a small chance to
fail, so a most part of bugs will be found in a few first seconds.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
In this case they will be executed in other name-spaces.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This patch can be committed instead of:
[PATCH 1/6] cr-dump: move parasite_drain_fds_seized out of dump_task_files
[PATCH 2/6] cr-dump: fix dumping file locks in a mount namespace
readlink is not required here and a file can be unavailable,
if a process is in another mnt namespace
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On glibc-2.16 I'm getting
| sched_prio00.c: In function ‘main’:
| sched_prio00.c:48:3: error: implicit declaration of function ‘setpriority’ [-Werror=implicit-function-declaration]
| sched_prio00.c:48:19: error: ‘PRIO_PROCESS’ undeclared (first use in this function)
| sched_prio00.c:48:19: note: each undeclared identifier is reported only once for each function it appears in
| sched_prio00.c:60:3: error: implicit declaration of function ‘getpriority’ [-Werror=implicit-function-declaration]
fix it adding headers needed.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When we've read all pstree-items and their ids we
can get the desired clone-flags early and avoid all
these dances with flag calculations in fork_with_pid
and company.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Helpers don't have any IDs on board and thus checks for "is
my X shared with parent" will be wrong.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
In old images we had no clue whether the root task is to be
created in new namespaces. Remember using the --namespaces
option for explicitl specification of this fact.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's no longer required to use this option -- two currently
supported cases (tasks on host and tasks in containers) can
be detected automatically. Keep this option for future.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Introduce the current_ns_mask variable, that collects info about
which namespaces tasks being dumped and to be restored live in.
For simlicity all tasks are supposed to live in one set of spaces.
This should be fixed eventually.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's required to know whether the root task lives in
namespaces very very early (e.g. -- to lock the network
properly). Thus we have to collect task IDs right at
the time we collect the tasks themselves.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On restore we'll need to know whether the root task should be
cloned in new set of namespaces. It's natural to do it by
comparing root ids with some "other-world" IDs.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The recent kernels allow to get namespaces IDs by reading proc-ns links.
Use this to generate IDs for tasks' namespaces (I do generate them, since
IDs provided by kernel look ugly :( ).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
These functions are designated to convert a native pointer
to uint64_t used to store a virtual address in protobuf messages
and vice versa in a machine-independent way.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
If a task executes a non-userspace code (that sometimes takes place on ARM)
while being seized the subsequent infection with the syscall blob fails
because ptrace fails to write to the VMA the PC is in.
The patch modifies the function get_vma_by_ip() to check the PC of the task
being seized is below the TASK_SIZE boundary. If the check fails
the first suitable VMA is infected.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This patch prevents compilation warnings about shift overflow on ARM.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>