On 15/01/2026 12:12, Heiko Carstens wrote:
On Wed, Jan 14, 2026 at 01:45:23PM +0000, Kalyazin, Nikita wrote:
From: Nikita Kalyazin <[email protected]>
These allow guest_memfd to remove its memory from the direct map.
Only implement them for architectures that have direct map.
In folio_zap_direct_map(), flush TLB on architectures where
set_direct_map_valid_noflush() does not flush it internally.
...
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index d3ce04a4b248..df4a487b484d 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -412,6 +412,24 @@ int set_direct_map_valid_noflush(struct page *page,
unsigned nr, bool valid)
return __set_memory((unsigned long)page_to_virt(page), nr, flags);
}
+int folio_zap_direct_map(struct folio *folio)
+{
+ unsigned long addr = (unsigned long)folio_address(folio);
+ int ret;
+
+ ret = set_direct_map_valid_noflush(folio_page(folio, 0),
+ folio_nr_pages(folio), false);
+ flush_tlb_kernel_range(addr, addr + folio_size(folio));
+
+ return ret;
+}
The instructions used in the s390 implementation of
set_direct_map_valid_noflush() do flush TLB entries.
The extra flush_tlb_kernel_range() is not required.
Thanks, Heiko. Will update in the next version.