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
ccflags-y += -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/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 += crtools.o
obj-y += sigframe.o
......
......@@ -16,15 +16,19 @@
* the fly.
*/
.text
#include "common/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)
#include "asm/linkage.h"
#include "common/asm/linkage.h"
#include "parasite.h"
.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