All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yan Zhao" <yan.y.zhao@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 05/15] KVM: TDX: Move KVM_BUG_ON()s in __tdp_mmu_set_spte_atomic() to TDX code
Date: Thu, 28 May 2026 09:45:08 +0000	[thread overview]
Message-ID: <20260528094509.3EF631F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260528081139.10284-1-yan.y.zhao@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Returning a deterministic error (-EIO or -EBUSY) from mirror SPTE modification paths causes an unkillable in-kernel infinite loop in TDP MMU iterators, converting a VM-scoped bug into a host kernel hang.
--

commit e15424312043140d3e6eda83d94e044749575d32
Author: Rick Edgecombe <rick.p.edgecombe@intel.com>

KVM: TDX: Move KVM_BUG_ON()s in __tdp_mmu_set_spte_atomic() to TDX code

Drop some KVM_BUG_ON()s that are guarding against TDP MMU attempting to
propagate unsupported changes to the external page table through
__tdp_mmu_set_spte_atomic(). Have TDX code trigger them instead.

[ ... ]

> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 6a48bbab5f141..8e97af221b40e 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -1717,6 +1717,9 @@ static int tdx_sept_set_private_spte(struct kvm *kvm, gfn_t gfn, u64 old_spte,
>  				     u64 new_spte, enum pg_level level)
>  {
> +	if (KVM_BUG_ON(is_shadow_present_pte(old_spte), kvm))
> +		return -EIO;
> +

[Severity: High]
This is a pre-existing issue, but does returning a deterministic error
(-EIO) here cause an unkillable in-kernel infinite loop in the TDP MMU
iterators?

Looking at the TDP MMU iterators, they evaluate the return value of
tdp_mmu_set_spte_atomic() and execute goto retry on any non-zero value,
assuming a transient cmpxchg race.

If tdx_sept_set_private_spte() returns -EIO, this propagates back to
__tdp_mmu_set_spte_atomic(), which restores the unmodified iter->old_spte
and returns the error:

arch/x86/kvm/mmu/tdp_mmu.c:__tdp_mmu_set_spte_atomic() {
    ...
		ret = kvm_x86_call(set_external_spte)(kvm, iter->gfn, iter->old_spte,
						      new_spte, iter->level);

		if (ret)
			__kvm_tdp_mmu_write_spte(iter->sptep, iter->old_spte);
    ...
		return ret;
}

Because the memory is restored and try_cmpxchg64() isn't used to update
iter->old_spte on this failure path, the local iterator state remains
unchanged. The loop retries, evaluates the exact same conditions, hits
the KVM_BUG_ON() again, and fails endlessly.

Since tdp_mmu_iter_cond_resched() refuses to yield without forward progress,
can this tight loop hold the RCU read lock and burn 100% CPU, leading to an
RCU stall or soft lockup?

Prior to this patch, the same livelock occurred when
__tdp_mmu_set_spte_atomic() returned -EBUSY directly, or when
set_external_spte() returned -EIO due to hardware rejection.

>  	if (KVM_BUG_ON(!is_shadow_present_pte(new_spte), kvm))
>  		return -EIO;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260528080856.10141-1-yan.y.zhao@intel.com?part=5

  reply	other threads:[~2026-05-28  9:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  8:08 [PATCH v3 00/15] TDX MMU refactors Yan Zhao
2026-05-28  8:10 ` [PATCH v3 01/15] KVM: TDX: Drop kvm_x86_ops.link_external_spt() Yan Zhao
2026-05-28  8:11 ` [PATCH v3 02/15] KVM: TDX: Wrap mapping of leaf and non-leaf S-EPT entries into helpers Yan Zhao
2026-05-28  8:11 ` [PATCH v3 03/15] KVM: x86/mmu: Fold set_external_spte_present() into its sole caller Yan Zhao
2026-05-28  8:11 ` [PATCH v3 04/15] KVM: x86/mmu: Plumb param "old_spte" into kvm_x86_ops.set_external_spte() Yan Zhao
2026-05-28  8:11 ` [PATCH v3 05/15] KVM: TDX: Move KVM_BUG_ON()s in __tdp_mmu_set_spte_atomic() to TDX code Yan Zhao
2026-05-28  9:45   ` sashiko-bot [this message]
2026-05-28  8:11 ` [PATCH v3 06/15] KVM: TDX: Move lockdep assert " Yan Zhao
2026-05-28  8:12 ` [PATCH v3 07/15] KVM: x86/tdp_mmu: Morph !is_frozen_spte() check into a KVM_MMU_WARN_ON() Yan Zhao
2026-05-28  8:12 ` [PATCH v3 08/15] KVM: x86/mmu: Plumb "sp" _pointer_ into the TDP MMU's handle_changed_spte() Yan Zhao
2026-05-28  8:12 ` [PATCH v3 09/15] KVM: x86/tdp_mmu: Centrally propagate to-present/atomic zap updates to external PTEs Yan Zhao
2026-05-28  9:52   ` sashiko-bot
2026-05-28  8:12 ` [PATCH v3 10/15] KVM: x86/mmu: Drop KVM_BUG_ON() on shared lock to zap child " Yan Zhao
2026-05-28  8:12 ` [PATCH v3 11/15] KVM: TDX: Hoist tdx_sept_remove_private_spte() above set_private_spte() Yan Zhao
2026-05-28  8:12 ` [PATCH v3 12/15] KVM: TDX: Drop kvm_x86_ops.remove_external_spte() Yan Zhao
2026-05-28  8:13 ` [PATCH v3 13/15] KVM: TDX: Rename tdx_sept_remove_private_spte() to show it's for leaf SPTEs Yan Zhao
2026-05-28  8:13 ` [PATCH v3 14/15] KVM: x86: Move error handling inside free_external_spt() Yan Zhao
2026-05-28  8:13 ` [PATCH v3 15/15] KVM: TDX: Move external page table freeing to TDX code Yan Zhao
2026-05-28 13:03 ` [PATCH v3 00/15] TDX MMU refactors Sean Christopherson
2026-05-29  5:34   ` 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=20260528094509.3EF631F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 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.