Re: [RFC PATCH v5 16/45] x86/virt/tdx: Add tdx_alloc/free_control_page() helpers
From: Sean Christopherson
Date: Thu Jan 29 2026 - 20:30:31 EST
On Wed, Jan 28, 2026, Sean Christopherson wrote:
> +/*
> + * For SEAMCALLs that pass a bundle of pages, the TDX spec treats the registers
> + * like an array, as they are ordered in the struct. The effective array size
> + * is (obviously) limited by the number or registers, relative to the starting
> + * register. Fill the register array at a given starting register, with sanity
> + * checks to avoid overflowing the args structure.
> + */
> +static void dpamt_copy_regs_array(struct tdx_module_args *args, void *reg,
> + u64 *pamt_pa_array, bool copy_to_regs)
> +{
> + int size = tdx_dpamt_entry_pages() * sizeof(*pamt_pa_array);
> +
> + if (WARN_ON_ONCE(reg + size > (void *)args) + sizeof(*args))
The above closing ')' after args is misplaced, this should be
if (WARN_ON_ONCE(reg + size > (void *)args + sizeof(*args)))
I'm still in disbelief that I managed to end up with such a horrid bug that
compiled without any warnings. *sigh*