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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 Jul 2023 18:59:12 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Kai Huang <kai.huang@...el.com>
Cc:     kirill.shutemov@...ux.intel.com, linux-kernel@...r.kernel.org,
        dave.hansen@...el.com, tglx@...utronix.de, bp@...en8.de,
        mingo@...hat.com, hpa@...or.com, x86@...nel.org, seanjc@...gle.com,
        pbonzini@...hat.com, kvm@...r.kernel.org, isaku.yamahata@...el.com,
        sathyanarayanan.kuppuswamy@...ux.intel.com
Subject: Re: [PATCH 07/10] x86/tdx: Extend TDX_MODULE_CALL to support more
 TDCALL/SEAMCALL leafs

On Wed, Jul 12, 2023 at 06:53:37PM +0200, Peter Zijlstra wrote:
> On Wed, Jul 12, 2023 at 08:55:21PM +1200, Kai Huang wrote:
> 
> 
> > @@ -72,7 +142,46 @@
> >  	movq %r9,  TDX_MODULE_r9(%rsi)
> >  	movq %r10, TDX_MODULE_r10(%rsi)
> >  	movq %r11, TDX_MODULE_r11(%rsi)
> > -	.endif
> > +	.endif	/* \ret */
> > +
> > +	.if \saved
> > +	.if \ret && \host
> > +	/*
> > +	 * Clear registers shared by guest for VP.ENTER to prevent
> > +	 * speculative use of guest's values, including those are
> > +	 * restored from the stack.
> > +	 *
> > +	 * See arch/x86/kvm/vmx/vmenter.S:
> > +	 *
> > +	 * In theory, a L1 cache miss when restoring register from stack
> > +	 * could lead to speculative execution with guest's values.
> > +	 *
> > +	 * Note: RBP/RSP are not used as shared register.  RSI has been
> > +	 * restored already.
> > +	 *
> > +	 * XOR is cheap, thus unconditionally do for all leafs.
> > +	 */
> > +	xorq %rcx, %rcx
> > +	xorq %rdx, %rdx
> > +	xorq %r8,  %r8
> > +	xorq %r9,  %r9
> > +	xorq %r10, %r10
> > +	xorq %r11, %r11
> 
> > +	xorq %r12, %r12
> > +	xorq %r13, %r13
> > +	xorq %r14, %r14
> > +	xorq %r15, %r15
> > +	xorq %rbx, %rbx
> 
> ^ those are an instant pop below, seems daft to clear them.

Also, please use the 32bit variant:

	xorl	%ecx, %ecx

saves a RAX prefix each.

> > +	xorq %rdi, %rdi
> > +	.endif	/* \ret && \host */
> > +
> > +	/* Restore callee-saved GPRs as mandated by the x86_64 ABI */
> > +	popq	%r15
> > +	popq	%r14
> > +	popq	%r13
> > +	popq	%r12
> > +	popq	%rbx
> > +	.endif	/* \saved */
> >  
> >  	FRAME_END
> >  	RET
> > -- 
> > 2.41.0
> > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ