Skip to contentSkip to conversation

xen/balloon: Fix mapping PG_offline pages to user space

PATCH Applied David Hildenbrand 2 participants 5 messages Mar 14, 2019 – Mar 15, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/balloon: Fix mapping PG_offline pages to user space

The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls.

Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages).

So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline.

Fixes 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)

---

v1 -> v2:
- Readd the braces dropped by accident :)

 drivers/xen/balloon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/xen/balloon.c +4 -1
index 39b229f9e256..d37dd5bb7a8f 100644
@@ -604,6 +604,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
 	while (pgno < nr_pages) {
 		page = balloon_retrieve(true);
 		if (page) {
+			__ClearPageOffline(page);
 			pages[pgno++] = page;
 #ifdef CONFIG_XEN_HAVE_PVMMU
 			/*
@@ -645,8 +646,10 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
 	mutex_lock(&balloon_mutex);
 
 	for (i = 0; i < nr_pages; i++) {
-		if (pages[i])
+		if (pages[i]) {
+			__SetPageOffline(pages[i]);
 			balloon_append(pages[i]);
+		}
 	}
 
 	balloon_stats.target_unpopulated -= nr_pages;
Signature · 1 line
2.17.2
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 14 lines · David Hildenbrand

The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls.

Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages).

So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline.

Quoted 4 lines
Fixes 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)

Juergen

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to David Hildenbrand
Quoted 14 lines · David Hildenbrand

The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls.

Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages).

So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline.

Quoted 4 lines
Fixes 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer Applied
#3 lore raw
In reply to David Hildenbrand
Quoted 14 lines · David Hildenbrand

The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls.

Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages).

So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline.

Quoted 4 lines
Fixes 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)

Pushed to xen/tip.git for-linus-5.1b

Juergen

maintainer Applied
#4 lore raw
In reply to David Hildenbrand
Quoted 14 lines · David Hildenbrand

The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls.

Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages).

So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline.

Quoted 4 lines
Fixes 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)

Pushed to xen/tip.git for-linus-5.1b

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel