[CRIU] [PATCH 11/11] arch: x86-32 -- Be able to build 32bit CRIU
Cyrill Gorcunov
gorcunov at openvz.org
Wed Apr 22 10:20:06 PDT 2015
After this patch one can run ARCH="ia32" make to build
32bit version on CRIU on 64bit host. Note this is only
build procedure which tuned up, the CRIU itself is not
yet ready to make a checkpoint/restore cycle -- a lot
of additional code is needed and here we rather put
stubs simply to make build procedure run.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Makefile | 10 ++++++++++
arch/x86/Makefile | 2 +-
arch/x86/include/asm/restore.h | 9 +++++++++
arch/x86/include/asm/restorer.h | 23 ++++++++++++++++++++++-
arch/x86/restorer.c | 3 ++-
arch/x86/vdso-pie.c | 29 +++++++++++++++++++++++++++++
6 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index ed2a1992efd5..bf315a086e8d 100644
--- a/Makefile
+++ b/Makefile
@@ -60,6 +60,16 @@ ifeq ($(ARCH),x86_64)
LDARCH := i386:x86-64
VDSO := y
endif
+ifeq ($(ARCH),ia32)
+ SRCARCH := x86
+ DEFINES := -DCONFIG_X86_32
+ LDARCH := i386
+ ldflags-y += -m elf_i386
+ VDSO := y
+ USERCFLAGS += -m32
+ PROTOUFIX := y
+ export PROTOUFIX ldflags-y
+endif
ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm)
ARMV := $(shell echo $(ARCH) | sed -nr 's/armv([[:digit:]]).*/\1/p; t; i7')
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 37fc491e54dd..ec1ad68973e1 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -29,7 +29,7 @@ syscalls-asm-y-asmflags := -Wstrict-prototypes -Wa,--noexecstack
endif
syscalls-asm-y-asmflags += -nostdlib -fomit-frame-pointer -I$(obj)
-ifeq ($(ARCH),i386)
+ifneq ($(filter i386 ia32,$(ARCH)),)
syscalls-obj-y += syscalls/syscall32.o
$(obj)/syscalls/syscall32.o: $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO)
endif
diff --git a/arch/x86/include/asm/restore.h b/arch/x86/include/asm/restore.h
index 7c39e0060e34..9d39b2bbae50 100644
--- a/arch/x86/include/asm/restore.h
+++ b/arch/x86/include/asm/restore.h
@@ -5,6 +5,7 @@
#include "protobuf/core.pb-c.h"
+#ifdef CONFIG_X86_64
#define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \
task_args) \
asm volatile( \
@@ -18,6 +19,14 @@
"g"(restore_task_exec_start), \
"g"(task_args) \
: "rsp", "rdi", "rsi", "rbx", "rax", "memory")
+#else /* CONFIG_X86_64 */
+#define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \
+ task_args) \
+ (void)new_sp; \
+ (void)restore_task_exec_start; \
+ (void)task_args; \
+ ;
+#endif /* CONFIG_X86_64 */
#define core_get_tls(pcore, ptls)
diff --git a/arch/x86/include/asm/restorer.h b/arch/x86/include/asm/restorer.h
index c04fb9426799..4e457dad52a3 100644
--- a/arch/x86/include/asm/restorer.h
+++ b/arch/x86/include/asm/restorer.h
@@ -72,7 +72,7 @@ struct rt_sigframe {
fpu_state_t fpu_state;
};
-
+#ifdef CONFIG_X86_64
#define ARCH_RT_SIGRETURN(new_sp) \
asm volatile( \
"movq %0, %%rax \n" \
@@ -129,6 +129,27 @@ struct rt_sigframe {
: \
: "r"(ret) \
: "memory")
+#else /* CONFIG_X86_64 */
+#define ARCH_RT_SIGRETURN(new_sp) \
+ ;
+#define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \
+ thread_args, clone_restore_fn) \
+ (void)ret; \
+ (void)clone_flags; \
+ (void)new_sp; \
+ (void)parent_tid; \
+ (void)thread_args; \
+ (void)clone_restore_fn; \
+ ;
+#define ARCH_FAIL_CORE_RESTORE \
+ asm volatile( \
+ "movl %0, %%esp \n" \
+ "xorl %%eax, %%eax \n" \
+ "jmp *%%rax \n" \
+ : \
+ : "r"(ret) \
+ : "memory")
+#endif /* CONFIG_X86_64 */
#define RT_SIGFRAME_UC(rt_sigframe) rt_sigframe->uc
#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.rip
diff --git a/arch/x86/restorer.c b/arch/x86/restorer.c
index 8dc5ac452ce9..364b156be91e 100644
--- a/arch/x86/restorer.c
+++ b/arch/x86/restorer.c
@@ -11,6 +11,7 @@
int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
{
+#ifdef CONFIG_X86_64
long ret;
unsigned long fsgs_base;
@@ -27,6 +28,6 @@ int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
pr_info("SET_GS fail %ld\n", ret);
return -1;
}
-
+#endif
return 0;
}
diff --git a/arch/x86/vdso-pie.c b/arch/x86/vdso-pie.c
index da86a5bc6b77..5330531c7623 100644
--- a/arch/x86/vdso-pie.c
+++ b/arch/x86/vdso-pie.c
@@ -26,6 +26,7 @@
#endif
#define LOG_PREFIX "vdso: "
+#ifdef CONFIG_X86_64
typedef struct {
u16 movabs;
u64 imm64;
@@ -438,3 +439,31 @@ int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
sys_mprotect((void *)vdso_rt_parked_at, vdso_vma_size(sym_rt), VDSO_PROT);
return 0;
}
+
+#else /* CONFIG_X86_64 */
+
+int vdso_redirect_calls(void *base_to, void *base_from,
+ struct vdso_symtable *to,
+ struct vdso_symtable *from)
+{
+ return 0;
+}
+
+int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
+{
+ return 0;
+}
+
+int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned long park_size)
+{
+ return 0;
+}
+
+int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
+ unsigned long vdso_rt_parked_at, size_t index,
+ VmaEntry *vmas, size_t nr_vmas)
+{
+ return 0;
+}
+
+#endif /* CONFIG_X86_64 */
--
2.1.0
More information about the CRIU
mailing list