From: "Huang, Kai" <kai.huang@intel.com>
To: "kirill.shutemov@linux.intel.com" <kirill.shutemov@linux.intel.com>
Cc: "Hansen, Dave" <dave.hansen@intel.com>, "Christopherson,,
Sean" <seanjc@google.com>, "x86@kernel.org" <x86@kernel.org>,
"bp@alien8.de" <bp@alien8.de>,
"peterz@infradead.org" <peterz@infradead.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"Yamahata, Isaku" <isaku.yamahata@intel.com>,
"sathyanarayanan.kuppuswamy@linux.intel.com"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
"n.borisov.lkml@gmail.com" <n.borisov.lkml@gmail.com>
Subject: Re: [PATCH v3 05/12] x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure
Date: Thu, 3 Aug 2023 11:35:48 +0000 [thread overview]
Message-ID: <1d402ce98cdcf71098783e7fe584bbf477e47eb9.camel@intel.com> (raw)
In-Reply-To: <20230803105810.xljd2sjqittqey2w@box.shutemov.name>
On Thu, 2023-08-03 at 13:58 +0300, kirill.shutemov@linux.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@linux.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.
?
next prev parent reply other threads:[~2023-08-03 11:36 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 11:25 [PATCH v3 00/12] Unify TDCALL/SEAMCALL and TDVMCALL assembly Kai Huang
2023-07-26 11:25 ` [PATCH v3 01/12] x86/tdx: Zero out the missing RSI in TDX_HYPERCALL macro Kai Huang
2023-07-27 12:48 ` kirill.shutemov
2023-07-26 11:25 ` [PATCH v3 02/12] x86/tdx: Skip saving output regs when SEAMCALL fails with VMFailInvalid Kai Huang
2023-07-27 12:52 ` kirill.shutemov
2023-07-27 22:55 ` Huang, Kai
2023-07-26 11:25 ` [PATCH v3 03/12] x86/tdx: Make macros of TDCALLs consistent with the spec Kai Huang
2023-07-27 13:00 ` kirill.shutemov
2023-07-28 1:54 ` Sathyanarayanan Kuppuswamy
2023-07-28 2:45 ` Huang, Kai
2023-07-26 11:25 ` [PATCH v3 04/12] x86/tdx: Rename __tdx_module_call() to __tdcall() Kai Huang
2023-07-27 13:02 ` kirill.shutemov
2023-07-28 15:33 ` Sathyanarayanan Kuppuswamy
2023-07-26 11:25 ` [PATCH v3 05/12] x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure Kai Huang
2023-07-27 16:36 ` kirill.shutemov
2023-07-27 22:54 ` Huang, Kai
2023-08-03 10:58 ` kirill.shutemov
2023-08-03 11:35 ` Huang, Kai [this message]
2023-08-03 11:47 ` kirill.shutemov
2023-07-26 11:25 ` [PATCH v3 06/12] x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs Kai Huang
2023-07-27 16:50 ` kirill.shutemov
2023-07-27 22:58 ` Huang, Kai
2023-07-26 11:25 ` [PATCH v3 07/12] x86/tdx: Make TDX_HYPERCALL asm similar to TDX_MODULE_CALL Kai Huang
2023-07-27 17:10 ` kirill.shutemov
2023-07-27 23:05 ` Huang, Kai
2023-08-03 11:45 ` kirill.shutemov
2023-08-03 11:56 ` Huang, Kai
2023-08-03 12:12 ` kirill.shutemov
2023-08-03 12:41 ` Huang, Kai
2023-08-03 13:47 ` kirill.shutemov
2023-08-03 22:41 ` Huang, Kai
2023-07-26 11:25 ` [PATCH v3 08/12] x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm Kai Huang
2023-08-06 11:25 ` kirill.shutemov
2023-07-26 11:25 ` [PATCH v3 09/12] x86/tdx: Remove 'struct tdx_hypercall_args' Kai Huang
2023-08-06 11:29 ` kirill.shutemov
2023-07-26 11:25 ` [PATCH v3 10/12] x86/virt/tdx: Wire up basic SEAMCALL functions Kai Huang
2023-08-06 11:36 ` kirill.shutemov
2023-08-07 1:40 ` Huang, Kai
2023-08-07 14:30 ` Sean Christopherson
2023-08-07 23:51 ` Huang, Kai
2023-07-26 11:25 ` [PATCH v3 11/12] x86/virt/tdx: Allow SEAMCALL to handle #UD and #GP Kai Huang
2023-08-06 11:41 ` kirill.shutemov
2023-08-07 2:14 ` Huang, Kai
2023-08-07 9:53 ` kirill.shutemov
2023-08-07 12:41 ` Huang, Kai
2023-08-07 14:27 ` kirill.shutemov
2023-08-07 14:46 ` Dave Hansen
2023-07-26 11:25 ` [PATCH v3 12/12] x86/virt/tdx: Adjust 'struct tdx_module_args' to use x86 "register index" layout Kai Huang
2023-08-02 21:32 ` Isaku Yamahata
2023-08-02 23:20 ` Huang, Kai
2023-08-02 21:39 ` Isaku Yamahata
2023-08-06 11:50 ` kirill.shutemov
2023-08-07 2:16 ` Huang, Kai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1d402ce98cdcf71098783e7fe584bbf477e47eb9.camel@intel.com \
--to=kai.huang@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=n.borisov.lkml@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®