ANDROID: ARM64: virtio_balloon: Disable balloon with warning if granule too large

If the reporting granule is larger than guest page size, we cannot
safely relinquish memory to the hypervisor.

Bug: 381400679
Bug: 357781595
Change-Id: I84461c21e44209021afe617ed2796108c5c43718
Signed-off-by: Keir Fraser <keirf@google.com>
This commit is contained in:
Keir Fraser
2025-01-21 12:12:51 +00:00
committed by Sebastian Ene
parent dd32b792c1
commit 9e68f0cc22
3 changed files with 11 additions and 0 deletions
@@ -114,6 +114,12 @@ static int mmio_guard_ioremap_hook(phys_addr_t phys, size_t size,
static bool mem_relinquish_available;
bool page_relinquish_disallowed(void)
{
return mem_relinquish_available && (pkvm_granule > PAGE_SIZE);
}
EXPORT_SYMBOL_GPL(page_relinquish_disallowed);
void page_relinquish(struct page *page)
{
phys_addr_t phys, end;
+3
View File
@@ -1182,6 +1182,9 @@ static int virtballoon_restore(struct virtio_device *vdev)
static int virtballoon_validate(struct virtio_device *vdev)
{
if (WARN_ON(page_relinquish_disallowed()))
return -EINVAL;
/*
* Inform the hypervisor that our pages are poisoned or
* initialized. If we cannot do that then we should disable
+2
View File
@@ -11,10 +11,12 @@ struct page;
#ifdef CONFIG_MEMORY_RELINQUISH
bool page_relinquish_disallowed(void);
void page_relinquish(struct page *page);
#else /* !CONFIG_MEMORY_RELINQUISH */
static inline bool page_relinquish_disallowed(void) { return false; }
static inline void page_relinquish(struct page *page) { }
#endif /* CONFIG_MEMORY_RELINQUISH */