* [PATCH] xen/mm: Unmap page for direct mapped domain on decrease reservation
@ 2015-10-27 11:33 Julien Grall
2015-10-27 13:08 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2015-10-27 11:33 UTC (permalink / raw)
To: xen-devel
Cc: Keir Fraser, ian.campbell, stefano.stabellini, Tim Deegan,
Julien Grall, Jan Beulich
Direct mapped domain needs to retrieve the exact same underlying
physical page when the region is re-populated.
Currently, when the memory reservation for this domain is decreased, the
request is just ignored and the page stayed mapped in the P2M. However,
this make more difficult to spot issue when the domain has not yet mapped
foreign page but trying to access the region.
What we really care for direct mapped domain is to not give back the
page to the allocator. So we can re-enable to direct mapped when the guest
memory region is re-populated.
The rest of the process to remove a page can be safely done. This
also ensures us to stay close to the normal domain memory handling.
At the same time, drop the trailing whitespaces around the code
modified.
Signed-off-by: Julien Grall <julien.grall@citrix.com>
---
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
This helped me to debug 64KB pages when only a part of the page is
actually mapped to foreign memory.
With this patch, direct domain will have the region ballooned unmap
until it decides to map foreign page.
---
xen/common/memory.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/xen/common/memory.c b/xen/common/memory.c
index 206955f..fd1f268 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -257,8 +257,16 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
put_page_and_type(page);
-
- if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
+
+ /*
+ * With the lack for iommu on some ARM platform, domain with DMA-capable
+ * device must retrieve the same pfn when the hypercall populate_physmap
+ * is called.
+ *
+ * For this purpose, the page is kept allocated.
+ */
+ if ( !is_domain_direct_mapped(d) &&
+ test_and_clear_bit(_PGC_allocated, &page->count_info) )
put_page(page);
guest_physmap_remove_page(d, gmfn, mfn, 0);
@@ -309,13 +317,6 @@ static void decrease_reservation(struct memop_args *a)
&& p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) )
continue;
- /* With the lack for iommu on some ARM platform, domain with DMA-capable
- * device must retrieve the same pfn when the hypercall
- * populate_physmap is called.
- */
- if ( is_domain_direct_mapped(a->domain) )
- continue;
-
for ( j = 0; j < (1 << a->extent_order); j++ )
if ( !guest_remove_page(a->domain, gmfn + j) )
goto out;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/mm: Unmap page for direct mapped domain on decrease reservation
2015-10-27 11:33 [PATCH] xen/mm: Unmap page for direct mapped domain on decrease reservation Julien Grall
@ 2015-10-27 13:08 ` Jan Beulich
2015-10-27 13:54 ` Julien Grall
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-10-27 13:08 UTC (permalink / raw)
To: JulienGrall
Cc: xen-devel, Tim Deegan, KeirFraser, ian.campbell,
stefano.stabellini
>>> On 27.10.15 at 12:33, <julien.grall@citrix.com> wrote:
> Direct mapped domain needs to retrieve the exact same underlying
> physical page when the region is re-populated.
>
> Currently, when the memory reservation for this domain is decreased, the
> request is just ignored and the page stayed mapped in the P2M. However,
> this make more difficult to spot issue when the domain has not yet mapped
> foreign page but trying to access the region.
>
> What we really care for direct mapped domain is to not give back the
> page to the allocator. So we can re-enable to direct mapped when the guest
> memory region is re-populated.
>
> The rest of the process to remove a page can be safely done. This
> also ensures us to stay close to the normal domain memory handling.
>
> At the same time, drop the trailing whitespaces around the code
> modified.
>
> Signed-off-by: Julien Grall <julien.grall@citrix.com>
Looks good, just one minor comment (which could be addressed upon
commit):
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -257,8 +257,16 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
>
> if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
> put_page_and_type(page);
> -
> - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
> +
> + /*
> + * With the lack for iommu on some ARM platform, domain with DMA-capable
I think it's "lack of", and I also wonder whether calling out ARM here
is really meaningful.
> + * device must retrieve the same pfn when the hypercall populate_physmap
> + * is called.
> + *
> + * For this purpose, the page is kept allocated.
..., to match populate_physmap() behavior. (or some such)
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/mm: Unmap page for direct mapped domain on decrease reservation
2015-10-27 13:08 ` Jan Beulich
@ 2015-10-27 13:54 ` Julien Grall
0 siblings, 0 replies; 3+ messages in thread
From: Julien Grall @ 2015-10-27 13:54 UTC (permalink / raw)
To: Jan Beulich
Cc: xen-devel, KeirFraser, Tim Deegan, ian.campbell,
stefano.stabellini
On 27/10/15 13:08, Jan Beulich wrote:
>> --- a/xen/common/memory.c
>> +++ b/xen/common/memory.c
>> @@ -257,8 +257,16 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
>>
>> if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
>> put_page_and_type(page);
>> -
>> - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
>> +
>> + /*
>> + * With the lack for iommu on some ARM platform, domain with DMA-capable
>
> I think it's "lack of", and I also wonder whether calling out ARM here
> is really meaningful.
>
>> + * device must retrieve the same pfn when the hypercall populate_physmap
>> + * is called.
>> + *
>> + * For this purpose, the page is kept allocated.
>
> ..., to match populate_physmap() behavior. (or some such)
I saw that your already committed the patch. FWIW, I'm fine with both
changes.
Regards,
--
Julien Grall
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-27 13:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 11:33 [PATCH] xen/mm: Unmap page for direct mapped domain on decrease reservation Julien Grall
2015-10-27 13:08 ` Jan Beulich
2015-10-27 13:54 ` Julien Grall
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).