From dc0b0b1f2d5792ecd9e26f2e65b36682f8ec2b27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roger=20Pau=20Monn=C3=A9?= Date: Mon, 18 Feb 2019 13:42:51 +0100 Subject: [PATCH] dom0/pvh: align allocation and mapping order to start address MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- xen/arch/x86/hvm/dom0_build.c | 2 ++ 1 file changed, 2 insertions(+) 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 ) { -- 2.39.5