Skip to contentSkip to conversation

Arm: relax iomem_access_permitted() check

PATCH In review Jan Beulich 2 participants 3 messages Aug 18, 2021 – Aug 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Arm: relax iomem_access_permitted() check

Ranges checked by iomem_access_permitted() are inclusive; to permit a mapping there's no need for access to also have been granted for the subsequent page.

Fixes 80f9c3167084 ("xen/arm: acpi: Map MMIO on fault in stage-2 page table for the hardware domain")
xen/arch/arm/traps.c +1 -1
@@ -1893,7 +1893,7 @@ static bool try_map_mmio(gfn_t gfn)
         return false;
 
     /* The hardware domain can only map permitted MMIO regions */
-    if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + 1) )
+    if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn)) )
         return false;
 
     return !map_regions_p2mt(d, gfn, 1, mfn, p2m_mmio_direct_c);
Reviewed-by on v1 1/1
#1 lore raw

Hi Jan,

Quoted 3 lines · Jan Beulich

Ranges checked by iomem_access_permitted() are inclusive; to permit a mapping there's no need for access to also have been granted for the subsequent page.

Good catch! OOI, how did you find it?

Quoted 3 lines
Fixes 80f9c3167084 ("xen/arm: acpi: Map MMIO on fault in stage-2 page table for the hardware domain")

Cheers,

Quoted 13 lines
xen/arch/arm/traps.c +1 -1
@@ -1893,7 +1893,7 @@ static bool try_map_mmio(gfn_t gfn)
          return false;
 
      /* The hardware domain can only map permitted MMIO regions */
-    if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + 1) )
+    if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn)) )
          return false;
 
      return !map_regions_p2mt(d, gfn, 1, mfn, p2m_mmio_direct_c);
Signature · 1 line
Julien Grall
#2 lore raw
Quoted 6 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Ranges checked by iomem_access_permitted() are inclusive; to permit a mapping there's no need for access to also have been granted for the subsequent page.

Good catch! OOI, how did you find it?

In the course of my large-IOMMU-mappings work I ended up grep-ing for all uses of the function, and this one - while unrelated to that work - caught my eye.

Quoted 4 lines
Quoted 2 lines
Fixes 80f9c3167084 ("xen/arm: acpi: Map MMIO on fault in stage-2 page table for the hardware domain")

Thanks.

Jan