xen/arm: Fix ARM build following c/s 11c397c
PATCH 1/1 xen/arm: Fix ARM build following c/s 11c397c
c/s 11c397c broke the ARM build by introducing a common ACCESS_ONCE() which is different to the definiton in smmu.c
The SMMU code included a scalar typecheck, which is worth keeping in the common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unused variables.
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
--- xen/drivers/passthrough/arm/smmu.c | 10 ---------- xen/include/xen/lib.h | 5 ++++- 2 files changed, 4 insertions(+), 11 deletions(-)
xen/drivers/passthrough/arm/smmu.c +0 -10
@@ -198,16 +198,6 @@ typedef paddr_t phys_addr_t;#define VA_BITS 0/* Only used for configuring stage-1 input size */ -/* The macro ACCESS_ONCE start to be replaced in Linux in favor of -* {READ, WRITE}_ONCE. Rather than introducing in the common code, keep a -* version here. We will have to drop it when the SMMU code in Linux will -* switch to {READ, WRITE}_ONCE. -*/ -#define __ACCESS_ONCE (x) ({ \ - __maybe_unused typeof(x) __var = 0; \ - (volatile typeof(x) *)&(x); }) -#define ACCESS_ONCE (x) (*__ACCESS_ONCE(x)) -#define MODULE_DEVICE_TABLE (type, name)#define module_param_named (name, value, type, perm)#define MODULE_PARM_DESC (_parm, desc)
xen/include/xen/lib.h +4 -1
@@ -56,7 +56,10 @@#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x)) -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) +#define __ACCESS_ONCE (x) ({ \ + (void)(typeof(x))0;/* Scalar typecheck. */ \ + (volatile typeof(x) *)&(x); }) +#define ACCESS_ONCE (x) (*__ACCESS_ONCE(x))#define MASK_EXTR (v, m) (((v) & (m)) / ((m) & -(m)))#define MASK_INSR (v, m) (((v) * ((m) & -(m))) & (m))
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi Andrew,
Quoted 6 lines · Andrew Cooper
c/s 11c397c broke the ARM build by introducing a common
ACCESS_ONCE()which is different to the definiton insmmu.cThe SMMU code included a scalar typecheck, which is worth keeping in the common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unused
s/compliants/complaint/
Quoted 1 line
variables.
OOI, the variable is marked as "__maybe_unused", so why Coverity would complaint?
Quoted 2 lines
Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Quoted 47 lines
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>--- xen/drivers/passthrough/arm/smmu.c | 10 ---------- xen/include/xen/lib.h | 5 ++++- 2 files changed, 4 insertions(+), 11 deletions(-)xen/drivers/passthrough/arm/smmu.c +0
-10@@ -198,16 +198,6 @@ typedef paddr_t phys_addr_t;#define VA_BITS 0/* Only used for configuring stage-1 input size */ -/* The macro ACCESS_ONCE start to be replaced in Linux in favor of -* {READ, WRITE}_ONCE. Rather than introducing in the common code, keep a -* version here. We will have to drop it when the SMMU code in Linux will -* switch to {READ, WRITE}_ONCE. -*/ -#define __ACCESS_ONCE (x) ({ \ - __maybe_unused typeof(x) __var = 0; \ - (volatile typeof(x) *)&(x); }) -#define ACCESS_ONCE (x) (*__ACCESS_ONCE(x)) -#define MODULE_DEVICE_TABLE (type, name)#define module_param_named (name, value, type, perm)#define MODULE_PARM_DESC (_parm, desc)xen/include/xen/lib.h +4
-1@@ -56,7 +56,10 @@#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x)) -#define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) +#define __ACCESS_ONCE (x) ({ \ + (void)(typeof(x))0;/* Scalar typecheck. */ \ + (volatile typeof(x) *)&(x); }) +#define ACCESS_ONCE (x) (*__ACCESS_ONCE(x))#define MASK_EXTR (v, m) (((v) & (m)) / ((m) & -(m)))#define MASK_INSR (v, m) (((v) * ((m) & -(m))) & (m))
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 7 lines · Julien Grall
Hi Andrew,
Quoted 4 lines · Andrew Cooper
c/s 11c397c broke the ARM build by introducing a common
ACCESS_ONCE()which is
different to the definiton insmmu.c
Quoted 5 lines
Quoted 3 lines
The SMMU code included a scalar typecheck, which is worth keeping in the common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unused
s/compliants/complaint/
In this case, it is multiple individual complains about unused individual variables, so "complaints" is scans perfectly well.
An alternative would be "to avoid Coverity complaining about..." if you prefer?
Quoted 5 lines
Quoted 2 lines
variables.
OOI, the variable is marked as "
__maybe_unused", so why Coverity would complaint?
The entire purpose of Coverity is to second guess what the programmer actually wrote when it looks suspicious.
As for this specific example, I believe that the annotation doesn't even survive into the GCC Abstract Syntax Tree, which means Coverity doesn't get to see it. Even if it does, the complaint of "This variable is unused - why do you need it?" is still valid.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Julien Grall
Hi Andrew,
Quoted 3 lines · Andrew Cooper
c/s 11c397c broke the ARM build by introducing a common
ACCESS_ONCE()which is
different to the definiton insmmu.c
Forgot this one s/definiton/definition/
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
The SMMU code included a scalar typecheck, which is worth keeping in the common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unused
Quoted 7 lines
Quoted 1 line
s/compliants/complaint/
In this case, it is multiple individual complains about unused individual variables, so "complaints" is scans perfectly well.
An alternative would be "to avoid Coverity complaining about..." if you prefer?
Sorry I was flagging the typo "i" and "a" inverted and not the plural.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
variables.
OOI, the variable is marked as "
__maybe_unused", so why Coverity would complaint?
Quoted 7 lines
The entire purpose of Coverity is to second guess what the programmer actually wrote when it looks suspicious.
As for this specific example, I believe that the annotation doesn't even survive into the GCC Abstract Syntax Tree, which means Coverity doesn't get to see it. Even if it does, the complaint of "This variable is unused - why do you need it?" is still valid.
Oh, thank you for the explanation.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 21 lines · Julien Grall
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Julien Grall
Hi Andrew,
Quoted 3 lines · Andrew Cooper
c/s 11c397c broke the ARM build by introducing a common
ACCESS_ONCE()which is
different to the definiton insmmu.cForgot this one s/definiton/definition/
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
The SMMU code included a scalar typecheck, which is worth keeping in the
common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unuseds/compliants/complaint/
Quoted 7 lines
Quoted 5 lines
In this case, it is multiple individual complains about unused individual variables, so "complaints" is scans perfectly well.
An alternative would be "to avoid Coverity complaining about..." if you prefer?
Sorry I was flagging the typo "i" and "a" inverted and not the plural.
Ah, sorry. I hadn't even spotted that.
Will fix both.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 25 lines · Andrew Cooper
Quoted 24 lines · Julien Grall
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Julien Grall
Hi Andrew,
Quoted 3 lines · Andrew Cooper
c/s 11c397c broke the ARM build by introducing a common
ACCESS_ONCE()which is
different to the definiton insmmu.cForgot this one s/definiton/definition/
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
The SMMU code included a scalar typecheck, which is worth keeping in the
common case, given ACCESS_ONCE()'s restrictions. However, express the typecheck differently so as to avoid Coverity compliants about unuseds/compliants/complaint/
In this case, it is multiple individual complains about unused individual variables, so "complaints" is scans perfectly well.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
An alternative would be "to avoid Coverity complaining about..." if you prefer?
Sorry I was flagging the typo "i" and "a" inverted and not the plural.
Ah, sorry. I hadn't even spotted that.
Will fix both.
I fixed the commit message and applied.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel