From: Isaku Yamahata <isaku.yamahata@gmail.com>
To: Yuan Yao <yuan.yao@linux.intel.com>
Cc: Isaku Yamahata <isaku.yamahata@gmail.com>,
"Huang, Kai" <kai.huang@intel.com>,
"Hansen, Dave" <dave.hansen@intel.com>, "Christopherson,,
Sean" <seanjc@google.com>, "bp@alien8.de" <bp@alien8.de>,
"x86@kernel.org" <x86@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.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>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"sathyanarayanan.kuppuswamy@linux.intel.com"
<sathyanarayanan.kuppuswamy@linux.intel.com>
Subject: Re: [PATCH 09/10] x86/virt/tdx: Wire up basic SEAMCALL functions
Date: Mon, 14 Aug 2023 13:37:32 -0700 [thread overview]
Message-ID: <20230814203732.GC2257301@ls.amr.corp.intel.com> (raw)
In-Reply-To: <20230808091606.jk667prer5lmtcpm@yy-desk-7060>
On Tue, Aug 08, 2023 at 05:16:06PM +0800,
Yuan Yao <yuan.yao@linux.intel.com> wrote:
> On Thu, Jul 13, 2023 at 11:44:34AM -0700, Isaku Yamahata wrote:
> > On Thu, Jul 13, 2023 at 03:46:52AM +0000,
> > "Huang, Kai" <kai.huang@intel.com> wrote:
> >
> > > On Wed, 2023-07-12 at 15:15 -0700, Isaku Yamahata wrote:
> > > > > The SEAMCALL ABI is very similar to the TDCALL ABI and leverages much
> > > > > TDCALL infrastructure. Wire up basic functions to make SEAMCALLs for
> > > > > the basic TDX support: __seamcall(), __seamcall_ret() and
> > > > > __seamcall_saved_ret() which is for TDH.VP.ENTER leaf function.
> > > >
> > > > Hi. __seamcall_saved_ret() uses struct tdx_module_arg as input and output. For
> > > > KVM TDH.VP.ENTER case, those arguments are already in unsigned long
> > > > kvm_vcpu_arch::regs[]. It's silly to move those values twice. From
> > > > kvm_vcpu_arch::regs to tdx_module_args. From tdx_module_args to real registers.
> > > >
> > > > If TDH.VP.ENTER is the only user of __seamcall_saved_ret(), can we make it to
> > > > take unsigned long kvm_vcpu_argh::regs[NR_VCPU_REGS]? Maybe I can make the
> > > > change with TDX KVM patch series.
> > >
> > > The assembly code assumes the second argument is a pointer to 'struct
> > > tdx_module_args'. I don't know how can we change __seamcall_saved_ret() to
> > > achieve what you said. We might change the kvm_vcpu_argh::regs[NR_VCPU_REGS] to
> > > match 'struct tdx_module_args''s layout and manually convert part of "regs" to
> > > the structure and pass to __seamcall_saved_ret(), but it's too hacky I suppose.
> > >
> > > This was one concern that I mentioned VP.ENTER can be implemented by KVM in its
> > > own assembly in the TDX host v12 discussion. I kinda agree we should leverage
> > > KVM's existing kvm_vcpu_arch::regs[NR_CPU_REGS] infrastructure to minimize the
> > > code change to the KVM's common infrastructure. If so, I guess we have to carry
> > > this memory copy burden between two structures.
> > >
> > > Btw, I do find KVM's VP.ENTER code is a little bit redundant to the common
> > > SEAMCALL assembly, which is a good reason for KVM to use __seamcall() variants
> > > for TDH.VP.ENTER.
> > >
> > > So it's a tradeoff I think.
> > >
> > > On the other hand, given CoCo VMs normally don't expose all GPRs to VMM, it's
> > > also debatable whether we should invent another infrastructure to the KVM code
> > > to handle register access of CoCo VMs too, e.g., we can catch bugs easily when
> > > KVM tries to access the registers that it shouldn't access.
> >
> > Yes, we'd like to save/restore GPRs only for TDVMCALL. Otherwise skip
> > save/restore.
>
> And another case to save/restore GPRs: supports DEBUG TD,
> which is type of TD guest allows VMM to change its register
> context, for debugging purpose.
For Debug TD case, we can use TDH.VP.RD(general purpose register) specifically.
We don't need to optimize for Debug TD case.
--
Isaku Yamahata <isaku.yamahata@gmail.com>
next prev parent reply other threads:[~2023-08-14 20:38 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 8:55 [PATCH 00/10] Unify TDCALL/SEAMCALL and TDVMCALL assembly Kai Huang
2023-07-12 8:55 ` [PATCH 01/10] x86/tdx: Zero out the missing RSI in TDX_HYPERCALL macro Kai Huang
2023-07-12 19:19 ` Sathyanarayanan Kuppuswamy
2023-07-12 8:55 ` [PATCH 02/10] x86/tdx: Use cmovc to save a label in TDX_MODULE_CALL asm Kai Huang
2023-07-12 19:27 ` Sathyanarayanan Kuppuswamy
2023-07-13 10:32 ` Huang, Kai
2023-07-12 8:55 ` [PATCH 03/10] x86/tdx: Move FRAME_BEGIN/END to TDX_MODULE_CALL asm macro Kai Huang
2023-07-12 19:57 ` Sathyanarayanan Kuppuswamy
2023-07-12 22:05 ` Isaku Yamahata
2023-07-12 8:55 ` [PATCH 04/10] x86/tdx: Make macros of TDCALLs consistent with the spec Kai Huang
2023-07-14 12:28 ` Nikolay Borisov
2023-07-14 12:28 ` Nikolay Borisov
2023-07-17 0:57 ` Huang, Kai
2023-07-12 8:55 ` [PATCH 05/10] x86/tdx: Rename __tdx_module_call() to __tdcall() Kai Huang
2023-07-12 8:55 ` [PATCH 06/10] x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure Kai Huang
2023-07-12 8:55 ` [PATCH 07/10] x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs Kai Huang
2023-07-12 16:53 ` Peter Zijlstra
2023-07-12 16:59 ` Peter Zijlstra
2023-07-13 8:02 ` Huang, Kai
2023-07-13 8:43 ` Peter Zijlstra
2023-07-13 10:19 ` Huang, Kai
2023-07-13 10:24 ` Huang, Kai
2023-07-13 10:39 ` Peter Zijlstra
2023-07-13 10:37 ` Peter Zijlstra
2023-07-13 10:47 ` Huang, Kai
2023-07-13 11:22 ` Andrew Cooper
2023-07-13 11:40 ` Huang, Kai
2023-07-13 7:48 ` Huang, Kai
2023-07-13 8:46 ` Peter Zijlstra
2023-07-13 9:34 ` Huang, Kai
2023-07-13 9:40 ` Peter Zijlstra
2023-07-12 17:11 ` Peter Zijlstra
2023-07-13 8:09 ` Huang, Kai
2023-07-13 9:01 ` Peter Zijlstra
2023-07-13 9:15 ` Huang, Kai
2023-07-13 9:25 ` Peter Zijlstra
2023-07-13 10:01 ` Huang, Kai
2023-07-12 8:55 ` [PATCH 08/10] x86/tdx: Unify TDX_HYPERCALL and TDX_MODULE_CALL assembly Kai Huang
2023-07-15 10:05 ` Nikolay Borisov
2023-07-17 6:35 ` Huang, Kai
2023-07-17 7:02 ` Nikolay Borisov
2023-07-17 7:58 ` Huang, Kai
2023-07-18 10:32 ` Huang, Kai
2023-07-12 8:55 ` [PATCH 09/10] x86/virt/tdx: Wire up basic SEAMCALL functions Kai Huang
2023-07-12 22:15 ` Isaku Yamahata
2023-07-13 3:46 ` Huang, Kai
2023-07-13 7:42 ` Peter Zijlstra
2023-07-13 8:18 ` Huang, Kai
2023-07-13 9:03 ` Peter Zijlstra
2023-07-13 9:20 ` Huang, Kai
2023-07-13 14:51 ` Sean Christopherson
2023-07-17 3:52 ` Huang, Kai
2023-07-13 18:44 ` Isaku Yamahata
2023-08-08 9:16 ` Yuan Yao
2023-08-14 20:37 ` Isaku Yamahata [this message]
2023-07-12 8:55 ` [PATCH 10/10] x86/virt/tdx: Allow SEAMCALL to handle #UD and #GP Kai Huang
2023-07-13 8:07 ` Peter Zijlstra
2023-07-13 9:58 ` 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=20230814203732.GC2257301@ls.amr.corp.intel.com \
--to=isaku.yamahata@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.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 \
--cc=yuan.yao@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.