Re: [RFC PATCH v8 02/14] mm: Zero memory during shared memory transitions

From: Kiryl Shutsemau

Date: Fri Sep 25 2026 - 08:09:18 EST


On Thu, Sep 24, 2026 at 03:35:17PM +0530, Aneesh Kumar K.V (Arm) wrote:
> diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
> index f904a636d449..1f1f39082391 100644
> --- a/arch/x86/coco/tdx/tdx.c
> +++ b/arch/x86/coco/tdx/tdx.c
> @@ -978,6 +978,9 @@ static bool tdx_enc_status_changed(unsigned long vaddr, int numpages, bool enc)
> static int tdx_enc_status_change_prepare(unsigned long vaddr, int numpages,
> bool enc)
> {
> + if (!enc)
> + memset((void *)vaddr, 0, (size_t)numpages << PAGE_SHIFT);
> +
> /*
> * Only handle shared->private conversion here.
> * See the comment in tdx_early_init().

This doesn't make sense to me.

On TDX the memset zeroes a page that is about to be dropped.
MapGPA(shared) makes the VMM back the GPA with different memory, and
what the guest reads afterwards through the shared mapping is whatever
the host has there.

--
Kiryl Shutsemau / Kirill A. Shutemov