Re: [PATCH v2 00/11] Unify TDCALL/SEAMCALL and TDVMCALL assembly

From: Huang, Kai
Date: Thu Jul 20 2023 - 20:18:57 EST


On Thu, 2023-07-20 at 15:16 +0200, Peter Zijlstra wrote:
> On Fri, Jul 21, 2023 at 12:28:03AM +1200, Kai Huang wrote:
>
> > Kai Huang (11):
> > x86/tdx: Zero out the missing RSI in TDX_HYPERCALL macro
> > x86/tdx: Skip saving output regs when SEAMCALL fails with
> > VMFailInvalid
> > x86/tdx: Make macros of TDCALLs consistent with the spec
> > x86/tdx: Rename __tdx_module_call() to __tdcall()
> > x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure
> > x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs
> > x86/tdx: Make TDX_HYPERCALL asm similar to TDX_MODULE_CALL
> > x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm
> > x86/tdx: Remove 'struct tdx_hypercall_args'
> > x86/virt/tdx: Wire up basic SEAMCALL functions
> > x86/virt/tdx: Allow SEAMCALL to handle #UD and #GP
>
> These look ok to me, thanks!

Thanks!

>
> This does not yet re-order the args structure to conform to the hardware
> index order as per kvm's requirement, right? That will be part of the
> KVM series?

Unfortunately I don't think it's feasible. Sean pointed out that
kvm_vcpu_arch::regs[] do follow the "register index" hardware layout in x86 (for
which I missed sorry), so we cannot re-order KVM part.  

And unfortunately RBP (5) is in middle of those registers:

0 = RAX
1 = RCX
2 = RDX
3 = RBX
4 = RSP
5 = RBP
6 = RSI
7 = RDI
8–15 represent R8–R15, respectively...

Thus unless we add RBP to 'struct tdx_module_args', it's impossible to re-order
the structure to match KVM's layout.