Re: [PATCH v7 05/12] KVM: guest_memfd: Add flag to remove from direct map

Aneesh Kumar K.V
2025-11-03T07:57:23Z

"Roy, Patrick" <roypat@amazon.co.uk> writes:

....

> +static int kvm_gmem_folio_zap_direct_map(struct folio *folio)
> +{
> + if (kvm_gmem_folio_no_direct_map(folio))
> + return 0;
> +
> + int r = set_direct_map_valid_noflush(folio_page(folio, 0), folio_nr_pages(folio),
> + false);
> +
> + if (!r) {
> + unsigned long addr = (unsigned long) folio_address(folio);
> + folio->private = (void *) ((u64) folio->private & KVM_GMEM_FOLIO_NO_DIRECT_MAP);
> + flush_tlb_kernel_range(addr, addr + folio_size(folio));
> + }
> +
> + return r;
> +}

These 'noflush' functions are actually doing flush_tlb_kernel

[-] ∘ flush_tlb_kernel_range
|-[-] ← __change_memory_common
| `-[-] ← set_memory_valid
| `- ← set_direct_map_valid_noflush

-aneesh