Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: Don't try to call xen_alloc_p2m_entry() on autotranslating guests

Commit aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")
removed XENFEAT_auto_translated_physmap test in xen_alloc_p2m_entry()
since it is assumed that the routine is never called by non-PV guests.

However, alloc_xenballooned_pages() may make this call on a PVH guest.
Prevent this from happening by adding XENFEAT_auto_translated_physmap
check there.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Fixes: aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")

+5 -3
+5 -3
drivers/xen/balloon.c
··· 664 664 */ 665 665 BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE); 666 666 667 - ret = xen_alloc_p2m_entry(page_to_pfn(page)); 668 - if (ret < 0) 669 - goto out_undo; 667 + if (!xen_feature(XENFEAT_auto_translated_physmap)) { 668 + ret = xen_alloc_p2m_entry(page_to_pfn(page)); 669 + if (ret < 0) 670 + goto out_undo; 671 + } 670 672 #endif 671 673 } else { 672 674 ret = add_ballooned_pages(nr_pages - pgno);