xen/arm: xen/arm: Reinforce use of is_hardware_domain
authorLuca Fancellu <luca.fancellu@arm.com>
Wed, 14 Apr 2021 09:14:02 +0000 (10:14 +0100)
committerJulien Grall <jgrall@amazon.com>
Thu, 15 Apr 2021 17:06:21 +0000 (18:06 +0100)
There are a few places on Arm where we use pretty much an open-coded
version of is_hardware_domain(). The main difference, is the helper
will also block speculation (not yet implemented on Arm).

The existing users are not in hot path, so blocking speculation
would not hurt when it is implemented. So remove the open-coded
version within the arm codebase.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
[julieng: Rework the commit message]
Acked-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/irq.c
xen/drivers/passthrough/arm/ipmmu-vmsa.c
xen/drivers/passthrough/arm/smmu-v3.c
xen/drivers/passthrough/arm/smmu.c
xen/include/asm-arm/domain.h

index b71b099e6fa21d3f95cb9f69492bb8cba1ea9781..b761d90c406338b0dbee104056b2f12c0c7497f3 100644 (file)
@@ -412,7 +412,7 @@ bool is_assignable_irq(unsigned int irq)
  */
 bool irq_type_set_by_domain(const struct domain *d)
 {
-    return (d == hardware_domain);
+    return is_hardware_domain(d);
 }
 
 /*
index aef358d880efe6920d64ee527d38cf8a6f26de41..8b8e3a00bad04ef4df7e24f21ece8d0d4f6e70df 100644 (file)
@@ -1168,7 +1168,7 @@ static int ipmmu_reassign_device(struct domain *s, struct domain *t,
     int ret = 0;
 
     /* Don't allow remapping on other domain than hwdom */
-    if ( t && t != hardware_domain )
+    if ( t && !is_hardware_domain(t) )
         return -EPERM;
 
     if ( t == s )
index 53d150cdb6a058522510e9a71e77faa8b5ee2328..d115df732016403f0adccb39e2b4c35a190368c4 100644 (file)
@@ -3366,7 +3366,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t,
        int ret = 0;
 
        /* Don't allow remapping on other domain than hwdom */
-       if (t && t != hardware_domain)
+       if ( t && !is_hardware_domain(t) )
                return -EPERM;
 
        if (t == s)
index fab7be8b48bbbb687702f7ec47213933c9ddf860..24ac4f3a8028090063fb15dc10eeb23cceed4526 100644 (file)
@@ -2771,7 +2771,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t,
        int ret = 0;
 
        /* Don't allow remapping on other domain than hwdom */
-       if (t && t != hardware_domain)
+       if ( t && !is_hardware_domain(t) )
                return -EPERM;
 
        if (t == s)
index 1da90f207d5b1411115bf036917f64555b866929..0a74df993107354ba50ea94592dbba14b9fc5d3d 100644 (file)
@@ -30,7 +30,7 @@ enum domain_type {
 #endif
 
 /* The hardware domain has always its memory direct mapped. */
-#define is_domain_direct_mapped(d) ((d) == hardware_domain)
+#define is_domain_direct_mapped(d) is_hardware_domain(d)
 
 struct vtimer {
     struct vcpu *v;