On 2018-12-14 03:01, Sean Christopherson wrote:
+struct sgx_enclave_regs { + __u64 rdi; + __u64 rsi; + __u64 rdx; + __u64 r8; + __u64 r9; + __u64 r10; +};
This is fine, but why not just cover all 13 normal registers that are not used by SGX?
Minor comments below.
+/** + * struct sgx_enclave_exception - structure to pass register in/out of enclave
Typo in struct name.
+ * by way of __vdso_sgx_enter_enclave + * + * @rdi: value of %rdi, loaded/saved on enter/exit + * @rsi: value of %rsi, loaded/saved on enter/exit + * @rdx: value of %rdx, loaded/saved on enter/exit + * @r8: value of %r8, loaded/saved on enter/exit + * @r9: value of %r9, loaded/saved on enter/exit + * @r10: value of %r10, loaded/saved on enter/exit + */
+ /* load leaf, TCS and AEP for ENCLU */ + mov %edi, %eax + mov %rsi, %rbx + lea 1f(%rip), %rcx
If you move this below the jump, you can use %rcx for @regs
+ + /* optionally copy @regs to registers */ + test %rdx, %rdx + je 1f + + mov %rdx, %r11 + mov RDI(%r11), %rdi + mov RSI(%r11), %rsi + mov RDX(%r11), %rdx + mov R8(%r11), %r8 + mov R9(%r11), %r9 + mov R10(%r11), %r10 + +1: enclu + + /* ret = 0 */ + xor %eax, %eax + + /* optionally copy registers to @regs */ + mov -0x8(%rsp), %r11 + test %r11, %r11 + je 2f + + mov %rdi, RDI(%r11) + mov %rsi, RSI(%r11) + mov %rdx, RDX(%r11) + mov %r8, R8(%r11) + mov %r9, R9(%r11) + mov %r10, R10(%r11)
Here you can use %rax for @regs and clear it at the end.
+2: pop %rbx + pop %r12 + pop %r13 + pop %r14 + pop %r15 + pop %rbp + ret
x86-64 ABI requires that you call CLD here (enclave may set it). -- Jethro Beekman | Fortanix
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature