]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/arm: fix iomem permissions cfg in map_range_to_domain()
authorGrygorii Strashko <gragst.linux@gmail.com>
Tue, 18 Feb 2025 11:22:52 +0000 (13:22 +0200)
committerJulien Grall <julien@xen.org>
Wed, 12 Mar 2025 19:47:04 +0000 (19:47 +0000)
Now the following code in map_range_to_domain()

    res = iomem_permit_access(d, paddr_to_pfn(addr),
                    paddr_to_pfn(PAGE_ALIGN(addr + len - 1)));

calculates the iomem range end address by rounding it up to the next Xen
page with incorrect assumption that iomem range end address passed to
iomem_permit_access() is exclusive, while it is expected to be inclusive.
It gives Control domain (Dom0) access to manage incorrect MMIO range with
one additional page.

For example, if requested range is [00e6140000:00e6141004] then it expected
to add [e6140:e6141] range (num_pages=2) to the domain iomem_caps rangeset,
but will add [e6140:e6142] (num_pages=3) instead.

To fix it, drop PAGE_ALIGN() from the iomem range end address calculation
formula.

Fixes: 33233c2758345 ("arch/arm: domain build: let dom0 access I/O memory of mapped devices")
Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/device.c

index 5610cddcba8e7a999463a9a9b5eccab92abf1365..97e613e06afacc3ded2d388109bdd92f1422ead8 100644 (file)
@@ -71,7 +71,7 @@ int map_range_to_domain(const struct dt_device_node *dev,
                      strlen("/reserved-memory/")) != 0 )
     {
         res = iomem_permit_access(d, paddr_to_pfn(addr),
-                paddr_to_pfn(PAGE_ALIGN(addr + len - 1)));
+                                  paddr_to_pfn(addr + len - 1));
         if ( res )
         {
             printk(XENLOG_ERR "Unable to permit to dom%d access to"