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]
Date:   Thu, 27 Jul 2023 22:58:12 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>
CC:     "Hansen, Dave" <dave.hansen@...el.com>,
        "Christopherson,, Sean" <seanjc@...gle.com>,
        "x86@...nel.org" <x86@...nel.org>, "bp@...en8.de" <bp@...en8.de>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "hpa@...or.com" <hpa@...or.com>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "sathyanarayanan.kuppuswamy@...ux.intel.com" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        "n.borisov.lkml@...il.com" <n.borisov.lkml@...il.com>
Subject: Re: [PATCH v3 06/12] x86/tdx: Extend TDX_MODULE_CALL to support more
 TDCALL/SEAMCALL leafs

On Thu, 2023-07-27 at 19:50 +0300, kirill.shutemov@...ux.intel.com wrote:
> On Wed, Jul 26, 2023 at 11:25:08PM +1200, Kai Huang wrote:
> > @@ -64,6 +103,37 @@
> >  .endif
> >  
> >  .if \ret
> > +.if \saved
> > +	/*
> > +	 * Restore the structure from stack to save the output registers
> > +	 *
> > +	 * In case of VP.ENTER returns due to TDVMCALL, all registers are
> > +	 * valid thus no register can be used as spare to restore the
> > +	 * structure from the stack (see "TDH.VP.ENTER Output Operands
> > +	 * Definition on TDCALL(TDG.VP.VMCALL) Following a TD Entry").
> > +	 * For this case, need to make one register as spare by saving it
> > +	 * to the stack and then manually load the structure pointer to
> > +	 * the spare register.
> > +	 *
> > +	 * Note for other TDCALLs/SEAMCALLs there are spare registers
> > +	 * thus no need for such hack but just use this for all.
> > +	 */
> > +	pushq	%rax		/* save the TDCALL/SEAMCALL return code */
> > +	movq	8(%rsp), %rax	/* restore the structure pointer */
> > +	movq	%rsi, TDX_MODULE_rsi(%rax)	/* save %rsi */
> > +	movq	%rax, %rsi	/* use %rsi as structure pointer */
> 
> This looks redundant. You get struct in RSI with popq two lines below.

Yes I guess so.  Will remove and have a test.

> 
> And please use upper case for registers: RSI instead of %rsi.

In the comments?  Will do.

> 
> > +	popq	%rax		/* restore the return code */
> > +	popq	%rsi		/* pop the structure pointer */
> > +
> > +	/* Copy additional output regs to the structure  */
> > +	movq %r12, TDX_MODULE_r12(%rsi)
> > +	movq %r13, TDX_MODULE_r13(%rsi)
> > +	movq %r14, TDX_MODULE_r14(%rsi)
> > +	movq %r15, TDX_MODULE_r15(%rsi)
> > +	movq %rbx, TDX_MODULE_rbx(%rsi)
> > +	movq %rdi, TDX_MODULE_rdi(%rsi)
> > +.endif	/* \saved */
> > +
> >  	/* Copy output registers to the structure */
> >  	movq %rcx, TDX_MODULE_rcx(%rsi)
> >  	movq %rdx, TDX_MODULE_rdx(%rsi)
> 
> Otherwise, looks sane:
> 
> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> 

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ