mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yan Zhao <yan.y.zhao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Michael Roth <michael.roth@amd.com>,
	"Ira Weiny" <ira.weiny@intel.com>,
	Vishal Annapurve <vannapurve@google.com>,
	"Rick Edgecombe" <rick.p.edgecombe@intel.com>
Subject: Re: [RFC PATCH 00/12] KVM: x86/mmu: TDX post-populate cleanups
Date: Wed, 27 Aug 2025 17:48:50 +0800	[thread overview]
Message-ID: <aK7UghwtKUedh/zm@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <20250827000522.4022426-1-seanjc@google.com>

On Tue, Aug 26, 2025 at 05:05:10PM -0700, Sean Christopherson wrote:
> This is a largely untested series to do most of what was discussed in the
> thread regarding locking issues between gmem and TDX's post-populate hook[*],
> with more than a few side quests thrown in as I was navigating through the
> code to try to figure out how best to eliminate the copy_from_user() from
> sev_gmem_post_populate(), which has the same locking problem (copying from
> a userspace address can fault and in theory trigger the same problematic
> path, I think).
> 
> Notably absent is the extraction of copy_from_user() from
> sev_gmem_post_populate() to kvm_gmem_populate().  I've had this on my todo
> list for a few weeks now, and haven't been able to focus on it for long
> enough to get something hammered out, and with KVM Forum on the horizon, I
> don't anticipate getting 'round to it within the next month (if not much
> longer).
> 
> The thing that stymied me is what to do if snp_launch_update() is passed in
> a huge batch of pages.  I waffled between doing a slow one-at-a-time approach
> and a batched approached, and got especially stuck when trying to remember
> and/or figure out how that handling would interact with hugepage support in
> SNP in particular.
> 
> If anyone wants to tackle that project, the one thing change I definitely
> think we should do is change the post_populate() callback to operate on
> exactly one page.
Not sure if I understand it correctly.
Do you mean something like the tdx_gmem_post_populate_4k() in
https://lore.kernel.org/all/20250424030500.32720-1-yan.y.zhao@intel.com, or
invoking hugepage_set_guest_inhibit() in the post_populate() callback? 

> KVM_SEV_SNP_LAUNCH_UPDATE allows for partial progress,
> i.e. KVM's ABI doesn't require it to unwind a batch if adding a page fails.
> If we take advantage of that, then sev_gmem_post_populate() will be a bit
> simpler (though I wouldn't go so far as to call it "simple").
> 
> RFC as this is compile tested only (mostly due to lack of access to a TDX
> capable system, but also due to lack of cycles).
> 
> [*] http://lore.kernel.org/all/aG_pLUlHdYIZ2luh@google.com
> 
> Sean Christopherson (12):
>   KVM: TDX: Drop PROVE_MMU=y sanity check on to-be-populated mappings
>   KVM: x86/mmu: Add dedicated API to map guest_memfd pfn into TDP MMU
>   Revert "KVM: x86/tdp_mmu: Add a helper function to walk down the TDP
>     MMU"
>   KVM: x86/mmu: Rename kvm_tdp_map_page() to kvm_tdp_prefault_page()
>   KVM: TDX: Drop superfluous page pinning in S-EPT management
>   KVM: TDX: Return -EIO, not -EINVAL, on a KVM_BUG_ON() condition
>   KVM: TDX: Avoid a double-KVM_BUG_ON() in tdx_sept_zap_private_spte()
>   KVM: TDX: Use atomic64_dec_return() instead of a poor equivalent
>   KVM: TDX: Fold tdx_mem_page_record_premap_cnt() into its sole caller
>   KVM: TDX: Assert that slots_lock is held when nr_premapped is accessed
>   KVM: TDX: Track nr_premapped as an "unsigned long", not an
>     "atomic64_t"
>   KVM: TDX: Rename nr_premapped to nr_pending_tdh_mem_page_adds
> 
>  arch/x86/kvm/mmu.h         |   3 +-
>  arch/x86/kvm/mmu/mmu.c     |  66 ++++++++++++++++++--
>  arch/x86/kvm/mmu/tdp_mmu.c |  37 ++---------
>  arch/x86/kvm/vmx/tdx.c     | 123 +++++++++++++------------------------
>  arch/x86/kvm/vmx/tdx.h     |   9 ++-
>  5 files changed, 117 insertions(+), 121 deletions(-)
> 
> 
> base-commit: 196d9e72c4b0bd68b74a4ec7f52d248f37d0f030
> -- 
> 2.51.0.268.g9569e192d0-goog
> 

  parent reply	other threads:[~2025-08-27  9:49 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27  0:05 Sean Christopherson
2025-08-27  0:05 ` [RFC PATCH 01/12] KVM: TDX: Drop PROVE_MMU=y sanity check on to-be-populated mappings Sean Christopherson
2025-08-27  8:14   ` Yan Zhao
2025-08-28  0:37   ` Ira Weiny
2025-08-28  2:13   ` Huang, Kai
2025-08-27  0:05 ` [RFC PATCH 02/12] KVM: x86/mmu: Add dedicated API to map guest_memfd pfn into TDP MMU Sean Christopherson
2025-08-27  8:25   ` Yan Zhao
2025-08-28  0:54     ` Edgecombe, Rick P
2025-08-28  1:26       ` Edgecombe, Rick P
2025-08-28  6:23         ` Yan Zhao
2025-08-28 19:40           ` Sean Christopherson
2025-08-29  1:16             ` Yan Zhao
2025-09-01  0:39               ` Yan Zhao
2025-08-28  6:55       ` Yan Zhao
2025-08-28  0:40   ` Ira Weiny
2025-08-28  1:51     ` Edgecombe, Rick P
2025-08-28 19:57       ` Sean Christopherson
2025-08-27  0:05 ` [RFC PATCH 03/12] Revert "KVM: x86/tdp_mmu: Add a helper function to walk down the TDP MMU" Sean Christopherson
2025-08-27  0:05 ` [RFC PATCH 04/12] KVM: x86/mmu: Rename kvm_tdp_map_page() to kvm_tdp_prefault_page() Sean Christopherson
2025-08-28  2:01   ` Edgecombe, Rick P
2025-08-28 18:50     ` Sean Christopherson
2025-08-28 19:04       ` Edgecombe, Rick P
2025-08-27  0:05 ` [RFC PATCH 05/12] KVM: TDX: Drop superfluous page pinning in S-EPT management Sean Christopherson
2025-08-27  8:33   ` Yan Zhao
2025-08-28  2:05     ` Edgecombe, Rick P
2025-08-28 20:16       ` Sean Christopherson
2025-08-28  0:36   ` Ira Weiny
2025-08-28  7:08     ` Yan Zhao
2025-08-28 15:54       ` Ira Weiny
2025-08-28  2:45   ` Huang, Kai
2025-08-27  0:05 ` [RFC PATCH 06/12] KVM: TDX: Return -EIO, not -EINVAL, on a KVM_BUG_ON() condition Sean Christopherson
2025-08-27  8:39   ` Yan Zhao
2025-08-27 17:26     ` Sean Christopherson
2025-08-28  2:11   ` Edgecombe, Rick P
2025-08-28 19:21     ` Sean Christopherson
2025-08-28 20:13       ` Edgecombe, Rick P
2025-08-28 21:00         ` Sean Christopherson
2025-08-28 21:19           ` Edgecombe, Rick P
2025-08-28 21:34             ` Sean Christopherson
2025-08-28 15:03   ` Ira Weiny
2025-08-27  0:05 ` [RFC PATCH 07/12] KVM: TDX: Avoid a double-KVM_BUG_ON() in tdx_sept_zap_private_spte() Sean Christopherson
2025-08-28  2:19   ` Edgecombe, Rick P
2025-08-28 14:50     ` Edgecombe, Rick P
2025-08-29  1:10       ` Yan Zhao
2025-08-28 15:02   ` Ira Weiny
2025-08-27  0:05 ` [RFC PATCH 08/12] KVM: TDX: Use atomic64_dec_return() instead of a poor equivalent Sean Christopherson
2025-08-28  2:56   ` Edgecombe, Rick P
2025-08-28  6:48     ` Yan Zhao
2025-08-28 19:14       ` Edgecombe, Rick P
2025-08-28 22:33         ` Sean Christopherson
2025-08-28 23:18           ` Edgecombe, Rick P
2025-08-28 15:03   ` Ira Weiny
2025-08-27  0:05 ` [RFC PATCH 09/12] KVM: TDX: Fold tdx_mem_page_record_premap_cnt() into its sole caller Sean Christopherson
2025-08-27  9:02   ` Yan Zhao
2025-08-27 19:08     ` Sean Christopherson
2025-08-28  3:13       ` Edgecombe, Rick P
2025-08-28  5:56         ` Yan Zhao
2025-08-28 19:08           ` Edgecombe, Rick P
2025-08-28  5:43       ` Yan Zhao
2025-08-28 17:00         ` Sean Christopherson
2025-08-28 18:52           ` Edgecombe, Rick P
2025-08-28 20:26             ` Sean Christopherson
2025-08-28 21:33               ` Edgecombe, Rick P
2025-08-28 21:57                 ` Sean Christopherson
2025-08-28 23:17                   ` Edgecombe, Rick P
2025-08-29  6:08                   ` Yan Zhao
2025-08-28 22:06                 ` Ira Weiny
2025-08-28 23:17                   ` Sean Christopherson
2025-08-29  0:35                     ` Ira Weiny
2025-08-29  6:06                 ` Yan Zhao
2025-08-28 21:44             ` Sean Christopherson
2025-08-29  2:42             ` Binbin Wu
2025-08-29  2:31           ` Yan Zhao
2025-08-29  6:33             ` Yan Zhao
2025-08-28 15:30       ` Ira Weiny
2025-08-28 15:28     ` Ira Weiny
2025-08-27  0:05 ` [RFC PATCH 10/12] KVM: TDX: Assert that slots_lock is held when nr_premapped is accessed Sean Christopherson
2025-08-27  0:05 ` [RFC PATCH 11/12] KVM: TDX: Track nr_premapped as an "unsigned long", not an "atomic64_t" Sean Christopherson
2025-08-27  9:12   ` Yan Zhao
2025-08-27  0:05 ` [RFC PATCH 12/12] KVM: TDX: Rename nr_premapped to nr_pending_tdh_mem_page_adds Sean Christopherson
2025-08-27  9:22   ` Yan Zhao
2025-08-28 15:23   ` Ira Weiny
2025-08-27  9:48 ` Yan Zhao [this message]
2025-08-28 19:01 ` [RFC PATCH 00/12] KVM: x86/mmu: TDX post-populate cleanups Edgecombe, Rick P
2025-08-28 23:19   ` Sean Christopherson

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=aK7UghwtKUedh/zm@yzhao56-desk.sh.intel.com \
    --to=yan.y.zhao@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=vannapurve@google.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®