Re: [PATCH v10 02/15] set_memory: add folio_{zap, restore}_direct_map helpers

David Hildenbrand (Arm)
2026-03-10T00:00:48Z

On 3/6/26 16:41, Nikita Kalyazin wrote:
>
>
> On 06/03/2026 15:17, David Hildenbrand (Arm) wrote:
>> On 3/6/26 15:48, Nikita Kalyazin wrote:
>>>
>>>
>>>
>>> Yeah, that's unfortunately the status quo as pointed by Aneesh [1]
>>>
>>> [1] https://lore.kernel.org/kvm/yq5ajz07czvz.fsf@kernel.org/
>>>
>>>
>>> Yes, looks like that.  I'll remove the explicit flush and rely on
>>> folio_zap_direct_map().
>>>
>>>
>>> I believe Dave meant to address that with folio_{zap,restore}
>>> _direct_map() [2].
>>>
>>> [2] https://lore.kernel.org/kvm/9409531b-589b-4a54-
>>> b122-06a3cf0846f3@intel.com/
>>>
>>>
>>> I'd be inclined to know what arch maintainers think because I don't have
>>> a strong opinion on that.
>>
>> You could also just perform a double flush, and let people that
>> implemented a _noflush() to perform a flush optimize that later.
>
> Do you propose to just universalise the one from x86?
>
> int folio_zap_direct_map(struct folio *folio)
> {
>     const void *addr = folio_address(folio);
>     int ret;
>
>     ret = set_direct_map_valid_noflush(addr, folio_nr_pages(folio), false);
>     flush_tlb_kernel_range((unsigned long)addr,
>                    (unsigned long)addr + folio_size(folio));
>
>     return ret;
> }

Yes, exactly something along those lines!
--
Cheers,

David