aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorWei Liu <wei.liu2@citrix.com>2014-03-15 12:11:47 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2014-03-25 06:38:30 -0400
commit09ed3d5ba06137913960f9c9385f71fc384193ab (patch)
tree582150ce743efb10051e0bc13747e3e1a24005b9 /drivers/xen
parentb098d6726bbfb94c06d6e1097466187afddae61f (diff)
xen/balloon: flush persistent kmaps in correct position
Xen balloon driver will update ballooned out pages' P2M entries to point to scratch page for PV guests. In 24f69373e2 ("xen/balloon: don't alloc page while non-preemptible", kmap_flush_unused was moved after updating P2M table. In that case for 32 bit PV guest we might end up with P2M X -----> S (S is mfn of balloon scratch page) M2P Y -----> X (Y is mfn in persistent kmap entry) kmap_flush_unused() iterates through all the PTEs in the kmap address space, using pte_to_page() to obtain the page. If the p2m and the m2p are inconsistent the incorrect page is returned. This will clear page->address on the wrong page which may cause subsequent oopses if that page is currently kmap'ed. Move the flush back between get_page and __set_phys_to_machine to fix this. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Cc: stable@vger.kernel.org # 3.12+
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/balloon.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 37d06ea624aa..61a6ac8fa8fc 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -399,11 +399,25 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
399 state = BP_EAGAIN; 399 state = BP_EAGAIN;
400 break; 400 break;
401 } 401 }
402 scrub_page(page);
402 403
403 pfn = page_to_pfn(page); 404 frame_list[i] = page_to_pfn(page);
404 frame_list[i] = pfn_to_mfn(pfn); 405 }
405 406
406 scrub_page(page); 407 /*
408 * Ensure that ballooned highmem pages don't have kmaps.
409 *
410 * Do this before changing the p2m as kmap_flush_unused()
411 * reads PTEs to obtain pages (and hence needs the original
412 * p2m entry).
413 */
414 kmap_flush_unused();
415
416 /* Update direct mapping, invalidate P2M, and add to balloon. */
417 for (i = 0; i < nr_pages; i++) {
418 pfn = frame_list[i];
419 frame_list[i] = pfn_to_mfn(pfn);
420 page = pfn_to_page(pfn);
407 421
408#ifdef CONFIG_XEN_HAVE_PVMMU 422#ifdef CONFIG_XEN_HAVE_PVMMU
409 /* 423 /*
@@ -429,11 +443,9 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
429 } 443 }
430#endif 444#endif
431 445
432 balloon_append(pfn_to_page(pfn)); 446 balloon_append(page);
433 } 447 }
434 448
435 /* Ensure that ballooned highmem pages don't have kmaps. */
436 kmap_flush_unused();
437 flush_tlb_all(); 449 flush_tlb_all();
438 450
439 set_xen_guest_handle(reservation.extent_start, frame_list); 451 set_xen_guest_handle(reservation.extent_start, frame_list);