[CRIU] [PATCH 3/4] arm: refactor the syscall glue to support ARMv6

Alexander Kartashov alekskartashov at parallels.com
Wed Jul 10 02:15:56 EDT 2013


This patch modifies the ARM syscall glue as follows:

* the macros syscallX that produce different code
  for syscalls with different number of arguments
  are replaced by the generic syscall thunk copied
  from libc;

* the syscall tables generation script is simplified
  since the syscall argument number analysis is redundant;

* the ARMv7 specific instruction MOVW is eliminated.

Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>

---
 arch/arm/gen-syscalls.pl           |   16 +--------
 arch/arm/include/asm/syscall-aux.S |   22 ++++++++-----
 arch/arm/syscall-common.S          |   64 ++++++++++--------------------------
 3 files changed, 31 insertions(+), 71 deletions(-)

diff --git a/arch/arm/gen-syscalls.pl b/arch/arm/gen-syscalls.pl
index 4b65621..ee52112 100755
--- a/arch/arm/gen-syscalls.pl
+++ b/arch/arm/gen-syscalls.pl
@@ -72,21 +72,7 @@ for (<IN>) {
 
 	if ($+{$code} ne "!") {
 		print CODESOUT "#define $code_macro $+{$code}\n";
-
-		my $nargs;
-
-		if ($+{args} eq "void") {
-			$nargs = 0;
-		} else {
-			my $tmp = $+{args};
-			$nargs = 1 + ($tmp =~ tr/\,/\,/);
-
-			if ($nargs <= 4) {
-			$nargs = 0;
-		}
-	}
-
-	print ASMOUT "syscall$nargs $sys_name, $code_macro\n";
+		print ASMOUT "syscall $sys_name, $code_macro\n";
 
 	} else {
 		$need_aux = 1;
diff --git a/arch/arm/include/asm/syscall-aux.S b/arch/arm/include/asm/syscall-aux.S
index 77e1397..8bc01c3 100644
--- a/arch/arm/include/asm/syscall-aux.S
+++ b/arch/arm/include/asm/syscall-aux.S
@@ -1,9 +1,13 @@
-        ENTRY(sys_mmap)
-        push    { %r4, %r5, %r7 }
-        ldr     %r4, [%sp, #12]
-        ldr     %r5, [%sp, #16]
-	lsr	%r5, #12
-        do_sys  192
-        pop     { %r4, %r5, %r7 }
-        bx      %lr
-        END(sys_mmap)
\ No newline at end of file
+nr_sys_mmap:
+	.long	192
+
+ENTRY(sys_mmap)
+	push	{%r4, %r5, %r7, %lr}
+	ldr		%r4, [%sp, #16]
+	ldr		%r5, [%sp, #20]
+	lsr		%r5, #12
+	adr		%r7, nr_sys_mmap
+	ldr		%r7, [%r7]
+	svc		0x00000000
+	pop		{%r4, %r5, %r7, %pc}
+END(sys_mmap)
diff --git a/arch/arm/syscall-common.S b/arch/arm/syscall-common.S
index 58d0878..bad9dc5 100644
--- a/arch/arm/syscall-common.S
+++ b/arch/arm/syscall-common.S
@@ -1,56 +1,26 @@
 #include "asm/linkage.h"
 
-        .macro mov_r7 imm
-        mov %r7, #\imm
-        .endm
+syscall_common:
+	ldr	%r7, [%r7]
+	add	%ip, %sp, #16
+	ldm	%ip, {%r4, %r5, %r6}
+	svc	0x00000000
+	pop	{%r4, %r5, %r6, %r7}
+	bx	%lr
 
 
-        // Call the kernel
+.macro syscall name, nr
+	.nr_\name :
+		.long \nr
 
-        .macro do_sys opcode
-        movw    %r7, #\opcode
-        svc     #0
-        .endm
+	ENTRY(\name)
+		push	{%r4, %r5, %r6, %r7}
+		adr		%r7, .nr_\name
+		b		syscall_common
+	END(\name)
+.endm
 
 
-        // a syscall with 0-4 arguments
-
-        .macro syscall0 name, opcode
-        ENTRY(\name)
-        push    { %r7 }
-        do_sys  \opcode
-        pop     { %r7 }
-        bx      %lr
-        END(\name)
-        .endm
-
-
-        // a syscall with 5 arguments
-
-        .macro syscall5 name, opcode
-        ENTRY(\name)
-        push    { %r4, %r7 }
-        ldr     %r4, [%sp, #8]
-        do_sys  \opcode
-        pop     { %r4, %r7 }
-        bx      %lr
-        END(\name)
-        .endm
-
-
-        // a syscall with 6 arguments
-
-        .macro syscall6 name, opcode
-        ENTRY(\name)
-        push    { %r4, %r5, %r7 }
-        ldr     %r4, [%sp, #12]
-        ldr     %r5, [%sp, #16]
-        do_sys  \opcode
-        pop     { %r4, %r5, %r7 }
-        bx      %lr
-        END(\name)
-        .endm
-
 ENTRY(__cr_restore_rt)
-	do_sys __NR_rt_sigreturn
+	b	sys_rt_sigreturn
 END(__cr_restore_rt)
-- 
1.7.10.4



More information about the CRIU mailing list