linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space
@ 2019-03-14 16:02 David Hildenbrand
  2019-03-14 16:05 ` Juergen Gross
  2019-03-15 14:53 ` Juergen Gross
  0 siblings, 2 replies; 3+ messages in thread
From: David Hildenbrand @ 2019-03-14 16:02 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Julien Grall, Matthew Wilcox, Nadav Amit, Andrew Cooper, akpm,
	linux-mm, Oscar Salvador, Jan Beulich, 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.

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>
---

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


 drivers/xen/balloon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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)
 	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;
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space
  2019-03-14 16:02 [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
@ 2019-03-14 16:05 ` Juergen Gross
  2019-03-15 14:53 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2019-03-14 16:05 UTC (permalink / raw)
  To: David Hildenbrand, xen-devel
  Cc: linux-kernel, Boris Ostrovsky, Stefano Stabellini, Julien Grall,
	Matthew Wilcox, Nadav Amit, Andrew Cooper, akpm, linux-mm,
	Oscar Salvador, Jan Beulich

On 14/03/2019 17:02, David Hildenbrand wrote:
> 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>


Juergen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space
  2019-03-14 16:02 [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
  2019-03-14 16:05 ` Juergen Gross
@ 2019-03-15 14:53 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2019-03-15 14:53 UTC (permalink / raw)
  To: David Hildenbrand, xen-devel
  Cc: linux-kernel, Boris Ostrovsky, Stefano Stabellini, Julien Grall,
	Matthew Wilcox, Nadav Amit, Andrew Cooper, akpm, linux-mm,
	Oscar Salvador, Jan Beulich

On 14/03/2019 17:02, David Hildenbrand wrote:
> 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>

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


Juergen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-15 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 16:02 [PATCH v2] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
2019-03-14 16:05 ` Juergen Gross
2019-03-15 14:53 ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).