[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] drivers/smmu-v3: Fix impending MISRA R20.6 violation



commit 7b55401529f9c4f5bfbc3232df941a9b6dc324d5
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed Apr 16 11:54:04 2025 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Apr 18 15:16:12 2025 +0100

    drivers/smmu-v3: Fix impending MISRA R20.6 violation
    
    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@xxxxxxxxxx>
    Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
 xen/drivers/passthrough/arm/smmu-v3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu-v3.c 
b/xen/drivers/passthrough/arm/smmu-v3.c
index cee5724022..df16235057 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -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);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.