diff mbox

[Xen-devel] xen/arm: Don't mix GFN and MFN when using iomem_deny_access

Message ID 1484668373-26722-1-git-send-email-julien.grall@arm.com
State New
Headers show

Commit Message

Julien Grall Jan. 17, 2017, 3:52 p.m. UTC
iomem_deny_access is working on MFN and not GFN. Make it clear by
renaming the local variables.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c |  6 +++---
 xen/arch/arm/gic-v2.c       | 18 +++++++++---------
 xen/arch/arm/gic-v3.c       | 18 +++++++++---------
 3 files changed, 21 insertions(+), 21 deletions(-)

Comments

Stefano Stabellini Jan. 17, 2017, 11:51 p.m. UTC | #1
On Tue, 17 Jan 2017, Julien Grall wrote:
> iomem_deny_access is working on MFN and not GFN. Make it clear by
> renaming the local variables.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


>  xen/arch/arm/domain_build.c |  6 +++---
>  xen/arch/arm/gic-v2.c       | 18 +++++++++---------
>  xen/arch/arm/gic-v3.c       | 18 +++++++++---------
>  3 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 07b868d..63301e6 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1373,7 +1373,7 @@ static int acpi_iomem_deny_access(struct domain *d)
>  {
>      acpi_status status;
>      struct acpi_table_spcr *spcr = NULL;
> -    unsigned long gfn;
> +    unsigned long mfn;
>      int rc;
>  
>      /* Firstly permit full MMIO capabilities. */
> @@ -1391,9 +1391,9 @@ static int acpi_iomem_deny_access(struct domain *d)
>          return -EINVAL;
>      }
>  
> -    gfn = spcr->serial_port.address >> PAGE_SHIFT;
> +    mfn = spcr->serial_port.address >> PAGE_SHIFT;
>      /* Deny MMIO access for UART */
> -    rc = iomem_deny_access(d, gfn, gfn + 1);
> +    rc = iomem_deny_access(d, mfn, mfn + 1);
>      if ( rc )
>          return rc;
>  
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 9245e7d..cd8e504 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -991,26 +991,26 @@ static void __init gicv2_dt_init(void)
>  static int gicv2_iomem_deny_access(const struct domain *d)
>  {
>      int rc;
> -    unsigned long gfn, nr;
> +    unsigned long mfn, nr;
>  
> -    gfn = dbase >> PAGE_SHIFT;
> -    rc = iomem_deny_access(d, gfn, gfn + 1);
> +    mfn = dbase >> PAGE_SHIFT;
> +    rc = iomem_deny_access(d, mfn, mfn + 1);
>      if ( rc )
>          return rc;
>  
> -    gfn = hbase >> PAGE_SHIFT;
> -    rc = iomem_deny_access(d, gfn, gfn + 1);
> +    mfn = hbase >> PAGE_SHIFT;
> +    rc = iomem_deny_access(d, mfn, mfn + 1);
>      if ( rc )
>          return rc;
>  
> -    gfn = cbase >> PAGE_SHIFT;
> +    mfn = cbase >> PAGE_SHIFT;
>      nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> -    rc = iomem_deny_access(d, gfn, gfn + nr);
> +    rc = iomem_deny_access(d, mfn, mfn + nr);
>      if ( rc )
>          return rc;
>  
> -    gfn = vbase >> PAGE_SHIFT;
> -    return iomem_deny_access(d, gfn, gfn + nr);
> +    mfn = vbase >> PAGE_SHIFT;
> +    return iomem_deny_access(d, mfn, mfn + nr);
>  }
>  
>  #ifdef CONFIG_ACPI
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 12775f5..955591b 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1238,37 +1238,37 @@ static void __init gicv3_dt_init(void)
>  static int gicv3_iomem_deny_access(const struct domain *d)
>  {
>      int rc, i;
> -    unsigned long gfn, nr;
> +    unsigned long mfn, nr;
>  
> -    gfn = dbase >> PAGE_SHIFT;
> +    mfn = dbase >> PAGE_SHIFT;
>      nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE);
> -    rc = iomem_deny_access(d, gfn, gfn + nr);
> +    rc = iomem_deny_access(d, mfn, mfn + nr);
>      if ( rc )
>          return rc;
>  
>      for ( i = 0; i < gicv3.rdist_count; i++ )
>      {
> -        gfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
> +        mfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
>          nr = DIV_ROUND_UP(gicv3.rdist_regions[i].size, PAGE_SIZE);
> -        rc = iomem_deny_access(d, gfn, gfn + nr);
> +        rc = iomem_deny_access(d, mfn, mfn + nr);
>          if ( rc )
>              return rc;
>      }
>  
>      if ( cbase != INVALID_PADDR )
>      {
> -        gfn = cbase >> PAGE_SHIFT;
> +        mfn = cbase >> PAGE_SHIFT;
>          nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> -        rc = iomem_deny_access(d, gfn, gfn + nr);
> +        rc = iomem_deny_access(d, mfn, mfn + nr);
>          if ( rc )
>              return rc;
>      }
>  
>      if ( vbase != INVALID_PADDR )
>      {
> -        gfn = vbase >> PAGE_SHIFT;
> +        mfn = vbase >> PAGE_SHIFT;
>          nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> -        return iomem_deny_access(d, gfn, gfn + nr);
> +        return iomem_deny_access(d, mfn, mfn + nr);
>      }
>  
>      return 0;
> -- 
> 1.9.1
>
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 07b868d..63301e6 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1373,7 +1373,7 @@  static int acpi_iomem_deny_access(struct domain *d)
 {
     acpi_status status;
     struct acpi_table_spcr *spcr = NULL;
-    unsigned long gfn;
+    unsigned long mfn;
     int rc;
 
     /* Firstly permit full MMIO capabilities. */
@@ -1391,9 +1391,9 @@  static int acpi_iomem_deny_access(struct domain *d)
         return -EINVAL;
     }
 
-    gfn = spcr->serial_port.address >> PAGE_SHIFT;
+    mfn = spcr->serial_port.address >> PAGE_SHIFT;
     /* Deny MMIO access for UART */
-    rc = iomem_deny_access(d, gfn, gfn + 1);
+    rc = iomem_deny_access(d, mfn, mfn + 1);
     if ( rc )
         return rc;
 
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 9245e7d..cd8e504 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -991,26 +991,26 @@  static void __init gicv2_dt_init(void)
 static int gicv2_iomem_deny_access(const struct domain *d)
 {
     int rc;
-    unsigned long gfn, nr;
+    unsigned long mfn, nr;
 
-    gfn = dbase >> PAGE_SHIFT;
-    rc = iomem_deny_access(d, gfn, gfn + 1);
+    mfn = dbase >> PAGE_SHIFT;
+    rc = iomem_deny_access(d, mfn, mfn + 1);
     if ( rc )
         return rc;
 
-    gfn = hbase >> PAGE_SHIFT;
-    rc = iomem_deny_access(d, gfn, gfn + 1);
+    mfn = hbase >> PAGE_SHIFT;
+    rc = iomem_deny_access(d, mfn, mfn + 1);
     if ( rc )
         return rc;
 
-    gfn = cbase >> PAGE_SHIFT;
+    mfn = cbase >> PAGE_SHIFT;
     nr = DIV_ROUND_UP(csize, PAGE_SIZE);
-    rc = iomem_deny_access(d, gfn, gfn + nr);
+    rc = iomem_deny_access(d, mfn, mfn + nr);
     if ( rc )
         return rc;
 
-    gfn = vbase >> PAGE_SHIFT;
-    return iomem_deny_access(d, gfn, gfn + nr);
+    mfn = vbase >> PAGE_SHIFT;
+    return iomem_deny_access(d, mfn, mfn + nr);
 }
 
 #ifdef CONFIG_ACPI
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 12775f5..955591b 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1238,37 +1238,37 @@  static void __init gicv3_dt_init(void)
 static int gicv3_iomem_deny_access(const struct domain *d)
 {
     int rc, i;
-    unsigned long gfn, nr;
+    unsigned long mfn, nr;
 
-    gfn = dbase >> PAGE_SHIFT;
+    mfn = dbase >> PAGE_SHIFT;
     nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE);
-    rc = iomem_deny_access(d, gfn, gfn + nr);
+    rc = iomem_deny_access(d, mfn, mfn + nr);
     if ( rc )
         return rc;
 
     for ( i = 0; i < gicv3.rdist_count; i++ )
     {
-        gfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
+        mfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
         nr = DIV_ROUND_UP(gicv3.rdist_regions[i].size, PAGE_SIZE);
-        rc = iomem_deny_access(d, gfn, gfn + nr);
+        rc = iomem_deny_access(d, mfn, mfn + nr);
         if ( rc )
             return rc;
     }
 
     if ( cbase != INVALID_PADDR )
     {
-        gfn = cbase >> PAGE_SHIFT;
+        mfn = cbase >> PAGE_SHIFT;
         nr = DIV_ROUND_UP(csize, PAGE_SIZE);
-        rc = iomem_deny_access(d, gfn, gfn + nr);
+        rc = iomem_deny_access(d, mfn, mfn + nr);
         if ( rc )
             return rc;
     }
 
     if ( vbase != INVALID_PADDR )
     {
-        gfn = vbase >> PAGE_SHIFT;
+        mfn = vbase >> PAGE_SHIFT;
         nr = DIV_ROUND_UP(csize, PAGE_SIZE);
-        return iomem_deny_access(d, gfn, gfn + nr);
+        return iomem_deny_access(d, mfn, mfn + nr);
     }
 
     return 0;