From: Roger Pau Monné Date: Mon, 18 Feb 2019 12:42:51 +0000 (+0100) Subject: dom0/pvh: align allocation and mapping order to start address X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dc0b0b1f2d5792ecd9e26f2e65b36682f8ec2b27;p=people%2Fiwj%2Fxen.git dom0/pvh: align allocation and mapping order to start address The p2m and iommu mapping code always had the requirement that addresses and orders must be aligned when populating the p2m or the iommu page tables. PVH dom0 builder didn't take this requirement into account, and can call into the p2m/iommu mapping helpers with addresses and orders that are not aligned. Fix this by making sure the orders passed to the physmap population helpers are always aligned to the guest address to be populated. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu Reviewed-by: Jan Beulich Release-acked-by: Juergen Gross --- diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 51cf490811..a571d15c13 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -152,6 +152,8 @@ static int __init pvh_populate_memory_range(struct domain *d, order = get_order_from_pages(end - start + 1); order = min(order ? order - 1 : 0, max_order); + /* The order allocated and populated must be aligned to the address. */ + order = min(order, start ? find_first_set_bit(start) : MAX_ORDER); page = alloc_domheap_pages(d, order, dom0_memflags | MEMF_no_scrub); if ( page == NULL ) {