linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"jpiotrowski@linux.microsoft.com"
	<jpiotrowski@linux.microsoft.com>
Cc: "tim.gardner@canonical.com" <tim.gardner@canonical.com>,
	"cascardo@canonical.com" <cascardo@canonical.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
	"roxana.nicolescu@canonical.com" <roxana.nicolescu@canonical.com>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"stefan.bader@canonical.com" <stefan.bader@canonical.com>,
	"Cui, Dexuan" <decui@microsoft.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"mhkelley58@gmail.com" <mhkelley58@gmail.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"bp@alien8.de" <bp@alien8.de>,
	"sashal@kernel.org" <sashal@kernel.org>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v1 2/3] x86/coco: Disable TDX module calls when TD partitioning is active
Date: Wed, 29 Nov 2023 10:37:02 +0000	[thread overview]
Message-ID: <ab1a3575ac66cf2f7cc05a21e5a20fbe415e834b.camel@intel.com> (raw)
In-Reply-To: <837fb5e9-4a35-4e49-8ec6-1fcfd5a0da30@linux.microsoft.com>

On Fri, 2023-11-24 at 11:38 +0100, Jeremi Piotrowski wrote:
> On 23/11/2023 15:13, Kirill A. Shutemov wrote:
> > On Wed, Nov 22, 2023 at 06:01:05PM +0100, Jeremi Piotrowski wrote:
> > > Introduce CC_ATTR_TDX_MODULE_CALLS to allow code to check whether TDX module
> > > calls are available. When TD partitioning is enabled, a L1 TD VMM handles most
> > > TDX facilities and the kernel running as an L2 TD VM does not have access to
> > > TDX module calls. The kernel still has access to TDVMCALL(0) which is forwarded
> > > to the VMM for processing, which is the L1 TD VM in this case.
> > 
> 
> Correction: it turns out TDVMCALL(0) is handled by L0 VMM.
> > 

Some thoughts after checking the spec more to make sure we don't have
misunderstanding on each other:

The TDX module will unconditionally exit to L1 for any TDCALL (except the
TDVMCALL) from the L2.  This is expected behaviour.  Because the L2 isn't a true
TDX guest, L1 is expected to inject a #UD or #GP or whatever error to L2 based
on the hardware spec to make sure L2 gets an correct architectural behaviour for
the TDCALL instruction.

I believe this is also the reason you mentioned "L2 TD VM does not have access
to TDX module calls".

However TDX module actually allows the L1 to control whether the L2 is allowed
to execute TDVMCALL by controlling whether the TDVMCALL from L2 will exit to L0
or L1.

I believe you mentioned "TDVMCALL(0) is handled by L0 VMM" is because the L1
hypervisor -- specifically, hyperv -- chooses to let the TDVMCALL from L2 exit
to L0?

But IMHO this is purely the hyperv's implementation, i.e., KVM can choose not to
do so, and simply handle TDVMCALL in the same way as it handles normal TDCALL --
inject the architecture defined error to L2.

Also AFAICT there's no architectural thing that controlled by L2 to allow the L1
know whether L2 is expecting to use TDVMCALL or not.  In other words, whether to
support TDVMCALL is purely L1 hypervisor implementation specific.

So to me this whole series is hyperv specific enlightenment for the L2 running
on TDX guest hyperv L1.  And because of that, perhaps a better way to do is:

1) The default L2 should just be a normal VM that any TDX guest L1 hypervisor
should be able to handle (guaranteed by the TDX partitioning architecture).

2) Different L2/L1 hypervisor can have it's own enlightenments.  We can even
have common enlightenments across different implementation of L1 hypervisors,
but that requires cross-hypervisor cooperation.

But IMHO it's not a good idea to say:

	L2 is running on a TDX partitioning enabled environment, let us mark it
	as a TDX guest but mark it as "TDX partitioning" to disable couple of 
	TDX functionalities.

Instead, perhaps it's better to let L2 explicitly opt-in TDX facilities that the
underneath hypervisor supports.

TDVMCALL can be the first facility to begin with.

At last, even TDVMCALL has bunch of leafs, and hypervisor can choose to support
them or not.  Use a single "tdx_partitioning_active" to select what TDX
facilities are supported doesn't seem a good idea.

That's my 2cents w/o knowing details of hyperv enlightenments.


  reply	other threads:[~2023-11-29 10:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 17:01 [PATCH v1 1/3] x86/tdx: Check for TDX partitioning during early TDX init Jeremi Piotrowski
2023-11-22 17:01 ` [PATCH v1 2/3] x86/coco: Disable TDX module calls when TD partitioning is active Jeremi Piotrowski
2023-11-23 14:13   ` Kirill A. Shutemov
2023-11-24 10:38     ` Jeremi Piotrowski
2023-11-29 10:37       ` Huang, Kai [this message]
2023-12-01 15:27         ` Jeremi Piotrowski
2023-11-22 17:01 ` [PATCH v1 3/3] x86/tdx: Provide stub tdx_accept_memory() for non-TDX configs Jeremi Piotrowski
2023-11-23 14:11   ` Kirill A. Shutemov
2023-11-24 10:00     ` Jeremi Piotrowski
2023-11-22 17:19 ` [PATCH v1 1/3] x86/tdx: Check for TDX partitioning during early TDX init Jeremi Piotrowski
2023-11-29 16:40   ` Borislav Petkov
2023-11-30  7:08     ` Reshetova, Elena
2023-11-30  7:55       ` Borislav Petkov
2023-11-30  8:31         ` Reshetova, Elena
2023-11-30  9:21           ` Borislav Petkov
2023-12-04 16:44             ` Jeremi Piotrowski
2023-12-04 13:39           ` Jeremi Piotrowski
2023-12-04 19:37     ` Jeremi Piotrowski
2023-11-23 13:58 ` Kirill A. Shutemov
2023-11-24 10:31   ` Jeremi Piotrowski
2023-11-24 10:43     ` Kirill A. Shutemov
2023-11-24 11:04       ` Jeremi Piotrowski
2023-11-24 13:33         ` Kirill A. Shutemov
2023-11-24 16:19           ` Jeremi Piotrowski
2023-11-29  4:36             ` Huang, Kai
2023-12-01 16:16               ` Jeremi Piotrowski
2023-12-05 13:26                 ` Huang, Kai
2023-12-06 18:47                   ` Jeremi Piotrowski
2023-12-07 12:58                     ` Huang, Kai
2023-12-07 17:21                       ` Jeremi Piotrowski
2023-12-07 19:35                         ` Jeremi Piotrowski
2023-12-08 10:51                           ` Huang, Kai
2023-12-07 17:36                     ` Reshetova, Elena
2023-12-08 12:45                       ` Jeremi Piotrowski
2023-12-04  9:17 ` Reshetova, Elena
2023-12-04 19:07   ` Jeremi Piotrowski
2023-12-05 10:54     ` Kirill A. Shutemov
2023-12-06 17:49       ` Jeremi Piotrowski
2023-12-06 22:54         ` Kirill A. Shutemov
2023-12-07 17:06           ` Jeremi Piotrowski
2023-12-07 20:56             ` Kirill A. Shutemov
2023-12-05 13:24     ` Reshetova, Elena

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=ab1a3575ac66cf2f7cc05a21e5a20fbe415e834b.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=bp@alien8.de \
    --cc=cascardo@canonical.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jpiotrowski@linux.microsoft.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhkelley58@gmail.com \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=roxana.nicolescu@canonical.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefan.bader@canonical.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tim.gardner@canonical.com \
    --cc=wei.liu@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).