Commit c36515ad authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

criu: arch, x86 -- A few style tuneup in mixed call code

 - use entry/end from linkage
 - use macros for segments
 - use C style comments
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Tested-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent acfd9a3e
...@@ -3,6 +3,10 @@ builtin-name := crtools.built-in.o ...@@ -3,6 +3,10 @@ builtin-name := crtools.built-in.o
ccflags-y += -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include ccflags-y += -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include
ccflags-y += -iquote $(SRC_DIR)/criu/include -iquote $(SRC_DIR)/include ccflags-y += -iquote $(SRC_DIR)/criu/include -iquote $(SRC_DIR)/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 += cpu.o
obj-y += crtools.o obj-y += crtools.o
obj-y += sigframe.o obj-y += sigframe.o
......
...@@ -16,15 +16,19 @@ ...@@ -16,15 +16,19 @@
* the fly. * the fly.
*/ */
.text #include "common/asm/linkage.h"
#define __USER32_CS 0x23
#define __USER_CS 0x33
.global call32_from_64 .text
.type call32_from_64, @function
call32_from_64:
// rdi: stack to use
// esi: function to call
// 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 %rbx
pushq %rbp pushq %rbp
pushq %r12 pushq %r12
...@@ -33,30 +37,29 @@ call32_from_64: ...@@ -33,30 +37,29 @@ call32_from_64:
pushq %r15 pushq %r15
pushfq pushfq
// Switch stacks /* Switch stacks */
sub $8, %rdi sub $8, %rdi
mov %rsp,(%rdi) mov %rsp,(%rdi)
mov %rdi,%rsp mov %rdi,%rsp
// Switch to compatibility mode /* Switch into compatibility mode */
pushq $0x23 /* USER32_CS */ pushq $__USER32_CS
pushq $1f pushq $1f
lretq lretq
1: 1:
.code32 .code32
// Call the function /* Run function and switch back */
call *%esi call *%esi
// Switch back to long mode jmp $__USER_CS,$1f
jmp $0x33,$1f
.code64 .code64
1: 1:
// Restore the stack /* Restore the stack */
mov (%rsp),%rsp mov (%rsp),%rsp
add $8, %rdi add $8, %rdi
// Restore registers /* Restore registers */
popfq popfq
popq %r15 popq %r15
popq %r14 popq %r14
...@@ -64,7 +67,5 @@ call32_from_64: ...@@ -64,7 +67,5 @@ call32_from_64:
popq %r12 popq %r12
popq %rbp popq %rbp
popq %rbx popq %rbx
ret ret
END(call32_from_64)
.size call32_from_64, .-call32_from_64
#include "asm/linkage.h" #include "common/asm/linkage.h"
#include "parasite.h" #include "parasite.h"
.section .head.text, "ax" .section .head.text, "ax"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment