mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Isaku Yamahata <isaku.yamahata@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"seanjc@google.com" <seanjc@google.com>,
	"davidskidmore@google.com" <davidskidmore@google.com>,
	"srutherford@google.com" <srutherford@google.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pankaj.gupta@amd.com" <pankaj.gupta@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Wang, Wei W" <wei.w.wang@intel.com>,
	"Yamahata, Isaku" <isaku.yamahata@intel.com>,
	isaku.yamahata@linux.intel.com
Subject: Re: [ANNOUNCE] PUCK Notes - 2024.04.03 - TDX Upstreaming Strategy
Date: Fri, 12 Apr 2024 10:39:35 -0700	[thread overview]
Message-ID: <20240412173935.GH3039520@ls.amr.corp.intel.com> (raw)
In-Reply-To: <19a0f47e-6840-42f8-b200-570a9aa7455d@intel.com>

On Fri, Apr 12, 2024 at 04:40:37PM +0800,
Xiaoyao Li <xiaoyao.li@intel.com> wrote:

> > The second issue is that userspace can’t know what CPUID values are configured
> > in the TD. In the existing API for normal guests, it knows because it tells the
> > guest what CPUID values to have. But for the TDX module that model is
> > complicated to fit into in its API where you tell it some things and it gives
> > you the resulting leaves. How to handle KVM_SET_CPUID kind of follows from this
> > issue.
> > 
> > One option is to demand the TDX module change to be able to efficiently wedge
> > into KVM’s exiting “tell” model. This looks like the metadata API to query the
> > fixed bits. Then userspace can know what bits it has to set, and call
> > KVM_SET_CPUID with them. I think it is still kind of awkward. "Tell me what you
> > want to hear?", "Ok here it is".
> > 
> > Another option would be to add TDX specific KVM APIs that work for the TDX
> > module's “ask” model, and meet the enumerated two goals. It could look something
> > like:
> > 1. KVM_TDX_GET_CONFIG_CPUID provides a list of directly configurable bits by
> > KVM. This is based on static data on what KVM supports, with sanity check of
> > TD_SYSINFO.CPUID_CONFIG[]. Bits that KVM doesn’t know about, but are returned as
> > configurable by TD_SYSINFO.CPUID_CONFIG[] are not exposed as configurable. (they
> > will be set to 1 by KVM, per the recommendation)
> 
> This is not how KVM works. KVM will never enable unknown features blindly.
> If the feature is unknown to KVM, it cannot be enable for guest. That's why
> every new feature needs enabling patch in KVM, even the simplest case that
> needs one patch to enumerate the CPUID of new instruction in
> KVM_GET_SUPPORTED_CPUID.

We can use device attributes as discussed at
https://lore.kernel.org/kvm/CABgObfZzkNiP3q8p=KpvvFnh8m6qcHX4=tATaJc7cvVv2QWpJQ@mail.gmail.com/
https://lore.kernel.org/kvm/20240404121327.3107131-6-pbonzini@redhat.com/

Something like

#define KVM_X86_GRP_TDX         2
ioctl(fd, KVM_GET_DEVICE_ATTR, (KVM_X86_GRP_TDX, metadata_field_id))


> > 2. KVM_TDX_INIT_VM is passed userspaces choice of configurable bits, along with
> > XFAM and ATTRIBUTES as dedicated fields. They go into TDH.MNG.INIT.
> > 3. KVM_TDX_INIT_VCPU_CPUID takes a list of CPUID leafs. It pulls the CPUID bits
> > actually configured in the TD for these leafs. They go into the struct kvm_vcpu,
> > and are also passed up to userspace so everyone knows what actually got
> > configured.

Any reason to introduce KVM_TDX_INIT_VCPU_CPUID in addition to
KVM_TDX_INIT_VCPU?  We can make single vCPU KVM TDX ioctl do all.


> > KVM_SET_CPUID is not used for TDX.

What cpuid does KVM_TDX_INIT_VCPU_CPUID accept?  The one that TDX module
accepts with TDH.MNG.INIT()?  Or any cpuids that KVM_SET_CPUID2 accepts?
I'm asking it because TDX module virtualizes only subset of CPUIDs. 
TDG.VP.VMCALL<CPUID> would need info from KVM_SET_CPUID.


> > Then we get TDX module folks to commit to never breaking KVM/userspace that
> > follows this logic. One thing still missing is how to handle unknown future
> > leafs with fixed bits. If a future leaf is defined and gets fixed 1, QEMU
> > wouldn't know to query it.
> 
> We can make KVM_TDX_INIT_VCPU_CPUID provide a large enough CPUID leafs and
> KVM reports every leafs to userpsace. Instead of something that userspace
> cares leafs X,Y,Z and KVM only reports back leafs X,Y,Z via
> KVM_TDX_INIT_VCPU_CPUID.

If new CPUID index is introduced, the userspace will get default values of
CPUIDs and don't touch unknown CPUIDs?  Or KVM_TDX_GET_CONFIG_CPUID will mask
out CPUID unknown to KVM?
-- 
Isaku Yamahata <isaku.yamahata@intel.com>

  reply	other threads:[~2024-04-12 17:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 16:58 Sean Christopherson
2024-04-07  3:15 ` Xiaoyao Li
2024-04-08 16:20   ` Sean Christopherson
2024-04-08 17:42     ` Edgecombe, Rick P
2024-04-08 18:51       ` Sean Christopherson
2024-04-08 21:56         ` Edgecombe, Rick P
2024-04-08 22:36           ` Sean Christopherson
2024-04-08 23:46             ` Edgecombe, Rick P
2024-04-09  1:37               ` Sean Christopherson
2024-04-09 14:46                 ` Edgecombe, Rick P
2024-04-09 15:23                   ` Sean Christopherson
2024-04-09 15:49                     ` Edgecombe, Rick P
2024-04-09 16:13                       ` Xiaoyao Li
2024-04-09 16:18                         ` Xiaoyao Li
2024-04-10  1:05                           ` Huang, Kai
2024-04-09 16:26                       ` Sean Christopherson
2024-04-11  1:13                         ` Edgecombe, Rick P
2024-04-11 14:22                           ` Sean Christopherson
2024-04-11 15:16                             ` Xiaoyao Li
2024-04-11 15:26                               ` Sean Christopherson
2024-04-11 15:41                                 ` Xiaoyao Li
2024-04-11 18:52                                 ` Edgecombe, Rick P
2024-04-12  8:40                                   ` Xiaoyao Li
2024-04-12 17:39                                     ` Isaku Yamahata [this message]
2024-04-12 20:05                                       ` Edgecombe, Rick P
2024-04-15 21:04                                         ` Isaku Yamahata
2024-04-10  1:12         ` Isaku Yamahata
2024-04-10 14:03           ` Huang, Kai
2024-04-11  1:03             ` Isaku Yamahata
2024-04-11  3:46               ` Isaku Yamahata
2024-04-11 13:39                 ` Huang, Kai
2024-04-09  2:57     ` Xiaoyao Li
2024-04-09 14:01       ` Sean Christopherson
2024-04-09 14:15         ` Xiaoyao Li

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=20240412173935.GH3039520@ls.amr.corp.intel.com \
    --to=isaku.yamahata@intel.com \
    --cc=davidskidmore@google.com \
    --cc=isaku.yamahata@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.gupta@amd.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=srutherford@google.com \
    --cc=wei.w.wang@intel.com \
    --cc=xiaoyao.li@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 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®