Re: [RFC PATCH v5 20/45] KVM: x86/mmu: Allocate/free S-EPT pages using tdx_{alloc,free}_control_page()

From: Sean Christopherson

Date: Mon Feb 09 2026 - 19:04:04 EST


On Mon, Feb 09, 2026, Dave Hansen wrote:
> On 2/6/26 07:01, Sean Christopherson wrote:
> > /* Bump PAMT refcount for the given page and allocate PAMT memory if needed */
> > int __tdx_pamt_get(u64 pfn, struct tdx_pamt_cache *cache)
> > @@ -2272,7 +2272,7 @@ int __tdx_pamt_get(u64 pfn, struct tdx_pamt_cache *cache)
> > if (ret)
> > goto out_free;
> >
> > - scoped_guard(spinlock, &pamt_lock) {
> > + scoped_guard(raw_spinlock_irqsave, &pamt_lock) {
> > /*
> > * Lost race to other tdx_pamt_add(). Other task has already allocated
> > * PAMT memory for the HPA.
> > @@ -2348,7 +2348,7 @@ void __tdx_pamt_put(u64 pfn)
>
> Why does this need to be a raw spinlock? irqsave, sure, but raw?

Huh, TIL. (And just when I thought I finally had my head wrapped around RT "spinlocks"):

The hard interrupt related suffixes for spin_lock / spin_unlock operations
(_irq, _irqsave / _irqrestore) do not affect the CPU’s interrupt disabled state.

Ah, and running RCU callbacks from soft IRQ context is straight up disallowed for
PREEMPT_RT.

/* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
static bool use_softirq = !IS_ENABLED(CONFIG_PREEMPT_RT);
#ifndef CONFIG_PREEMPT_RT
module_param(use_softirq, bool, 0444);
#endif

So yeah, just spinlock_irqsave should be fine. Though the way things are trending,
it'll be a moot point if KVM ends up freeing S-EPT page tables from task context.

> The page allocator locks are used in this context and aren't raw.