lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cda13cff-1a56-a40f-7d69-f0f1ab752f8e@fortanix.com>
Date:   Fri, 14 Dec 2018 09:55:49 +0000
From:   Jethro Beekman <jethro@...tanix.com>
To:     Sean Christopherson <sean.j.christopherson@...el.com>,
        Andy Lutomirski <luto@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "x86@...nel.org" <x86@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
CC:     "H. Peter Anvin" <hpa@...or.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>,
        Andy Lutomirski <luto@...capital.net>,
        Josh Triplett <josh@...htriplett.org>,
        Haitao Huang <haitao.huang@...ux.intel.com>,
        "Dr . Greg Wettstein" <greg@...ellic.com>
Subject: Re: [RFC PATCH v4 5/5] x86/vdso: Add __vdso_sgx_enter_enclave() to
 wrap SGX enclave transitions

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


Download attachment "smime.p7s" of type "application/pkcs7-signature" (3990 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ