[PATCH 12/13] virtio_balloon: unaccept inflated balloon pages

From: Kevin Loughlin

Date: Mon Oct 26 2026 - 23:03:32 EST


When pages are allocated for balloon inflation in confidential
computing guests requiring page state transitions, mark the allocated
pages as unaccepted via mark_memory_unaccepted() before notifying the
host VMM. When those pages are later deflated and released via
put_page(), the page allocator routes them to zone->unaccepted_pages
for lazy re-acceptance on demand.

Signed-off-by: Kevin Loughlin <kevinloughlin@xxxxxxxxxx>
---
drivers/virtio/virtio_balloon.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index e10bd792ef7c..217431e75751 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -329,6 +329,15 @@ static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num)
unsigned int pfns = (1 << page_order) * VIRTIO_BALLOON_PAGES_PER_PAGE;

list_del(&page->lru);
+ if (virtballoon_cc_needs_state_transition()) {
+ unsigned long page_size = (1UL << page_order) * PAGE_SIZE;
+ phys_addr_t paddr = page_to_phys(page);
+
+ if (mark_memory_unaccepted(paddr, page_size)) {
+ put_page(page);
+ continue;
+ }
+ }
balloon_page_enqueue(&vb->vb_dev_info, page);

vb->num_pages += pfns;
--
2.56.0.307.g5fe7bd680c-goog