From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: andres@gridcentric.ca, tim@xen.org, olaf@aepfle.de, adin@gridcentric.ca
Subject: [PATCH 2 of 4] x86/mm: Fix more ballooning+paging and ballooning+sharing bugs
Date: Wed, 15 Feb 2012 22:42:26 -0500 [thread overview]
Message-ID: <b03a10be14280ecce5c7.1329363746@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1329363744@xdev.gridcentric.ca>
xen/arch/x86/mm/p2m.c | 7 +++++--
xen/common/memory.c | 17 ++++++++++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
If the guest balloons away a page that has been nominated for paging but not yet
paged out, we fix:
- Send EVICT_FAIL flag in the event to the pager
- Do not leak the underlying page
If the page was shared, we were not:
- properly refreshing the mfn to balloon after the unshare.
- unlocking the p2m on the error exit case
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r a70a87d7bf84 -r b03a10be1428 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -928,11 +928,14 @@ void p2m_mem_paging_drop_page(struct dom
req.gfn = gfn;
req.flags = MEM_EVENT_FLAG_DROP_PAGE;
- mem_event_put_request(d, &d->mem_event->paging, &req);
-
/* Update stats unless the page hasn't yet been evicted */
if ( p2mt != p2m_ram_paging_out )
atomic_dec(&d->paged_pages);
+ else
+ /* Evict will fail now, tag this request for pager */
+ req.flags |= MEM_EVENT_FLAG_EVICT_FAIL;
+
+ mem_event_put_request(d, &d->mem_event->paging, &req);
}
/**
diff -r a70a87d7bf84 -r b03a10be1428 xen/common/memory.c
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -167,6 +167,15 @@ int guest_remove_page(struct domain *d,
{
guest_physmap_remove_page(d, gmfn, mfn, 0);
put_gfn(d, gmfn);
+ /* If the page hasn't yet been paged out, there is an
+ * actual page that needs to be released. */
+ if ( p2mt == p2m_ram_paging_out )
+ {
+ ASSERT(mfn_valid(mfn));
+ page = mfn_to_page(mfn);
+ if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
+ put_page(page);
+ }
p2m_mem_paging_drop_page(d, gmfn, p2mt);
return 1;
}
@@ -181,7 +190,6 @@ int guest_remove_page(struct domain *d,
return 0;
}
- page = mfn_to_page(mfn);
#ifdef CONFIG_X86_64
if ( p2m_is_shared(p2mt) )
{
@@ -190,10 +198,17 @@ int guest_remove_page(struct domain *d,
* need to trigger proper cleanup. Once done, this is
* like any other page. */
if ( mem_sharing_unshare_page(d, gmfn, 0) )
+ {
+ put_gfn(d, gmfn);
return 0;
+ }
+ /* Maybe the mfn changed */
+ mfn = mfn_x(get_gfn_query_unlocked(d, gmfn, &p2mt));
+ ASSERT(!p2m_is_shared(p2mt));
}
#endif /* CONFIG_X86_64 */
+ page = mfn_to_page(mfn);
if ( unlikely(!get_page(page, d)) )
{
put_gfn(d, gmfn);
next prev parent reply other threads:[~2012-02-16 3:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 3:42 [PATCH 0 of 4] x86/mm: Four fixes Andres Lagar-Cavilla
2012-02-16 3:42 ` [PATCH 1 of 4] x86/mm: Make asserts on types and counts of shared pages more accurate Andres Lagar-Cavilla
2012-02-16 3:42 ` Andres Lagar-Cavilla [this message]
2012-02-16 3:42 ` [PATCH 3 of 4] x86/mm: Check sharing/paging/access have been enabled before processing a memop Andres Lagar-Cavilla
2012-02-16 3:42 ` [PATCH 4 of 4] x86/mm: Fix two PAE+paging bugs Andres Lagar-Cavilla
2012-02-16 15:59 ` [PATCH 0 of 4] x86/mm: Four fixes Tim Deegan
2012-02-17 16:14 ` Andres Lagar-Cavilla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b03a10be14280ecce5c7.1329363746@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=adin@gridcentric.ca \
--cc=andres@gridcentric.ca \
--cc=olaf@aepfle.de \
--cc=tim@xen.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.