Skip to content

Commit 19fadee

Browse files
Cyrill Gorcunovavagin
Cyrill Gorcunov
authored andcommitted
compel: plugins,std -- Implement syscalls in std plugin
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 <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
1 parent 35726a7 commit 19fadee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+311
-808
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ $(SOCCR_A): |soccr/built-in.o
228228
#
229229
# But note that we're already included
230230
# the nmk so we can reuse it there.
231-
criu/%: images/built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
231+
criu/%: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
232232
$(Q) $(MAKE) $(build)=criu $@
233-
criu: images/built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
233+
criu: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
234234
$(Q) $(MAKE) $(build)=criu all
235235
.PHONY: criu
236236

@@ -256,6 +256,7 @@ clean: subclean
256256
$(Q) $(MAKE) $(build)=soccr $@
257257
$(Q) $(MAKE) $(build)=lib $@
258258
$(Q) $(MAKE) $(build)=compel $@
259+
$(Q) $(MAKE) $(build)=compel/plugins $@
259260
.PHONY: clean
260261

261262
# mrproper depends on clean in nmk
@@ -265,6 +266,7 @@ mrproper: subclean
265266
$(Q) $(MAKE) $(build)=soccr $@
266267
$(Q) $(MAKE) $(build)=lib $@
267268
$(Q) $(MAKE) $(build)=compel $@
269+
$(Q) $(MAKE) $(build)=compel/plugins $@
268270
$(Q) $(RM) $(CONFIG_HEADER)
269271
$(Q) $(RM) $(SOCCR_CONFIG)
270272
$(Q) $(RM) $(VERSION_HEADER)

compel/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,3 @@ endif
4040
cleanup-y += compel/compel
4141
cleanup-y += compel/compel-host
4242
cleanup-y += compel/libcompel.so
43-
44-
#
45-
# FIXME Fake target for syscalls headers generation,
46-
# drop after syscalls generation.
47-
$(obj)/plugins/include/uapi/std/asm/syscall-types.h: $(obj)/arch/$(ARCH)/plugins/include/asm/syscall-types.h
48-
$(call msg-gen,$@)
49-
$(Q) ln -s ../../../../../arch/$(ARCH)/plugins/include/asm/syscall-types.h $@
50-
51-
cleanup-y += $(obj)/plugins/include/uapi/std/asm/syscall-types.h
52-
$(obj)/compel-host: $(obj)/plugins/include/uapi/std/asm/syscall-types.h
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../arm/plugins/std/syscalls/Makefile.syscalls
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../arm/plugins/std/syscalls/gen-sys-exec-tbl.pl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../arm/plugins/std/syscalls/gen-syscalls.pl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../arm/plugins/std/syscalls/syscall.def
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
2+
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
3+
4+
sys-types := $(obj)/include/uapi/std/syscall-types.h
5+
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
6+
sys-proto := $(obj)/include/uapi/std/syscall.h
7+
8+
sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
9+
sys-asm-common-name := std/syscalls/syscall-common.S
10+
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
11+
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
12+
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
13+
14+
sys-gen := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
15+
sys-gen-tbl := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-sys-exec-tbl.pl
16+
17+
sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
18+
std-obj-y += $(sys-asm:.S=).o
19+
20+
ifeq ($(ARCH),arm)
21+
arch_bits := 32
22+
else
23+
arch_bits := 64
24+
endif
25+
26+
sys-exec-tbl := sys-exec-tbl.c
27+
28+
$(sys-asm) $(sys-types) $(sys-codes) $(sys-proto): $(sys-gen) $(sys-def) $(sys-asm-common)
29+
$(E) " GEN " $@
30+
$(Q) perl \
31+
$(sys-gen) \
32+
$(sys-def) \
33+
$(sys-codes) \
34+
$(sys-proto) \
35+
$(sys-asm) \
36+
$(sys-asm-common-name) \
37+
$(sys-types) \
38+
$(arch_bits)
39+
40+
$(sys-asm:.S=).o: $(sys-asm)
41+
42+
$(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
43+
$(E) " GEN " $@
44+
$(Q) perl \
45+
$(sys-gen-tbl) \
46+
$(sys-def) \
47+
$(sys-exec-tbl) \
48+
$(arch_bits)
49+
50+
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
51+
$(call msg-gen, $@)
52+
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
53+
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
54+
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h
55+
56+
std-headers-deps += $(sys-codes) $(sys-proto) $(sys-asm-types)
57+
mrproper-y += $(std-headers-deps)
58+
mrproper-y += $(obj)/include/uapi/std/syscall-aux.S
59+
mrproper-y += $(obj)/include/uapi/std/syscall-aux.h

criu/arch/scripts/arm/gen-syscalls.pl renamed to compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
my $bits = $ARGV[6];
1818

1919
my $codesdef = $codes;
20-
$codesdef =~ tr/.-/_/;
20+
$codesdef =~ tr/.\-\//_/;
2121
my $protosdef = $protos;
22-
$protosdef =~ tr/.-/_/;
22+
$protosdef =~ tr/.\-\//_/;
2323
my $code = "code$bits";
2424
my $need_aux = 0;
2525

@@ -91,8 +91,8 @@ END
9191
}
9292

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

9898
print CODESOUT "#endif /* $codesdef */";
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
2+
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
3+
4+
sys-types := $(obj)/include/uapi/std/syscall-types.h
5+
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
6+
sys-proto := $(obj)/include/uapi/std/syscall.h
7+
8+
sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-ppc64.tbl
9+
sys-asm-common-name := std/syscalls/syscall-common-ppc64.S
10+
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
11+
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
12+
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
13+
14+
sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
15+
std-obj-y += $(sys-asm:.S=).o
16+
17+
$(sys-codes): $(sys-def)
18+
$(E) " GEN " $@
19+
$(Q) echo "/* Autogenerated, don't edit */" > $@
20+
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
21+
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
22+
$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
23+
'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
24+
'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@
25+
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
26+
27+
$(sys-proto): $(sys-def)
28+
$(E) " GEN " $@
29+
$(Q) echo "/* Autogenerated, don't edit */" > $@
30+
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
31+
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
32+
$(Q) echo "#include \"uapi/std/syscall-codes.h\"" >> $@
33+
$(Q) echo "#include \"uapi/std/syscall-types.h\"" >> $@
34+
$(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@
35+
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
36+
37+
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
38+
$(E) " GEN " $@
39+
$(Q) echo "/* Autogenerated, don't edit */" > $@
40+
$(Q) echo "#include \"uapi/std/syscall-codes.h\"" >> $@
41+
$(Q) echo "#include \"$(sys-asm-common-name)\"" >> $@
42+
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@
43+
44+
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
45+
$(E) " GEN " $@
46+
$(Q) echo "/* Autogenerated, don't edit */" > $@
47+
$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {" >> $@
48+
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@
49+
$(Q) echo " { }, /* terminator */" >> $@
50+
$(Q) echo "};" >> $@
51+
52+
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
53+
$(call msg-gen, $@)
54+
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
55+
56+
std-headers-deps += $(sys-codes) $(sys-proto) $(sys-asm-types)
57+
mrproper-y += $(std-headers-deps)
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
std-obj-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
2+
3+
sys-proto-types := $(obj)/include/uapi/std/syscall-types.h
4+
sys-proto-generic := $(obj)/include/uapi/std/syscall.h
5+
sys-codes-generic := $(obj)/include/uapi/std/syscall-codes.h
6+
sys-codes = $(obj)/include/uapi/std/syscall-codes-$(1).h
7+
sys-proto = $(obj)/include/uapi/std/syscall-$(1).h
8+
sys-def = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
9+
sys-asm = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
10+
sys-asm-common-name = std/syscalls/syscall-common-x86-$(1).S
11+
sys-asm-common = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
12+
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
13+
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
14+
15+
sys-bits := 64
16+
17+
AV := $$$$
18+
19+
define gen-rule-sys-codes
20+
$(sys-codes): $(sys-def) $(sys-proto-types)
21+
$(call msg-gen, $$@)
22+
$(Q) echo "/* Autogenerated, don't edit */" > $$@
23+
$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__" >> $$@
24+
$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__" >> $$@
25+
$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1; \
26+
sub("^__NR", "SYS", SYSN); \
27+
print "\n#ifndef ", $(AV)1; \
28+
print "#define", $(AV)1, $(AV)2; \
29+
print "#endif"; \
30+
print "\n#ifndef ", SYSN; \
31+
print "#define ", SYSN, $(AV)1; \
32+
print "#endif";}' >> $$@
33+
$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */" >> $$@
34+
endef
35+
36+
define gen-rule-sys-proto
37+
$(sys-proto): $(sys-def) $(sys-proto-types)
38+
$(call msg-gen, $$@)
39+
$(Q) echo "/* Autogenerated, don't edit */" > $$@
40+
$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
41+
$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
42+
$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"' >> $$@
43+
$(Q) echo '#include "uapi/std/syscall-types.h"' >> $$@
44+
ifeq ($(1),32)
45+
$(Q) echo '#include "asm/syscall32.h"' >> $$@
46+
endif
47+
$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3, \
48+
substr($(AV)0, index($(AV)0,$(AV)4)), ";"}' >> $$@
49+
$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */" >> $$@
50+
endef
51+
52+
define gen-rule-sys-asm
53+
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
54+
$(call msg-gen, $$@)
55+
$(Q) echo "/* Autogenerated, don't edit */" > $$@
56+
$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"' >> $$@
57+
$(Q) echo '#include "$(sys-asm-common-name)"' >> $$@
58+
$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}' >> $$@
59+
endef
60+
61+
define gen-rule-sys-exec-tbl
62+
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
63+
$(call msg-gen, $$@)
64+
$(Q) echo "/* Autogenerated, don't edit */" > $$@
65+
$(Q) cat $$< | awk '/^__NR/{print \
66+
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
67+
endef
68+
69+
$(sys-codes-generic): $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_32.tbl $(sys-proto-types)
70+
$(call msg-gen, $@)
71+
$(Q) echo "/* Autogenerated, don't edit */" > $@
72+
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
73+
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
74+
$(Q) echo '#include "uapi/std/syscall-codes-64.h"' >> $@
75+
$(Q) cat $< | awk '/^__NR/{NR32=$$1; \
76+
sub("^__NR", "__NR32", NR32); \
77+
print "\n#ifndef ", NR32; \
78+
print "#define ", NR32, $$2; \
79+
print "#endif";}' >> $@
80+
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
81+
mrproper-y += $(sys-codes-generic)
82+
83+
$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
84+
$(call msg-gen, $@)
85+
$(Q) echo "/* Autogenerated, don't edit */" > $@
86+
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
87+
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
88+
$(Q) echo "" >> $@
89+
$(Q) echo "#ifdef CONFIG_X86_32" >> $@
90+
$(Q) echo '#include "uapi/std/syscall-32.h"' >> $@
91+
$(Q) echo "#else" >> $@
92+
$(Q) echo '#include "uapi/std/syscall-64.h"' >> $@
93+
$(Q) echo "#endif /* CONFIG_X86_32 */" >> $@
94+
$(Q) echo "" >> $@
95+
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
96+
mrproper-y += $(sys-proto-generic)
97+
98+
define gen-rule-sys-exec-tbl
99+
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
100+
$(call msg-gen, $$@)
101+
$(Q) echo "/* Autogenerated, don't edit */" > $$@
102+
$(Q) cat $$< | awk '/^__NR/{print \
103+
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
104+
endef
105+
106+
$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
107+
$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
108+
$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
109+
$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
110+
111+
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
112+
$(call msg-gen, $@)
113+
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
114+
115+
std-headers-deps += $(call sys-codes,$(sys-bits))
116+
std-headers-deps += $(call sys-proto,$(sys-bits))
117+
std-headers-deps += $(call sys-asm,$(sys-bits))
118+
std-headers-deps += $(call sys-exec-tbl,$(sys-bits))
119+
std-headers-deps += $(sys-codes-generic)
120+
std-headers-deps += $(sys-proto-generic)
121+
std-headers-deps += $(sys-asm-types)
122+
mrproper-y += $(std-headers-deps)

0 commit comments

Comments
 (0)