Skip to contentSkip to conversation

x86/MCE-telem: adjust cookie definition

PATCH In review Jan Beulich 5 participants 6 messages Feb 19, 2025 – Feb 20, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/MCE-telem: adjust cookie definition

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

No functional change intended.

xen/arch/x86/cpu/mcheck/mctelem.c +2 -2
@@ -64,8 +64,8 @@ struct mctelem_ent {
 
 #define MC_NENT (MC_URGENT_NENT + MC_NONURGENT_NENT)
 
-#define	COOKIE2MCTE(c)		((struct mctelem_ent *)(c))
-#define	MCTE2COOKIE(tep)	((mctelem_cookie_t)(tep))
+#define	COOKIE2MCTE(c)		(c)
+#define	MCTE2COOKIE(tep)	(tep)
 
 static struct mc_telem_ctl {
 	/* Linked lists that thread the array members together.
xen/arch/x86/cpu/mcheck/mctelem.h +1 -1
@@ -52,7 +52,7 @@
  * the element from the processing list.
  */
 
-typedef struct mctelem_cookie *mctelem_cookie_t;
+typedef struct mctelem_ent *mctelem_cookie_t;
 
 typedef enum mctelem_class {
     MC_URGENT,
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jan Beulich

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

No functional change intended.

https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9181587757

Eclair does appear to be happy with this approach (assuming I stripped down to only checking R11.2 correctly, and making it fatal).

For the change itself, it's an almost identical binary, differing only in the string section which I expect means some embedded line numbers.

#2 lore raw
Quoted 13 lines · Andrew Cooper
Quoted 11 lines · Jan Beulich

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

No functional change intended.

Quoted 7 lines

https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9181587757

Eclair does appear to be happy with this approach (assuming I stripped down to only checking R11.2 correctly, and making it fatal).

For the change itself, it's an almost identical binary, differing only in the string section which I expect means some embedded line numbers.

Line number changes would be odd, given the patch doesn't add or remove any lines. I expect its internal kind-of-sequence numbers of the compiler, used to e.g. generate local label names.

Quoted 1 line

Thanks.

Jan

#3 lore raw
In reply to Andrew Cooper
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Jan Beulich

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

Quoted 9 lines
Quoted 3 lines

No functional change intended.

https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9181587757

Eclair does appear to be happy with this approach (assuming I stripped down to only checking R11.2 correctly, and making it fatal).

The analysis settings are correct.

Quoted 4 lines

For the change itself, it's an almost identical binary, differing only in the string section which I expect means some embedded line numbers.

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#4 lore raw
In reply to Andrew Cooper
Quoted 15 lines · Andrew Cooper
Quoted 11 lines · Jan Beulich

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

No functional change intended.

https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9181587757

Quoted 7 lines

Eclair does appear to be happy with this approach (assuming I stripped down to only checking R11.2 correctly, and making it fatal).

For the change itself, it's an almost identical binary, differing only in the string section which I expect means some embedded line numbers.

Thank you very much Jan for writing the patch, and thank you Andrew for running the pipeline. It is great that resolves all the 11.2 issues!

Oleksii, may I ask for a release-ack? I'll follow up with a patch to mark 11.2 as clean.

#5 lore raw
Quoted 21 lines · Stefano Stabellini
Quoted 20 lines · Andrew Cooper
Quoted 11 lines · Jan Beulich

struct mctelem_ent is opaque outside of mcetelem.c; the cookie abstraction exists - afaict - just to achieve this opaqueness. Then it is irrelevant though which kind of pointer mctelem_cookie_t resolves to. IOW we can as well use struct mctelem_ent there, allowing to remove the casts from COOKIE2MCTE() and MCTE2COOKIE(). Their removal addresses Misra C:2012 rule 11.2 ("Conversions shall not be performed between a pointer to an incomplete type and any other type") violations.

No functional change intended.

https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9181587757

Eclair does appear to be happy with this approach (assuming I stripped down to only checking R11.2 correctly, and making it fatal).

For the change itself, it's an almost identical binary, differing only in the string section which I expect means some embedded line numbers.

Quoted 6 lines
Quoted 1 line

Thank you very much Jan for writing the patch, and thank you Andrew for running the pipeline. It is great that resolves all the 11.2 issues!

Oleksii, may I ask for a release-ack? I'll follow up with a patch to mark 11.2 as clean.

~ Oleksii