]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
dom0/pvh: align allocation and mapping order to start address
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 18 Feb 2019 12:42:51 +0000 (13:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 18 Feb 2019 12:42:51 +0000 (13:42 +0100)
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é <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/hvm/dom0_build.c

index 51cf490811632a7e0542163393829f77b2476c63..a571d15c1344d29e33308b91af5355b56ae79f4e 100644 (file)
@@ -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 )
         {