From e95813e9da6b43edc63a7dd0e2f704428c992b4d Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 18 Aug 2022 10:41:35 +0000 Subject: [PATCH] ANDROID: KVM: arm64: balloon: Notify hyp before reporting free pages to host When running as a protected VM, the hypervisor isolates the VM's memory pages from the host. Returning ownership of a VM page therefore requires hypervisor involvement, and acknowledgement from the protected VM that it is voluntarily cooperating. To this end, notify pages via the new relinquish hypercall when they are being reported to the host as free and available for temporary reclaim. Bug: 240239989 Change-Id: I8718e468be63c3aacb2f79ff141fbcedd6d19b56 Signed-off-by: Keir Fraser Signed-off-by: Quentin Perret --- mm/page_reporting.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 382958eef8a9..5c4b1fb73187 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "page_reporting.h" #include "internal.h" @@ -120,7 +121,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, unsigned int page_len = PAGE_SIZE << order; struct page *page, *next; long budget; - int err = 0; + int i, err = 0; /* * Perform early check, if free area is empty there is @@ -175,6 +176,10 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, --(*offset); sg_set_page(&sgl[*offset], page, page_len, 0); + /* Notify hyp that these pages are reclaimable. */ + for (i = 0; i < (1<