diff options
author | David Hildenbrand <david@redhat.com> | 2019-03-14 12:02:56 -0400 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2019-03-15 10:35:35 -0400 |
commit | 0266def913771e718fd0c998eecb072e0685e2c9 (patch) | |
tree | 1d503c09f9630e1d17424c44b502c0d0ea4b2a8d /drivers/xen | |
parent | f261c4e529dac5608a604d3dd3ae1cd2adf23c89 (diff) |
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)
Reported-by: Julien Grall <julien.grall@arm.com>
Tested-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/balloon.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 39b229f9e256..d37dd5bb7a8f 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -604,6 +604,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) | |||
604 | while (pgno < nr_pages) { | 604 | while (pgno < nr_pages) { |
605 | page = balloon_retrieve(true); | 605 | page = balloon_retrieve(true); |
606 | if (page) { | 606 | if (page) { |
607 | __ClearPageOffline(page); | ||
607 | pages[pgno++] = page; | 608 | pages[pgno++] = page; |
608 | #ifdef CONFIG_XEN_HAVE_PVMMU | 609 | #ifdef CONFIG_XEN_HAVE_PVMMU |
609 | /* | 610 | /* |
@@ -645,8 +646,10 @@ void free_xenballooned_pages(int nr_pages, struct page **pages) | |||
645 | mutex_lock(&balloon_mutex); | 646 | mutex_lock(&balloon_mutex); |
646 | 647 | ||
647 | for (i = 0; i < nr_pages; i++) { | 648 | for (i = 0; i < nr_pages; i++) { |
648 | if (pages[i]) | 649 | if (pages[i]) { |
650 | __SetPageOffline(pages[i]); | ||
649 | balloon_append(pages[i]); | 651 | balloon_append(pages[i]); |
652 | } | ||
650 | } | 653 | } |
651 | 654 | ||
652 | balloon_stats.target_unpopulated -= nr_pages; | 655 | balloon_stats.target_unpopulated -= nr_pages; |