[PATCH] drivers/virt: pkvm: Zero and clean memory before sharing it with the host
Fuad Tabba
fuad.tabba at linux.dev
Mon Nov 16 04:25:43 PST 2026
Hi Vincent,
On Mon, 16 Nov 2026 at 11:28, Vincent Donnefort <vdonnefort at google.com> wrote:
[...]
> > + /*
> > + * The host can read the pages as soon as they are shared, possibly
> > + * through a Non-cacheable mapping. No caller relies on their contents.
> > + */
> > + memset((void *)addr, 0, size);
>
> Are we sure we want that? The guest may want to setup memory and then share it.
> I am not sure about modifying this API.
Right! I wanted to fix the bug for the ITS property table, which is
shared before it's initialized, and totally forgot that this is the
path all sharing goes through... I'll drop this, and put that fix back
in the ITS series.
> > + dcache_clean_poc(addr, addr + size);
>
> I believe the hypervisor is already doing the cache maintainance when the page
> is mapped back into the host. (see stage2_map_walker_try_leaf())
I don't think it does on this path. host_mmu.mm_ops doesn't have a
dcache_clean_inval_poc() callback, so stage2_map_walker_try_leaf()
doesn't do the CMO for a host mapping. On the guest's side,
__pkvm_guest_share_host() only changes the software bits of the
existing mapping, and the walker returns before the CMO in that case.
Cheers,
/fuad
More information about the linux-arm-kernel
mailing list