[PATCH v11 2/7] mm: page_reporting: support host-zeroed reported pages
From: Michael S. Tsirkin
Date: Thu Nov 19 2026 - 07:02:50 EST
Add a host_zeroes_pages flag to page_reporting_dev_info, allowing
page reporting devices to declare that their host zeros reported pages
on reclaim.
On successful reporting by such a device that guarantees zero contents, set
PG_zeroed.
Note, that hosts zero the pages for guests, safely, even on
architectures with aliasing data caches, and even without knowing the
guest user virtual addresses.
Specifically, ARM64 data caches behave as PIPT; KVM handles cache maintenance
around stage-2 mappings and invalidates the whole I-cache when it aliases.
On aliasing MIPS, host unmapping flushes the whole D-cache, and slow GUP
flushes the host aliases of replacement backing pages before KVM maps
them.
Any host that can't handle this, will simply not set the flag in its
page reporting device.
No driver sets host_zeroes_pages yet.
Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Assisted-by: LLM
---
include/linux/page_reporting.h | 8 ++++++++
mm/page_reporting.c | 3 +++
2 files changed, 11 insertions(+)
diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h
index 272b1274efdc1..49adfc5d45804 100644
--- a/include/linux/page_reporting.h
+++ b/include/linux/page_reporting.h
@@ -13,6 +13,14 @@ struct page_reporting_dev_info {
int (*report)(struct page_reporting_dev_info *prdev,
struct scatterlist *sg, unsigned int nents);
+ /*
+ * If true, the host zeros reported pages on reclaim.
+ * This includes any architecture-required cache flushing or
+ * invalidation, especially on architectures with aliasing data
+ * caches, so guest accesses observe the zeroed contents.
+ */
+ bool host_zeroes_pages;
+
/* work struct for processing reports */
struct delayed_work work;
diff --git a/mm/page_reporting.c b/mm/page_reporting.c
index de587be178010..841dcd64777d1 100644
--- a/mm/page_reporting.c
+++ b/mm/page_reporting.c
@@ -127,6 +127,9 @@ page_reporting_drain(struct page_reporting_dev_info *prdev,
int mt = get_pageblock_migratetype(page);
unsigned int order = get_order(sg->length);
+ if (reported && prdev->host_zeroes_pages)
+ __SetPageZeroed(page);
+
__putback_isolated_page(page, order, mt);
/* If the pages were not reported due to error skip flagging */
--
MST