diff mbox series

[v3,1/2] arm/vgic: drop const attribute from gic_iomem_deny_access()

Message ID 20220928141117.51351-2-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series Move calls to memory_type_changed() | expand

Commit Message

Roger Pau Monné Sept. 28, 2022, 2:11 p.m. UTC
While correct from a code point of view, the usage of the const
attribute for the domain parameter of gic_iomem_deny_access() is at
least partially bogus.  Contents of the domain structure (the iomem
rangeset) is modified by the function.  Such modifications succeed
because right now the iomem rangeset is allocated separately from
struct domain, and hence is not subject to the constness of struct
domain.

Amend this by dropping the const attribute from the function
parameter.

This is required by further changes that will convert
iomem_{permit,deny}_access into a function.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/arm/gic-v2.c          | 2 +-
 xen/arch/arm/gic-v3.c          | 2 +-
 xen/arch/arm/gic.c             | 2 +-
 xen/arch/arm/include/asm/gic.h | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

Comments

Bertrand Marquis Sept. 28, 2022, 2:26 p.m. UTC | #1
Hi Roger,

> On 28 Sep 2022, at 16:11, Roger Pau Monne <roger.pau@citrix.com> wrote:
> 
> While correct from a code point of view, the usage of the const
> attribute for the domain parameter of gic_iomem_deny_access() is at
> least partially bogus.  Contents of the domain structure (the iomem
> rangeset) is modified by the function.  Such modifications succeed
> because right now the iomem rangeset is allocated separately from
> struct domain, and hence is not subject to the constness of struct
> domain.
> 
> Amend this by dropping the const attribute from the function
> parameter.
> 
> This is required by further changes that will convert
> iomem_{permit,deny}_access into a function.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> xen/arch/arm/gic-v2.c          | 2 +-
> xen/arch/arm/gic-v3.c          | 2 +-
> xen/arch/arm/gic.c             | 2 +-
> xen/arch/arm/include/asm/gic.h | 4 ++--
> 4 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index bd773bcc67..ae5bd8e95f 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -1083,7 +1083,7 @@ static void __init gicv2_dt_init(void)
>     gicv2_extension_dt_init(node);
> }
> 
> -static int gicv2_iomem_deny_access(const struct domain *d)
> +static int gicv2_iomem_deny_access(struct domain *d)
> {
>     int rc;
>     unsigned long mfn, nr;
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 64b36cec25..018fa0dfa0 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1424,7 +1424,7 @@ static void __init gicv3_dt_init(void)
>                               &vbase, &vsize);
> }
> 
> -static int gicv3_iomem_deny_access(const struct domain *d)
> +static int gicv3_iomem_deny_access(struct domain *d)
> {
>     int rc, i;
>     unsigned long mfn, nr;
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 3b0331b538..9b82325442 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -462,7 +462,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d)
> }
> #endif
> 
> -int gic_iomem_deny_access(const struct domain *d)
> +int gic_iomem_deny_access(struct domain *d)
> {
>     return gic_hw_ops->iomem_deny_access(d);
> }
> diff --git a/xen/arch/arm/include/asm/gic.h b/xen/arch/arm/include/asm/gic.h
> index 3692fae393..76e3fa5dc4 100644
> --- a/xen/arch/arm/include/asm/gic.h
> +++ b/xen/arch/arm/include/asm/gic.h
> @@ -392,7 +392,7 @@ struct gic_hw_operations {
>     /* Map extra GIC MMIO, irqs and other hw stuffs to the hardware domain. */
>     int (*map_hwdom_extra_mappings)(struct domain *d);
>     /* Deny access to GIC regions */
> -    int (*iomem_deny_access)(const struct domain *d);
> +    int (*iomem_deny_access)(struct domain *d);
>     /* Handle LPIs, which require special handling */
>     void (*do_LPI)(unsigned int lpi);
> };
> @@ -449,7 +449,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d);
> #endif
> 
> int gic_map_hwdom_extra_mappings(struct domain *d);
> -int gic_iomem_deny_access(const struct domain *d);
> +int gic_iomem_deny_access(struct domain *d);
> 
> #endif /* __ASSEMBLY__ */
> #endif
> -- 
> 2.37.3
>
diff mbox series

Patch

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index bd773bcc67..ae5bd8e95f 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -1083,7 +1083,7 @@  static void __init gicv2_dt_init(void)
     gicv2_extension_dt_init(node);
 }
 
-static int gicv2_iomem_deny_access(const struct domain *d)
+static int gicv2_iomem_deny_access(struct domain *d)
 {
     int rc;
     unsigned long mfn, nr;
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 64b36cec25..018fa0dfa0 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1424,7 +1424,7 @@  static void __init gicv3_dt_init(void)
                               &vbase, &vsize);
 }
 
-static int gicv3_iomem_deny_access(const struct domain *d)
+static int gicv3_iomem_deny_access(struct domain *d)
 {
     int rc, i;
     unsigned long mfn, nr;
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 3b0331b538..9b82325442 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -462,7 +462,7 @@  unsigned long gic_get_hwdom_madt_size(const struct domain *d)
 }
 #endif
 
-int gic_iomem_deny_access(const struct domain *d)
+int gic_iomem_deny_access(struct domain *d)
 {
     return gic_hw_ops->iomem_deny_access(d);
 }
diff --git a/xen/arch/arm/include/asm/gic.h b/xen/arch/arm/include/asm/gic.h
index 3692fae393..76e3fa5dc4 100644
--- a/xen/arch/arm/include/asm/gic.h
+++ b/xen/arch/arm/include/asm/gic.h
@@ -392,7 +392,7 @@  struct gic_hw_operations {
     /* Map extra GIC MMIO, irqs and other hw stuffs to the hardware domain. */
     int (*map_hwdom_extra_mappings)(struct domain *d);
     /* Deny access to GIC regions */
-    int (*iomem_deny_access)(const struct domain *d);
+    int (*iomem_deny_access)(struct domain *d);
     /* Handle LPIs, which require special handling */
     void (*do_LPI)(unsigned int lpi);
 };
@@ -449,7 +449,7 @@  unsigned long gic_get_hwdom_madt_size(const struct domain *d);
 #endif
 
 int gic_map_hwdom_extra_mappings(struct domain *d);
-int gic_iomem_deny_access(const struct domain *d);
+int gic_iomem_deny_access(struct domain *d);
 
 #endif /* __ASSEMBLY__ */
 #endif