Commit 74c0a702 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

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: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 31d394bc
...@@ -10,5 +10,7 @@ asflags-y += -iquote $(obj)/include ...@@ -10,5 +10,7 @@ asflags-y += -iquote $(obj)/include
obj-y += cpu.o obj-y += cpu.o
obj-y += crtools.o obj-y += crtools.o
obj-y += sigframe.o obj-y += sigframe.o
obj-y += sigaction_compat.o ifeq ($(CONFIG_COMPAT),y)
obj-y += call32.o obj-y += sigaction_compat.o
obj-y += call32.o
endif
...@@ -17,11 +17,9 @@ target := ...@@ -17,11 +17,9 @@ target :=
target_32 := syscalls-32 target_32 := syscalls-32
target_64 := syscalls-64 target_64 := syscalls-64
SYS-BITS := 32 SYS-BITS := 64
ifeq ($(CONFIG_COMPAT),y)
# native x86_64 SYS-BITS += 32
ifeq ($(ARCH),x86)
SYS-BITS += 64
endif endif
# targets # targets
......
...@@ -134,8 +134,6 @@ static inline void _setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas) ...@@ -134,8 +134,6 @@ static inline void _setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas)
int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r); int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r);
int restore_nonsigframe_gpregs(UserX86RegsEntry *r); int restore_nonsigframe_gpregs(UserX86RegsEntry *r);
void restore_tls(tls_t *ptls);
int ptrace_set_breakpoint(pid_t pid, void *addr); int ptrace_set_breakpoint(pid_t pid, void *addr);
int ptrace_flush_breakpoints(pid_t pid); int ptrace_flush_breakpoints(pid_t pid);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
int restore_nonsigframe_gpregs(UserX86RegsEntry *r) int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
{ {
#ifdef CONFIG_X86_64
long ret; long ret;
unsigned long fsgs_base; unsigned long fsgs_base;
...@@ -30,10 +29,10 @@ int restore_nonsigframe_gpregs(UserX86RegsEntry *r) ...@@ -30,10 +29,10 @@ int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
pr_info("SET_GS fail %ld\n", ret); pr_info("SET_GS fail %ld\n", ret);
return -1; return -1;
} }
#endif
return 0; return 0;
} }
#ifdef CONFIG_COMPAT
asm ( " .pushsection .text \n" asm ( " .pushsection .text \n"
" .global restore_set_thread_area \n" " .global restore_set_thread_area \n"
" .code32 \n" " .code32 \n"
...@@ -90,3 +89,4 @@ void restore_tls(tls_t *ptls) ...@@ -90,3 +89,4 @@ void restore_tls(tls_t *ptls)
if (stack32) if (stack32)
free_compat_syscall_stack(stack32); free_compat_syscall_stack(stack32);
} }
#endif
#ifdef CONFIG_X86_64
static struct syscall_exec_desc sc_exec_table_64[] = { static struct syscall_exec_desc sc_exec_table_64[] = {
#include "sys-exec-tbl-64.c" #include "sys-exec-tbl-64.c"
{ }, /* terminator */ { }, /* terminator */
}; };
#endif
#ifdef CONFIG_COMPAT
static struct syscall_exec_desc sc_exec_table_32[] = { static struct syscall_exec_desc sc_exec_table_32[] = {
#include "sys-exec-tbl-32.c" #include "sys-exec-tbl-32.c"
{ }, /* terminator */ { }, /* terminator */
}; };
#endif
struct syscall_exec_desc; struct syscall_exec_desc;
...@@ -26,7 +26,7 @@ find_syscall_table(char *name, struct syscall_exec_desc *tbl) ...@@ -26,7 +26,7 @@ find_syscall_table(char *name, struct syscall_exec_desc *tbl)
#define ARCH_HAS_FIND_SYSCALL #define ARCH_HAS_FIND_SYSCALL
/* overwrite default to search in two tables above */ /* overwrite default to search in two tables above */
#ifdef CONFIG_X86_64 #ifdef CONFIG_COMPAT
struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl) struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
{ {
if (seized_native(ctl)) if (seized_native(ctl))
...@@ -38,6 +38,6 @@ struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl) ...@@ -38,6 +38,6 @@ struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
struct syscall_exec_desc * struct syscall_exec_desc *
find_syscall(char *name, __always_unused struct parasite_ctl *ctl) find_syscall(char *name, __always_unused struct parasite_ctl *ctl)
{ {
return find_syscall_table(name, sc_exec_table_32); return find_syscall_table(name, sc_exec_table_64);
} }
#endif #endif
...@@ -299,11 +299,11 @@ void debug_show_page_pipe(struct page_pipe *pp) ...@@ -299,11 +299,11 @@ void debug_show_page_pipe(struct page_pipe *pp)
if (pp->flags & PP_COMPAT) { if (pp->flags & PP_COMPAT) {
iov_c = (void *)ppb->iov; iov_c = (void *)ppb->iov;
pr_debug("\t\t%x %lu\n", iov_c[i].iov_base, pr_debug("\t\t%x %lu\n", iov_c[i].iov_base,
iov_c[i].iov_len / PAGE_SIZE); (unsigned long) iov_c[i].iov_len / PAGE_SIZE);
} else { } else {
iov = &ppb->iov[i]; iov = &ppb->iov[i];
pr_debug("\t\t%p %lu\n", iov->iov_base, pr_debug("\t\t%p %lu\n", iov->iov_base,
iov->iov_len / PAGE_SIZE); (unsigned long) iov->iov_len / PAGE_SIZE);
} }
} }
} }
...@@ -313,11 +313,11 @@ void debug_show_page_pipe(struct page_pipe *pp) ...@@ -313,11 +313,11 @@ void debug_show_page_pipe(struct page_pipe *pp)
if (pp->flags & PP_COMPAT) { if (pp->flags & PP_COMPAT) {
iov_c = (void *)pp->holes; iov_c = (void *)pp->holes;
pr_debug("\t%x %lu\n", iov_c[i].iov_base, pr_debug("\t%x %lu\n", iov_c[i].iov_base,
iov_c[i].iov_len / PAGE_SIZE); (unsigned long) iov_c[i].iov_len / PAGE_SIZE);
} else { } else {
iov = &pp->holes[i]; iov = &pp->holes[i];
pr_debug("\t%p %lu\n", iov->iov_base, pr_debug("\t%p %lu\n", iov->iov_base,
iov->iov_len / PAGE_SIZE); (unsigned long) iov->iov_len / PAGE_SIZE);
} }
} }
} }
...@@ -1489,7 +1489,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, ...@@ -1489,7 +1489,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
if (seized_native(ctl)) if (seized_native(ctl))
parasite_size = pie_size(parasite_native); parasite_size = pie_size(parasite_native);
#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */ #ifdef CONFIG_COMPAT
else else
parasite_size = pie_size(parasite_compat); parasite_size = pie_size(parasite_compat);
#endif #endif
...@@ -1513,7 +1513,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, ...@@ -1513,7 +1513,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
if (seized_native(ctl)) if (seized_native(ctl))
init_parasite_ctl(ctl, native); init_parasite_ctl(ctl, native);
#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */ #ifdef CONFIG_COMPAT
else else
init_parasite_ctl(ctl, compat); init_parasite_ctl(ctl, compat);
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# restorer is always native (64-bit) # restorer is always native (64-bit)
parasite_target := native parasite_target := native
ifeq ($(ARCH),x86) ifeq ($(CONFIG_COMPAT),y)
parasite_target += compat parasite_target += compat
endif endif
...@@ -14,8 +14,11 @@ restorer-obj-y += ./$(ARCH_DIR)/restorer.o ...@@ -14,8 +14,11 @@ restorer-obj-y += ./$(ARCH_DIR)/restorer.o
ifeq ($(ARCH),x86) ifeq ($(ARCH),x86)
restorer-obj-e += ./$(ARCH_DIR)/syscalls-64.built-in.o restorer-obj-e += ./$(ARCH_DIR)/syscalls-64.built-in.o
restorer-obj-y += ./$(ARCH_DIR)/call32.o
restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o ifeq ($(CONFIG_COMPAT),y)
restorer-obj-y += ./$(ARCH_DIR)/call32.o
restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o
endif
native-obj-y += ./$(ARCH_DIR)/parasite-head-64.o native-obj-y += ./$(ARCH_DIR)/parasite-head-64.o
native-obj-e += ./$(ARCH_DIR)/syscalls-64.built-in.o native-obj-e += ./$(ARCH_DIR)/syscalls-64.built-in.o
......
...@@ -6,11 +6,12 @@ CFLAGS += -Wa,--noexecstack -fno-stack-protector -DCR_NOGLIBC ...@@ -6,11 +6,12 @@ CFLAGS += -Wa,--noexecstack -fno-stack-protector -DCR_NOGLIBC
CFLAGS_native += -fpie CFLAGS_native += -fpie
ifeq ($(ARCH),x86) ifeq ($(ARCH),x86)
target += compat ifeq ($(CONFIG_COMPAT),y)
target += compat
native-lib-y += util-vdso-elf32.o
endif
CFLAGS_native += -DCONFIG_X86_64 CFLAGS_native += -DCONFIG_X86_64
CFLAGS_compat += -fno-pic -m32 -DCONFIG_X86_32 CFLAGS_compat += -fno-pic -m32 -DCONFIG_X86_32
native-lib-y += util-vdso-elf32.o
CFLAGS_util-vdso-elf32.o += -DCONFIG_X86_32 CFLAGS_util-vdso-elf32.o += -DCONFIG_X86_32
endif endif
......
#include "parasite-native-blob.h" #include "parasite-native-blob.h"
#ifdef CONFIG_X86_64 #ifdef CONFIG_COMPAT
# include "parasite-compat-blob.h" # include "parasite-compat-blob.h"
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment