Skip to content

Commit

Permalink
compel: plugins,std -- Implement syscalls in std plugin
Browse files Browse the repository at this point in the history
And use it in CRIU directly instead:

 - move syscalls into compel/arch/ARCH/plugins/std/syscalls
 - drop old symlinks
 - no build for 32bit on x86 as expected
 - use std.built-in.o inside criu directly (compel_main stub)
 - drop syscalls on x86 criu directory, I copied them already
   in first compel commist, so we can't move them now, but
   delete in place

Signed-off-by: Cyrill Gorcunov <[email protected]>
Signed-off-by: Pavel Emelyanov <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
  • Loading branch information
Cyrill Gorcunov authored and avagin committed Mar 14, 2017
1 parent 35726a7 commit 19fadee
Show file tree
Hide file tree
Showing 46 changed files with 311 additions and 808 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ $(SOCCR_A): |soccr/built-in.o
#
# But note that we're already included
# the nmk so we can reuse it there.
criu/%: images/built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
criu/%: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
$(Q) $(MAKE) $(build)=criu $@
criu: images/built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
criu: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
$(Q) $(MAKE) $(build)=criu all
.PHONY: criu

Expand All @@ -256,6 +256,7 @@ clean: subclean
$(Q) $(MAKE) $(build)=soccr $@
$(Q) $(MAKE) $(build)=lib $@
$(Q) $(MAKE) $(build)=compel $@
$(Q) $(MAKE) $(build)=compel/plugins $@
.PHONY: clean

# mrproper depends on clean in nmk
Expand All @@ -265,6 +266,7 @@ mrproper: subclean
$(Q) $(MAKE) $(build)=soccr $@
$(Q) $(MAKE) $(build)=lib $@
$(Q) $(MAKE) $(build)=compel $@
$(Q) $(MAKE) $(build)=compel/plugins $@
$(Q) $(RM) $(CONFIG_HEADER)
$(Q) $(RM) $(SOCCR_CONFIG)
$(Q) $(RM) $(VERSION_HEADER)
Expand Down
10 changes: 0 additions & 10 deletions compel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,3 @@ endif
cleanup-y += compel/compel
cleanup-y += compel/compel-host
cleanup-y += compel/libcompel.so

#
# FIXME Fake target for syscalls headers generation,
# drop after syscalls generation.
$(obj)/plugins/include/uapi/std/asm/syscall-types.h: $(obj)/arch/$(ARCH)/plugins/include/asm/syscall-types.h
$(call msg-gen,$@)
$(Q) ln -s ../../../../../arch/$(ARCH)/plugins/include/asm/syscall-types.h $@

cleanup-y += $(obj)/plugins/include/uapi/std/asm/syscall-types.h
$(obj)/compel-host: $(obj)/plugins/include/uapi/std/asm/syscall-types.h
1 change: 1 addition & 0 deletions compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls
1 change: 1 addition & 0 deletions compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions compel/arch/aarch64/plugins/std/syscalls/syscall.def
59 changes: 59 additions & 0 deletions compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/

sys-types := $(obj)/include/uapi/std/syscall-types.h
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
sys-proto := $(obj)/include/uapi/std/syscall.h

sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
sys-asm-common-name := std/syscalls/syscall-common.S
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c

sys-gen := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
sys-gen-tbl := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-sys-exec-tbl.pl

sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-obj-y += $(sys-asm:.S=).o

ifeq ($(ARCH),arm)
arch_bits := 32
else
arch_bits := 64
endif

sys-exec-tbl := sys-exec-tbl.c

$(sys-asm) $(sys-types) $(sys-codes) $(sys-proto): $(sys-gen) $(sys-def) $(sys-asm-common)
$(E) " GEN " $@
$(Q) perl \
$(sys-gen) \
$(sys-def) \
$(sys-codes) \
$(sys-proto) \
$(sys-asm) \
$(sys-asm-common-name) \
$(sys-types) \
$(arch_bits)

$(sys-asm:.S=).o: $(sys-asm)

$(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
$(E) " GEN " $@
$(Q) perl \
$(sys-gen-tbl) \
$(sys-def) \
$(sys-exec-tbl) \
$(arch_bits)

$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h

std-headers-deps += $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y += $(std-headers-deps)
mrproper-y += $(obj)/include/uapi/std/syscall-aux.S
mrproper-y += $(obj)/include/uapi/std/syscall-aux.h
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
my $bits = $ARGV[6];

my $codesdef = $codes;
$codesdef =~ tr/.-/_/;
$codesdef =~ tr/.\-\//_/;
my $protosdef = $protos;
$protosdef =~ tr/.-/_/;
$protosdef =~ tr/.\-\//_/;
my $code = "code$bits";
my $need_aux = 0;

Expand Down Expand Up @@ -91,8 +91,8 @@ END
}

if ($need_aux == 1) {
print ASMOUT "#include \"asm/syscall-aux.S\"\n";
print CODESOUT "#include \"asm/syscall-aux.h\"\n";
print ASMOUT "#include \"uapi/std/syscall-aux.S\"\n";
print CODESOUT "#include \"uapi/std/syscall-aux.h\"\n";
}

print CODESOUT "#endif /* $codesdef */";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/

sys-types := $(obj)/include/uapi/std/syscall-types.h
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
sys-proto := $(obj)/include/uapi/std/syscall.h

sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-ppc64.tbl
sys-asm-common-name := std/syscalls/syscall-common-ppc64.S
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c

sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-obj-y += $(sys-asm:.S=).o

$(sys-codes): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@

$(sys-proto): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#include \"uapi/std/syscall-codes.h\"" >> $@
$(Q) echo "#include \"uapi/std/syscall-types.h\"" >> $@
$(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@

$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#include \"uapi/std/syscall-codes.h\"" >> $@
$(Q) echo "#include \"$(sys-asm-common-name)\"" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@

$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@
$(Q) echo " { }, /* terminator */" >> $@
$(Q) echo "};" >> $@

$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)

std-headers-deps += $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y += $(std-headers-deps)
File renamed without changes.
122 changes: 122 additions & 0 deletions compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
std-obj-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o

sys-proto-types := $(obj)/include/uapi/std/syscall-types.h
sys-proto-generic := $(obj)/include/uapi/std/syscall.h
sys-codes-generic := $(obj)/include/uapi/std/syscall-codes.h
sys-codes = $(obj)/include/uapi/std/syscall-codes-$(1).h
sys-proto = $(obj)/include/uapi/std/syscall-$(1).h
sys-def = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
sys-asm = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
sys-asm-common-name = std/syscalls/syscall-common-x86-$(1).S
sys-asm-common = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c

sys-bits := 64

AV := $$$$

define gen-rule-sys-codes
$(sys-codes): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1; \
sub("^__NR", "SYS", SYSN); \
print "\n#ifndef ", $(AV)1; \
print "#define", $(AV)1, $(AV)2; \
print "#endif"; \
print "\n#ifndef ", SYSN; \
print "#define ", SYSN, $(AV)1; \
print "#endif";}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */" >> $$@
endef

define gen-rule-sys-proto
$(sys-proto): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"' >> $$@
$(Q) echo '#include "uapi/std/syscall-types.h"' >> $$@
ifeq ($(1),32)
$(Q) echo '#include "asm/syscall32.h"' >> $$@
endif
$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3, \
substr($(AV)0, index($(AV)0,$(AV)4)), ";"}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */" >> $$@
endef

define gen-rule-sys-asm
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"' >> $$@
$(Q) echo '#include "$(sys-asm-common-name)"' >> $$@
$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}' >> $$@
endef

define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef

$(sys-codes-generic): $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_32.tbl $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo '#include "uapi/std/syscall-codes-64.h"' >> $@
$(Q) cat $< | awk '/^__NR/{NR32=$$1; \
sub("^__NR", "__NR32", NR32); \
print "\n#ifndef ", NR32; \
print "#define ", NR32, $$2; \
print "#endif";}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
mrproper-y += $(sys-codes-generic)

$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "" >> $@
$(Q) echo "#ifdef CONFIG_X86_32" >> $@
$(Q) echo '#include "uapi/std/syscall-32.h"' >> $@
$(Q) echo "#else" >> $@
$(Q) echo '#include "uapi/std/syscall-64.h"' >> $@
$(Q) echo "#endif /* CONFIG_X86_32 */" >> $@
$(Q) echo "" >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
mrproper-y += $(sys-proto-generic)

define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef

$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))

$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)

std-headers-deps += $(call sys-codes,$(sys-bits))
std-headers-deps += $(call sys-proto,$(sys-bits))
std-headers-deps += $(call sys-asm,$(sys-bits))
std-headers-deps += $(call sys-exec-tbl,$(sys-bits))
std-headers-deps += $(sys-codes-generic)
std-headers-deps += $(sys-proto-generic)
std-headers-deps += $(sys-asm-types)
mrproper-y += $(std-headers-deps)
Loading

0 comments on commit 19fadee

Please sign in to comment.