Message ID | 20250416115900.2491661-3-andrew.cooper3@citrix.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xen: Centralise byteswap infrastructure | expand |
On 2025-04-16 13:58, Andrew Cooper wrote: > cpu_to_le64() is about to become a macro, at which point the #ifdef in > the > middle of it becomes undefined behaviour. > > Use a logcal variable to prepare strtab, where the #ifdef is fine to > use. > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> for MISRA: Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com> > --- > CC: Anthony PERARD <anthony.perard@vates.tech> > CC: Michal Orzel <michal.orzel@amd.com> > CC: Jan Beulich <jbeulich@suse.com> > CC: Julien Grall <julien@xen.org> > CC: Roger Pau Monné <roger.pau@citrix.com> > CC: Stefano Stabellini <sstabellini@kernel.org> > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > CC: Bertrand Marquis <bertrand.marquis@arm.com> > CC: Shawn Anastasio <sanastasio@raptorengineering.com> > CC: Oleksii Kurochko <oleksii.kurochko@gmail.com> > CC: Daniel P. Smith <dpsmith@apertussolutions.com> > CC: Lin Liu <lin.liu@citrix.com> > > v6: > * New > > Eclair log from v5: > > https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/andyhhp/xen/ECLAIR_normal/xen-bswap/ARM64/9556392204/PROJECT.ecd;/by_service/MC3A2.R20.6.html > --- > 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 cee572402203..df162350578c 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);
+ Rahul On Wed, 16 Apr 2025, Andrew Cooper wrote: > cpu_to_le64() is about to become a macro, at which point the #ifdef in the > middle of it becomes undefined behaviour. > > Use a logcal variable to prepare strtab, where the #ifdef is fine to use. > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> > --- > CC: Anthony PERARD <anthony.perard@vates.tech> > CC: Michal Orzel <michal.orzel@amd.com> > CC: Jan Beulich <jbeulich@suse.com> > CC: Julien Grall <julien@xen.org> > CC: Roger Pau Monné <roger.pau@citrix.com> > CC: Stefano Stabellini <sstabellini@kernel.org> > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > CC: Bertrand Marquis <bertrand.marquis@arm.com> > CC: Shawn Anastasio <sanastasio@raptorengineering.com> > CC: Oleksii Kurochko <oleksii.kurochko@gmail.com> > CC: Daniel P. Smith <dpsmith@apertussolutions.com> > CC: Lin Liu <lin.liu@citrix.com> > > v6: > * New > > Eclair log from v5: > https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/andyhhp/xen/ECLAIR_normal/xen-bswap/ARM64/9556392204/PROJECT.ecd;/by_service/MC3A2.R20.6.html > --- > 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 cee572402203..df162350578c 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); > > -- > 2.39.5 >
Hi Andrew, > On 16 Apr 2025, at 13:58, Andrew Cooper <andrew.cooper3@citrix.com> wrote: > > cpu_to_le64() is about to become a macro, at which point the #ifdef in the > middle of it becomes undefined behaviour. > > Use a logcal 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: Bertrand Marquis <bertrand.marquis@arm.com> Cheers Bertrand > --- > CC: Anthony PERARD <anthony.perard@vates.tech> > CC: Michal Orzel <michal.orzel@amd.com> > CC: Jan Beulich <jbeulich@suse.com> > CC: Julien Grall <julien@xen.org> > CC: Roger Pau Monné <roger.pau@citrix.com> > CC: Stefano Stabellini <sstabellini@kernel.org> > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > CC: Bertrand Marquis <bertrand.marquis@arm.com> > CC: Shawn Anastasio <sanastasio@raptorengineering.com> > CC: Oleksii Kurochko <oleksii.kurochko@gmail.com> > CC: Daniel P. Smith <dpsmith@apertussolutions.com> > CC: Lin Liu <lin.liu@citrix.com> > > v6: > * New > > Eclair log from v5: > https://uk01.z.antigena.com/l/DKXzqbWh6FOSes_N-GS4kVrRo3s8zxL~gIwm28-vykineH901_xtXphlRhHlTYIHWWH6_S74ZTXa~OJ1oe8DWS0WAgpOS1BOFHtxX2jR6U-~VP31JDjZ40itG8x3chZ~PBn931irdHNDnKtxILHxK_FvR7wxF63KdTZtHUaOvCWrtK4k_iVXV9-H9nXfDUd_q1i9d6-qOYpJBZ9NvulXvOWkHp6YDvPqHMLDubcurr3Zr60yQ3vrc8GDgfSEgbkM6Cmz9QmGqEm_qyEqM1N2rys622rmVNet6hPpI-Xm6SJRUeepHpylVuK4flX48Jpf0jOqHz4GaTjouy4nRC017h > --- > 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 cee572402203..df162350578c 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); > > -- > 2.39.5 > >
diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c index cee572402203..df162350578c 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);
cpu_to_le64() is about to become a macro, at which point the #ifdef in the middle of it becomes undefined behaviour. Use a logcal variable to prepare strtab, where the #ifdef is fine to use. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Anthony PERARD <anthony.perard@vates.tech> CC: Michal Orzel <michal.orzel@amd.com> CC: Jan Beulich <jbeulich@suse.com> CC: Julien Grall <julien@xen.org> CC: Roger Pau Monné <roger.pau@citrix.com> CC: Stefano Stabellini <sstabellini@kernel.org> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> CC: Bertrand Marquis <bertrand.marquis@arm.com> CC: Shawn Anastasio <sanastasio@raptorengineering.com> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com> CC: Daniel P. Smith <dpsmith@apertussolutions.com> CC: Lin Liu <lin.liu@citrix.com> v6: * New Eclair log from v5: https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/andyhhp/xen/ECLAIR_normal/xen-bswap/ARM64/9556392204/PROJECT.ecd;/by_service/MC3A2.R20.6.html --- xen/drivers/passthrough/arm/smmu-v3.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)