* [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
@ 2019-03-14 15:40 David Hildenbrand
2019-03-14 15:49 ` Oscar Salvador
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: David Hildenbrand @ 2019-03-14 15:40 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, 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>
---
drivers/xen/balloon.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 39b229f9e256..751d32f41f26 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
/*
@@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
for (i = 0; i < nr_pages; i++) {
if (pages[i])
+ __SetPageOffline(pages[i]);
balloon_append(pages[i]);
}
--
2.17.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:40 [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
2019-03-14 15:49 ` Oscar Salvador
@ 2019-03-14 15:49 ` Oscar Salvador
2019-03-14 15:59 ` David Hildenbrand
2019-03-14 15:59 ` David Hildenbrand
2019-03-14 15:49 ` Jan Beulich
2019-03-14 15:49 ` Jan Beulich
3 siblings, 2 replies; 10+ messages in thread
From: Oscar Salvador @ 2019-03-14 15:49 UTC (permalink / raw)
To: David Hildenbrand
Cc: xen-devel, linux-kernel, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Julien Grall, Matthew Wilcox, Nadav Amit,
Andrew Cooper, akpm, linux-mm
On Thu, Mar 14, 2019 at 04:40:25PM +0100, David Hildenbrand wrote:
> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>
> for (i = 0; i < nr_pages; i++) {
> if (pages[i])
> + __SetPageOffline(pages[i]);
> balloon_append(pages[i]);
didn't you forget {} there? ;-)
> }
>
> --
> 2.17.2
>
--
Oscar Salvador
SUSE L3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:40 [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
@ 2019-03-14 15:49 ` Oscar Salvador
2019-03-14 15:49 ` Oscar Salvador
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Oscar Salvador @ 2019-03-14 15:49 UTC (permalink / raw)
To: David Hildenbrand
Cc: Juergen Gross, Stefano Stabellini, Andrew Cooper, linux-kernel,
Matthew Wilcox, linux-mm, Julien Grall, Nadav Amit, xen-devel,
Boris Ostrovsky, akpm
On Thu, Mar 14, 2019 at 04:40:25PM +0100, David Hildenbrand wrote:
> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>
> for (i = 0; i < nr_pages; i++) {
> if (pages[i])
> + __SetPageOffline(pages[i]);
> balloon_append(pages[i]);
didn't you forget {} there? ;-)
> }
>
> --
> 2.17.2
>
--
Oscar Salvador
SUSE L3
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:40 [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
@ 2019-03-14 15:49 ` Jan Beulich
2019-03-14 15:49 ` Oscar Salvador
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-03-14 15:49 UTC (permalink / raw)
To: David Hildenbrand
Cc: Julien Grall, Andrew Cooper, Matthew Wilcox, Stefano Stabellini,
linux-mm, akpm, xen-devel, Boris Ostrovsky, Juergen Gross,
linux-kernel, Nadav Amit
>>> On 14.03.19 at 16:40, <david@redhat.com> wrote:
> --- 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;
While this one's fine, ...
> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>
> for (i = 0; i < nr_pages; i++) {
> if (pages[i])
> + __SetPageOffline(pages[i]);
> balloon_append(pages[i]);
> }
... I think you want to add a pair of braces here.
Jan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
@ 2019-03-14 15:49 ` Jan Beulich
0 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-03-14 15:49 UTC (permalink / raw)
To: David Hildenbrand
Cc: Julien Grall, Andrew Cooper, Matthew Wilcox, Stefano Stabellini,
linux-mm, akpm, xen-devel, Boris Ostrovsky, Juergen Gross,
linux-kernel, Nadav Amit
>>> On 14.03.19 at 16:40, <david@redhat.com> wrote:
> --- 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;
While this one's fine, ...
> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>
> for (i = 0; i < nr_pages; i++) {
> if (pages[i])
> + __SetPageOffline(pages[i]);
> balloon_append(pages[i]);
> }
... I think you want to add a pair of braces here.
Jan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:40 [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
` (2 preceding siblings ...)
2019-03-14 15:49 ` Jan Beulich
@ 2019-03-14 15:49 ` Jan Beulich
3 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-03-14 15:49 UTC (permalink / raw)
To: David Hildenbrand
Cc: Juergen Gross, Stefano Stabellini, Andrew Cooper, linux-kernel,
Matthew Wilcox, linux-mm, Julien Grall, Nadav Amit, xen-devel,
akpm, Boris Ostrovsky
>>> On 14.03.19 at 16:40, <david@redhat.com> wrote:
> --- 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;
While this one's fine, ...
> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>
> for (i = 0; i < nr_pages; i++) {
> if (pages[i])
> + __SetPageOffline(pages[i]);
> balloon_append(pages[i]);
> }
... I think you want to add a pair of braces here.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:49 ` Oscar Salvador
@ 2019-03-14 15:59 ` David Hildenbrand
2019-03-14 15:59 ` David Hildenbrand
1 sibling, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2019-03-14 15:59 UTC (permalink / raw)
To: Oscar Salvador
Cc: xen-devel, linux-kernel, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Julien Grall, Matthew Wilcox, Nadav Amit,
Andrew Cooper, akpm, linux-mm
On 14.03.19 16:49, Oscar Salvador wrote:
> On Thu, Mar 14, 2019 at 04:40:25PM +0100, David Hildenbrand wrote:
>> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>>
>> for (i = 0; i < nr_pages; i++) {
>> if (pages[i])
>> + __SetPageOffline(pages[i]);
>> balloon_append(pages[i]);
>
> didn't you forget {} there? ;-)
>
That's what happens when you stashed the original patch and try to
recreate it quickly from a mail ;)
Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:49 ` Oscar Salvador
2019-03-14 15:59 ` David Hildenbrand
@ 2019-03-14 15:59 ` David Hildenbrand
1 sibling, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2019-03-14 15:59 UTC (permalink / raw)
To: Oscar Salvador
Cc: Juergen Gross, Stefano Stabellini, Andrew Cooper, linux-kernel,
Matthew Wilcox, linux-mm, Julien Grall, Nadav Amit, xen-devel,
Boris Ostrovsky, akpm
On 14.03.19 16:49, Oscar Salvador wrote:
> On Thu, Mar 14, 2019 at 04:40:25PM +0100, David Hildenbrand wrote:
>> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>>
>> for (i = 0; i < nr_pages; i++) {
>> if (pages[i])
>> + __SetPageOffline(pages[i]);
>> balloon_append(pages[i]);
>
> didn't you forget {} there? ;-)
>
That's what happens when you stashed the original patch and try to
recreate it quickly from a mail ;)
Thanks!
--
Thanks,
David / dhildenb
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:49 ` Jan Beulich
(?)
(?)
@ 2019-03-14 16:00 ` David Hildenbrand
-1 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2019-03-14 16:00 UTC (permalink / raw)
To: Jan Beulich
Cc: Julien Grall, Andrew Cooper, Matthew Wilcox, Stefano Stabellini,
linux-mm, akpm, xen-devel, Boris Ostrovsky, Juergen Gross,
linux-kernel, Nadav Amit
On 14.03.19 16:49, Jan Beulich wrote:
>>>> On 14.03.19 at 16:40, <david@redhat.com> wrote:
>> --- 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;
>
> While this one's fine, ...
>
>> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>>
>> for (i = 0; i < nr_pages; i++) {
>> if (pages[i])
>> + __SetPageOffline(pages[i]);
>> balloon_append(pages[i]);
>> }
>
> ... I think you want to add a pair of braces here.
>
> Jan
>
>
Indeed, dropped by accident. Will resend in a minute. Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space
2019-03-14 15:49 ` Jan Beulich
(?)
@ 2019-03-14 16:00 ` David Hildenbrand
-1 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2019-03-14 16:00 UTC (permalink / raw)
To: Jan Beulich
Cc: Juergen Gross, Stefano Stabellini, Andrew Cooper, linux-kernel,
Matthew Wilcox, linux-mm, Julien Grall, Nadav Amit, xen-devel,
akpm, Boris Ostrovsky
On 14.03.19 16:49, Jan Beulich wrote:
>>>> On 14.03.19 at 16:40, <david@redhat.com> wrote:
>> --- 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;
>
> While this one's fine, ...
>
>> @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
>>
>> for (i = 0; i < nr_pages; i++) {
>> if (pages[i])
>> + __SetPageOffline(pages[i]);
>> balloon_append(pages[i]);
>> }
>
> ... I think you want to add a pair of braces here.
>
> Jan
>
>
Indeed, dropped by accident. Will resend in a minute. Thanks!
--
Thanks,
David / dhildenb
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-03-14 16:00 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 15:40 [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space David Hildenbrand
2019-03-14 15:49 ` Oscar Salvador
2019-03-14 15:49 ` Oscar Salvador
2019-03-14 15:59 ` David Hildenbrand
2019-03-14 15:59 ` David Hildenbrand
2019-03-14 15:49 ` [Xen-devel] " Jan Beulich
2019-03-14 15:49 ` Jan Beulich
2019-03-14 16:00 ` David Hildenbrand
2019-03-14 16:00 ` [Xen-devel] " David Hildenbrand
2019-03-14 15:49 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.