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 <keirf@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Keir Fraser 2022-08-18 10:41:35 +00:00 committed by Quentin Perret
parent 23cfd30bb3
commit e95813e9da

View File

@ -7,6 +7,7 @@
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/scatterlist.h>
#include <linux/mem_relinquish.h>
#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<<order); i++)
page_relinquish(page+i);
continue;
}