]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
drivers/smmu-v3: Fix impending MISRA R20.6 violation
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 16 Apr 2025 10:54:04 +0000 (11:54 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 18 Apr 2025 14:16:12 +0000 (15:16 +0100)
cpu_to_le64() is about to become a macro, at which point the #ifdef in the
middle of it becomes undefined behaviour.

Use a local variable to prepare strtab, where the #ifdef is fine to use.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
xen/drivers/passthrough/arm/smmu-v3.c

index cee5724022033b37f71f79488eadfad8fdaa6c92..df162350578ceb230ca7bc4b0d1894f76df66414 100644 (file)
@@ -722,15 +722,17 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid,
        }
 
        if (s2_cfg) {
-               BUG_ON(ste_live);
-               dst[2] = cpu_to_le64(
+               u64 strtab =
                         FIELD_PREP(STRTAB_STE_2_S2VMID, s2_cfg->vmid) |
                         FIELD_PREP(STRTAB_STE_2_VTCR, s2_cfg->vtcr) |
 #ifdef __BIG_ENDIAN
                         STRTAB_STE_2_S2ENDI |
 #endif
                         STRTAB_STE_2_S2PTW | STRTAB_STE_2_S2AA64 |
-                        STRTAB_STE_2_S2R);
+                        STRTAB_STE_2_S2R;
+
+               BUG_ON(ste_live);
+               dst[2] = cpu_to_le64(strtab);
 
                dst[3] = cpu_to_le64(s2_cfg->vttbr & STRTAB_STE_3_S2TTB_MASK);