[CRIU] [PATCH 2/3] criu: arch, x86 -- A few style tuneup in mixed call code
Cyrill Gorcunov
gorcunov at openvz.org
Wed Jul 6 14:15:24 PDT 2016
- use entry/end from linkage
- use macros for segments
- use C style comments
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/arch/x86/Makefile | 4 ++++
criu/arch/x86/call32.S | 37 +++++++++++++++++++------------------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/criu/arch/x86/Makefile b/criu/arch/x86/Makefile
index d8e8251845bf..e214a15be4b1 100644
--- a/criu/arch/x86/Makefile
+++ b/criu/arch/x86/Makefile
@@ -2,6 +2,10 @@ builtin-name := crtools.built-in.o
ccflags-y += -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
+asflags-y += -Wstrict-prototypes -Wa,--noexecstack
+asflags-y += -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
+asflags-y += -iquote $(obj)/include
+
obj-y += cpu.o
obj-y += crtools.o
obj-y += sigaction_compat.o
diff --git a/criu/arch/x86/call32.S b/criu/arch/x86/call32.S
index bc724d6c5fae..935461dcdc86 100644
--- a/criu/arch/x86/call32.S
+++ b/criu/arch/x86/call32.S
@@ -16,15 +16,19 @@
* the fly.
*/
- .text
+#include "asm/linkage.h"
+
+#define __USER32_CS 0x23
+#define __USER_CS 0x33
- .global call32_from_64
- .type call32_from_64, @function
-call32_from_64:
- // rdi: stack to use
- // esi: function to call
+ .text
- // Save registers
+/*
+ * @rdi: Stack to use
+ * @esi: Pointer to function for calling
+ */
+ENTRY(call32_from_64)
+ /* Callee-saving registers due to ABI */
pushq %rbx
pushq %rbp
pushq %r12
@@ -33,30 +37,29 @@ call32_from_64:
pushq %r15
pushfq
- // Switch stacks
+ /* Switch stacks */
sub $8, %rdi
mov %rsp,(%rdi)
mov %rdi,%rsp
- // Switch to compatibility mode
- pushq $0x23 /* USER32_CS */
+ /* Switch into compatibility mode */
+ pushq $__USER32_CS
pushq $1f
lretq
1:
.code32
- // Call the function
+ /* Run function and switch back */
call *%esi
- // Switch back to long mode
- jmp $0x33,$1f
+ jmp $__USER_CS,$1f
.code64
1:
- // Restore the stack
+ /* Restore the stack */
mov (%rsp),%rsp
add $8, %rdi
- // Restore registers
+ /* Restore registers */
popfq
popq %r15
popq %r14
@@ -64,7 +67,5 @@ call32_from_64:
popq %r12
popq %rbp
popq %rbx
-
ret
-
-.size call32_from_64, .-call32_from_64
+END(call32_from_64)
--
2.7.4
More information about the CRIU
mailing list