From: Ira Weiny <ira.weiny@intel.com>
To: Vishal Annapurve <vannapurve@google.com>,
Sean Christopherson <seanjc@google.com>
Cc: Ira Weiny <ira.weiny@intel.com>, Yan Zhao <yan.y.zhao@intel.com>,
"Michael Roth" <michael.roth@amd.com>, <pbonzini@redhat.com>,
<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<rick.p.edgecombe@intel.com>, <kai.huang@intel.com>,
<adrian.hunter@intel.com>, <reinette.chatre@intel.com>,
<xiaoyao.li@intel.com>, <tony.lindgren@intel.com>,
<binbin.wu@linux.intel.com>, <dmatlack@google.com>,
<isaku.yamahata@intel.com>, <david@redhat.com>,
<ackerleytng@google.com>, <tabba@google.com>,
<chao.p.peng@intel.com>
Subject: Re: [RFC PATCH] KVM: TDX: Decouple TDX init mem region from kvm_gmem_populate()
Date: Thu, 2 Oct 2025 16:01:17 -0500 [thread overview]
Message-ID: <68dee81d79199_296d74294b9@iweiny-mobl.notmuch> (raw)
In-Reply-To: <CAGtprH9JifhhmTdseXLi9ax_imnY5b=K_+_bhkTXKSaW8VMFRQ@mail.gmail.com>
Vishal Annapurve wrote:
> On Tue, Aug 5, 2025 at 12:59 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Mon, Aug 04, 2025, Vishal Annapurve wrote:
> > > On Mon, Aug 4, 2025 at 5:22 PM Sean Christopherson <seanjc@google.com> wrote:
> > > > : 4) For SNP, if src != null, make the target pfn to be shared, copy
> > > > : contents and then make the target pfn back to private.
> > > >
> > > > Copying from userspace under spinlock (rwlock) is illegal, as accessing userspace
> > > > memory might_fault() and thus might_sleep().
> > >
> > > I would think that a combination of get_user_pages() and
> > > kmap_local_pfn() will prevent this situation of might_fault().
> >
> > Yes, but if SNP is using get_user_pages(), then it looks an awful lot like the
> > TDX flow, at which point isn't that an argument for keeping populate()?
>
> Ack, I agree we can't ditch kvm_gmem_populate() for SNP VMs. I am ok
> with using it for TDX/CCA VMs with the fixes discussed in this RFC.
Sean,
Where did this thread land? Was there a follow on series which came out
of this? I thought you sent a patch with the suggestions in this thread
but I can't find it.
Ira
>
> >
> > > Memory population in my opinion is best solved either by users asserting
> > > ownership of the memory and writing to it directly or by using guest_memfd
> > > (to be) exposed APIs to populate memory ranges given a source buffer. IMO
> > > kvm_gmem_populate() is doing something different than both of these options.
> >
> > In a perfect world, yes, guest_memfd would provide a clean, well-defined API
> > without needing a complicated dance between vendor code and guest_memfd. But,
> > sadly, the world of CoCo is anything but perfect. It's not KVM's fault that
> > every vendor came up with a different CoCo architecture. I.e. we can't "fix"
> > the underlying issue of SNP and TDX having significantly different ways for
> > initializing private memory.
> >
> > What we can do is shift as much code to common KVM as possible, e.g. to minimize
> > maintenance costs, reduce boilerplate and/or copy+paste code, provide a consistent
> > ABI, etc. Those things always need to be balanced against overall complexity, but
> > IMO providing a vendor callback doesn't add anywhere near enough complexity to
> > justify open coding the same concept in every vendor implementation.
>
> Ack. My goal was to steer this implementation towards reusing existing
> KVM synchronization to protect guest memory population within KVM
> vendor logic rather than relying on guest_memfd filemap lock to
> provide the needed protection here. That being said, I agree that we
> can't solve this problem cleanly in a manner that works for all
> architectures.
next prev parent reply other threads:[~2025-10-02 20:59 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 6:26 [RFC PATCH] KVM: TDX: Decouple TDX init mem region from kvm_gmem_populate() Yan Zhao
2025-07-03 16:51 ` Vishal Annapurve
2025-07-09 23:21 ` Michael Roth
2025-07-10 16:24 ` Sean Christopherson
2025-07-11 1:41 ` Ira Weiny
2025-07-11 14:21 ` Sean Christopherson
2025-07-11 4:36 ` Yan Zhao
2025-07-11 15:17 ` Michael Roth
2025-07-11 15:39 ` Sean Christopherson
2025-07-11 16:34 ` Michael Roth
2025-07-11 18:38 ` Vishal Annapurve
2025-07-11 19:49 ` Michael Roth
2025-07-11 20:19 ` Sean Christopherson
2025-07-11 20:25 ` Ira Weiny
2025-07-11 22:56 ` Sean Christopherson
2025-07-11 23:04 ` Vishal Annapurve
2025-07-14 23:11 ` Ira Weiny
2025-07-15 0:41 ` Vishal Annapurve
2025-07-14 23:08 ` Ira Weiny
2025-07-14 23:12 ` Sean Christopherson
2025-07-11 18:46 ` Vishal Annapurve
2025-07-12 17:38 ` Vishal Annapurve
2025-07-14 6:15 ` Yan Zhao
2025-07-14 15:46 ` Sean Christopherson
2025-07-14 16:02 ` David Hildenbrand
2025-07-14 16:07 ` Sean Christopherson
2025-07-15 1:10 ` Yan Zhao
2025-07-18 9:14 ` Yan Zhao
2025-07-18 15:57 ` Vishal Annapurve
2025-07-18 18:42 ` Ira Weiny
2025-07-18 18:59 ` Vishal Annapurve
2025-07-21 17:46 ` Ira Weiny
2025-07-28 9:48 ` Yan Zhao
2025-07-29 0:45 ` Vishal Annapurve
2025-07-29 1:37 ` Yan Zhao
2025-07-29 16:33 ` Ira Weiny
2025-08-05 0:22 ` Sean Christopherson
2025-08-05 1:20 ` Vishal Annapurve
2025-08-05 14:30 ` Vishal Annapurve
2025-08-05 19:59 ` Sean Christopherson
2025-08-06 0:09 ` Vishal Annapurve
2025-10-02 21:01 ` Ira Weiny [this message]
2025-10-03 0:15 ` Sean Christopherson
2025-10-03 15:31 ` Ira Weiny
2025-07-14 3:20 ` Yan Zhao
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=68dee81d79199_296d74294b9@iweiny-mobl.notmuch \
--to=ira.weiny@intel.com \
--cc=ackerleytng@google.com \
--cc=adrian.hunter@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=chao.p.peng@intel.com \
--cc=david@redhat.com \
--cc=dmatlack@google.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tabba@google.com \
--cc=tony.lindgren@intel.com \
--cc=vannapurve@google.com \
--cc=xiaoyao.li@intel.com \
--cc=yan.y.zhao@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