Re: [PATCH 23/33] KVM: TDX: create/destroy VM structure
From: Dave Hansen
Date: Wed Jun 25 2025 - 11:47:28 EST
On 2/26/25 10:14, Paolo Bonzini wrote:
> +static void tdx_clear_page(struct page *page)
> +{
> + const void *zero_page = (const void *) page_to_virt(ZERO_PAGE(0));
> + void *dest = page_to_virt(page);
> + unsigned long i;
> +
> + /*
> + * The page could have been poisoned. MOVDIR64B also clears
> + * the poison bit so the kernel can safely use the page again.
> + */
> + for (i = 0; i < PAGE_SIZE; i += 64)
> + movdir64b(dest + i, zero_page);
> + /*
> + * MOVDIR64B store uses WC buffer. Prevent following memory reads
> + * from seeing potentially poisoned cache.
> + */
> + __mb();
> +}
Hey guys,
This ended up in KVM code when we already have the *VERY* similar
reset_tdx_pages().
Could we consolidate them, please? There's no reason to sprinkle
knowledge of movdir64b's memory ordering rules all across the tree.
Adrian, this is probably something to go do, first, before you try and
poke at this code that probably shouldn't be in KVM in the first place.