123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #include "pal_linux_defs.h"
- #include "sgx_arch.h"
- #include "asm-offsets.h"
- .extern tcs_base
- .global sgx_ecall
- .type sgx_ecall, @function
- sgx_ecall:
- # put entry address in RDX
- leaq sgx_entry(%rip), %rdx
- # other arguments: RDI - code, RSI - ms
- .Ldo_ecall:
- # RBX has to be the TCS of the thread
- movq current_tcs@gottpoff(%rip), %rbx
- movq %fs:(%rbx), %rbx
- # RCX has to be the AEP (Asynchronous Exit Pointer)
- leaq async_exit_pointer(%rip), %rcx
- movq $EENTER, %rax
- ENCLU
- .global async_exit_pointer
- .type async_exit_pointer, @function
- async_exit_pointer:
- ENCLU
- .global sgx_raise
- .type sgx_raise, @function
- sgx_raise:
- leaq .Lafter_resume(%rip), %rdx
- jmp .Ldo_ecall
- .Lafter_resume:
- retq
- sgx_entry:
- # arguments: RDI - code, RSI - ms
- leaq ocall_table(%rip), %rbx
- movq (%rbx,%rdi,8), %rbx
- movq %rsi, %rdi
- pushq %rbp
- movq %rsp, %rbp
- andq $~0xF, %rsp # Required by System V AMD64 ABI.
- callq *%rbx
- movq %rbp, %rsp
- popq %rbp
- movq %rax, %rdi
- # Not interrupted
- xorq %rsi, %rsi
- .global sgx_entry_return
- .type sgx_entry_return, @function
- sgx_entry_return:
- # return to enclave, arguments:
- # RDI - return value
- # RSI - external event
- jmp .Ldo_ecall
- /*
- * rdfsbase:
- * read FS register (allowed in enclaves).
- */
- .global rdfsbase
- .type rdfsbase, @function
- rdfsbase:
- .cfi_startproc
- .byte 0xf3, 0x48, 0x0f, 0xae, 0xc0 /* RDFSBASE %RAX */
- retq
- .cfi_endproc
- .size rdfsbase, .-rdfsbase
- /*
- * wrfsbase:
- * modify FS register (allowed in enclaves).
- */
- .global wrfsbase
- .type wrfsbase, @function
- wrfsbase:
- .cfi_startproc
- .byte 0xf3, 0x48, 0x0f, 0xae, 0xd7 /* WRFSBASE %RDI */
- retq
- .cfi_endproc
- .size wrfsbase, .-wrfsbase
|