From: David Vrabel Date: Wed, 22 Jul 2015 13:50:37 +0000 (+0100) Subject: xen/balloon: pre-allocate p2m entries for ballooned pages X-Git-Tag: v4.1.12-92~172^2~5^2~54 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f56e7fc06466dcce162b58e400cf847b21db95fa;p=users%2Fjedix%2Flinux-maple.git xen/balloon: pre-allocate p2m entries for ballooned pages Pages returned by alloc_xenballooned_pages() will be used for grant mapping which will call set_phys_to_machine() (in PV guests). Ballooned pages are set as INVALID_P2M_ENTRY in the p2m and thus may be using the (shared) missing tables and a subsequent set_phys_to_machine() will need to allocate new tables. Since the grant mapping may be done from a context that cannot sleep, the p2m entries must already be allocated. Signed-off-by: David Vrabel Reviewed-by: Daniel Kiper (cherry picked from commit 4a69c909deb0dd3cae653d14ac0ff52d5440a19c) Signed-off-by: Joao Martins --- diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 25fd1bd949d8c..f56662324a471 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -602,6 +602,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) page = balloon_retrieve(true); if (page) { pages[pgno++] = page; +#ifdef CONFIG_XEN_HAVE_PVMMU + ret = xen_alloc_p2m_entry(page_to_pfn(page)); + if (ret < 0) + goto out_undo; +#endif } else { ret = add_ballooned_pages(nr_pages - pgno); if (ret < 0)