diff mbox

[Xen-devel,v5,13/17] xen/arm: Use the typesafes mfn and gfn in map_dev_mmio_region...

Message ID 1467130643-23868-14-git-send-email-julien.grall@arm.com
State Superseded
Headers show

Commit Message

Julien Grall June 28, 2016, 4:17 p.m. UTC
to avoid mixing machine frame with guest frame. Also drop the prefix start_.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---
    Changes in v4:
        - Patch added
---
 xen/arch/arm/mm.c         |  2 +-
 xen/arch/arm/p2m.c        | 10 +++++-----
 xen/include/asm-arm/p2m.h |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Julien Grall June 29, 2016, 12:20 p.m. UTC | #1
Hi Andrew,

On 28/06/2016 18:21, Andrew Cooper wrote:
> On 28/06/16 17:17, Julien Grall wrote:
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index f11094e..5ffc3df 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -1211,20 +1211,20 @@ int unmap_mmio_regions(struct domain *d,
>>  }
>>
>>  int map_dev_mmio_region(struct domain *d,
>> -                        unsigned long start_gfn,
>> +                        gfn_t gfn,
>>                          unsigned long nr,
>> -                        unsigned long mfn)
>> +                        mfn_t mfn)
>>  {
>>      int res;
>>
>> -    if ( !(nr && iomem_access_permitted(d, mfn, mfn + nr - 1)) )
>> +    if ( !(nr && iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + nr - 1)) )
>>          return 0;
>>
>> -    res = map_mmio_regions(d, _gfn(start_gfn), nr, _mfn(mfn));
>> +    res = map_mmio_regions(d, gfn, nr, mfn);
>>      if ( res < 0 )
>>      {
>>          printk(XENLOG_G_ERR "Unable to map [%#lx - %#lx] in Dom%d\n",
>
> %PRImfn
>
> I would also recommend qualifying what is being mapped, so "to map mfns
> [...".

Good idea, I will modify it in the next version.

Cheers,
diff mbox

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 0e408f8..b5fc034 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1145,7 +1145,7 @@  int xenmem_add_to_physmap_one(
         if ( extra.res0 )
             return -EOPNOTSUPP;
 
-        rc = map_dev_mmio_region(d, gfn_x(gfn), 1, idx);
+        rc = map_dev_mmio_region(d, gfn, 1, _mfn(idx));
         return rc;
 
     default:
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index f11094e..5ffc3df 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1211,20 +1211,20 @@  int unmap_mmio_regions(struct domain *d,
 }
 
 int map_dev_mmio_region(struct domain *d,
-                        unsigned long start_gfn,
+                        gfn_t gfn,
                         unsigned long nr,
-                        unsigned long mfn)
+                        mfn_t mfn)
 {
     int res;
 
-    if ( !(nr && iomem_access_permitted(d, mfn, mfn + nr - 1)) )
+    if ( !(nr && iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + nr - 1)) )
         return 0;
 
-    res = map_mmio_regions(d, _gfn(start_gfn), nr, _mfn(mfn));
+    res = map_mmio_regions(d, gfn, nr, mfn);
     if ( res < 0 )
     {
         printk(XENLOG_G_ERR "Unable to map [%#lx - %#lx] in Dom%d\n",
-               mfn, mfn + nr - 1, d->domain_id);
+               mfn_x(mfn), mfn_x(mfn) + nr - 1, d->domain_id);
         return res;
     }
 
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 4752161..8d29eda 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -152,9 +152,9 @@  int unmap_regions_rw_cache(struct domain *d,
                            unsigned long mfn);
 
 int map_dev_mmio_region(struct domain *d,
-                        unsigned long start_gfn,
+                        gfn_t gfn,
                         unsigned long nr,
-                        unsigned long mfn);
+                        mfn_t mfn);
 
 int guest_physmap_add_entry(struct domain *d,
                             gfn_t gfn,