From: sashiko-bot@kernel.org
To: "Rick Edgecombe" <rick.p.edgecombe@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v8 06/11] KVM: TDX: Allocate PAMT memory for TD and vCPU control structures
Date: Sat, 25 Jul 2026 00:35:24 +0000 [thread overview]
Message-ID: <20260725003525.5A10B1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260725002302.3337017-7-rick.p.edgecombe@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Acquiring `cpus_read_lock()` after holding `kvm->lock` and `kvm->slots_lock` creates an ABBA deadlock risk.
--
--- Patch [6]: [PATCH v8 06/11] KVM: TDX: Allocate PAMT memory for TD and vCPU control structures ---
commit 777b107da8496af75d46b0c5bfc966aabe90a027
Author: Kiryl Shutsemau <kas@kernel.org>
KVM: TDX: Allocate PAMT memory for TD and vCPU control structures
This commit replaces raw page allocation and free functions with TDX control
page helpers for TD and vCPU control structures. This allows the operations
to properly handle Dynamic PAMT backing.
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index d1af0a752e97e..528ebb3cb0389 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
[ ... ]
> @@ -2472,7 +2472,7 @@ static int __tdx_td_init(struct kvm *kvm, struct td_params *td_params,
> goto free_tdr;
>
> for (i = 0; i < kvm_tdx->td.tdcs_nr_pages; i++) {
> - tdcs_pages[i] = alloc_page(GFP_KERNEL_ACCOUNT);
> + tdcs_pages[i] = tdx_alloc_control_page();
> if (!tdcs_pages[i])
> goto free_tdcs;
> }
[Severity: High]
This is a pre-existing issue, but does taking cpus_read_lock() inside this
function create an ABBA deadlock risk?
Looking at __tdx_td_init(), just a few lines below this allocation loop, the
code calls cpus_read_lock():
for (i = 0; i < kvm_tdx->td.tdcs_nr_pages; i++) {
tdcs_pages[i] = tdx_alloc_control_page();
if (!tdcs_pages[i])
goto free_tdcs;
}
if (!zalloc_cpumask_var(&packages, GFP_KERNEL))
goto free_tdcs;
cpus_read_lock();
This function is reached via a KVM_TDX_INIT_VM ioctl, which triggers
tdx_vm_ioctl(). That ioctl handler acquires the VM state locks using
CLASS(tdx_vm_state_guard, guard)(kvm) before calling __tdx_td_init().
Is it safe to acquire cpus_read_lock() while kvm->lock and kvm->slots_lock
are already held, or does this violate the KVM locking hierarchy where
cpus_read_lock() should be the outermost lock to prevent deadlocks against
CPU hotplug operations?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725002302.3337017-1-rick.p.edgecombe@intel.com?part=6
next prev parent reply other threads:[~2026-07-25 0:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 0:22 [PATCH v8 00/11] Dynamic PAMT Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 01/11] x86/virt/tdx: Simplify PAMT layout calculation Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 02/11] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT Rick Edgecombe
2026-07-25 0:33 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 03/11] x86/virt/tdx: Add tdx_alloc/free_control_page() helpers Rick Edgecombe
2026-07-25 0:35 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 04/11] x86/virt/tdx: Allocate refcounts for Dynamic PAMT memory Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 05/11] x86/virt/tdx: Handle multiple callers in tdx_pamt_get/put() Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 06/11] KVM: TDX: Allocate PAMT memory for TD and vCPU control structures Rick Edgecombe
2026-07-25 0:35 ` sashiko-bot [this message]
2026-07-25 0:22 ` [PATCH v8 07/11] x86/tdx: Add APIs to support Dynamic PAMT ops from KVM's fault path Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 08/11] KVM: TDX: Get/put PAMT pages when (un)mapping private memory Rick Edgecombe
2026-07-25 0:46 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 09/11] x86/virt/tdx: Enable Dynamic PAMT Rick Edgecombe
2026-07-25 0:23 ` [PATCH v8 10/11] Documentation/x86: Add documentation for TDX's " Rick Edgecombe
2026-07-25 0:23 ` [PATCH v8 11/11] x86/virt/tdx: Optimize tdx_pamt_get/put() Rick Edgecombe
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=20260725003525.5A10B1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=rick.p.edgecombe@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.