[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d402ce98cdcf71098783e7fe584bbf477e47eb9.camel@intel.com>
Date: Thu, 3 Aug 2023 11:35:48 +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 05/12] x86/tdx: Pass TDCALL/SEAMCALL input/output
registers via a structure
On Thu, 2023-08-03 at 13:58 +0300, kirill.shutemov@...ux.intel.com wrote:
> On Thu, Jul 27, 2023 at 10:54:28PM +0000, Huang, Kai wrote:
> > On Thu, 2023-07-27 at 19:36 +0300, kirill.shutemov@...ux.intel.com wrote:
> > > On Wed, Jul 26, 2023 at 11:25:07PM +1200, Kai Huang wrote:
> > > > diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
> > > > index 6bdf6e137953..a0e7fe81bf63 100644
> > > > --- a/arch/x86/virt/vmx/tdx/tdxcall.S
> > > > +++ b/arch/x86/virt/vmx/tdx/tdxcall.S
> > > > @@ -17,34 +17,33 @@
> > > > * TDX module and hypercalls to the VMM.
> > > > * SEAMCALL - used by TDX hosts to make requests to the
> > > > * TDX module.
> > > > + *
> > > > + *-------------------------------------------------------------------------
> > > > + * TDCALL/SEAMCALL ABI:
> > > > + *-------------------------------------------------------------------------
> > > > + * Input Registers:
> > > > + *
> > > > + * RAX - TDCALL/SEAMCALL Leaf number.
> > > > + * RCX,RDX,R8-R9 - TDCALL/SEAMCALL Leaf specific input registers.
> > > > + *
> > > > + * Output Registers:
> > > > + *
> > > > + * RAX - TDCALL/SEAMCALL instruction error code.
> > > > + * RCX,RDX,R8-R11 - TDCALL/SEAMCALL Leaf specific output registers.
> > > > + *
> > > > + *-------------------------------------------------------------------------
> > >
> > > So, you keep the existing asymetry in IN and OUT registers. R10 and R11
> > > are OUT-only registers. It can be confusing for user since it is the same
> > > structure now. I guess it changes in the following patches, but I would
> > > prefer to make them even here if there's no good reason not to.
> > >
> >
> >
> > Do you mean you prefer to use R10/R11 as input too even in this patch?
>
> Yes.
>
> > I think _logically_ it should be part of the next patch, because w/o extending
> > TDX_MODULE_CALL to support additional TDCALLs/SEAMCALLs, we don't need R10/R11
> > as input. This patch only changes to take a structure as function argument,
> > rather than taking individual registers as argument.
>
> As a user, if I see a struct used for in and out, I would expect that all
> fields have the same rules.
>
> > Also, we have a comment to say this around the structure too:
> >
> > /*
> > - * Used in __tdx_module_call() to gather the output registers' values of the
> > + * Used in __tdcall*() to gather the input/output registers' values of the
> > * TDCALL instruction when requesting services from the TDX module. This is a
> > * software only structure and not part of the TDX module/VMM ABI
> > */
> > -struct tdx_module_output {
> > +struct tdx_module_args {
> > + /* input/output */
> > u64 rcx;
> > u64 rdx;
> > u64 r8;
> > u64 r9;
> > + /* additional output */
> > u64 r10;
> > u64 r11;
> > };
> >
> > So to me there should be no confusion.
>
> Do you always read documentation? :P Maybe it is only me...
>
> > Even consider a theoretical case: someone wants to backport this patch to an old
> > kernel w/o further patches, then it makes little sense to do R10/R11 in
> > TDX_MODULE_CALL here in this patch
> >
> > :-)
>
> Consider the case whe the patch was (wrongly) backported to use new call
> that uses R10 as input.
>
> I realize that all my objections are rather hand-wavy. I would like to
> have in/out symmetry here. But I would not NAK patch over this.
>
The only concern is I don't particularly like to add additional logic to this
patch. Anyway not big deal to me. I can do what you said if I don't see
Peter's (or other maintainers') comment on this.
Btw, should I say something like below in the changelog to justify this
additional logic:
Also use R10/R11 as input registers too to make the input/outputĀ
registers symmetric, although currently no TDCALL/SEAMCALL use
them as input registers.
?
Powered by blists - more mailing lists