Skip to contentSkip to conversation

x86: address remaining violation of Rule 7.2

PATCH In review Alessandro Zucchelli 4 participants 9 messages Apr 24, 2024

lore
Share & tools
lore
#0 lore raw

cover x86: address remaining violation of Rule 7.2

This patch series addresses the last violations of MISRA C:2012 Rule 7.2. This rule will soon be tagged as clean for ECLAIR in a future patch.

Alessandro Zucchelli (2):
pci: add suffix 'U' to PCI_CONF_ADDRESS macro. x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

 xen/arch/x86/include/asm/msr-index.h | 2 +-
 xen/arch/x86/x86_64/pci.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 pci: add suffix 'U' to PCI_CONF_ADDRESS macro.

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

---
 xen/arch/x86/x86_64/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/x86_64/pci.c +1 -1
index aad1c3f7cf..8d33429103 100644
@@ -9,7 +9,7 @@
 #include <asm/io.h>
 
 #define PCI_CONF_ADDRESS(sbdf, reg) \
-    (0x80000000 | ((sbdf).bdf << 8) | ((reg) & ~3))
+    (0x80000000U | ((sbdf).bdf << 8) | ((reg) & ~3))
 
 uint8_t pci_conf_read8(pci_sbdf_t sbdf, unsigned int reg)
 {
Signature · 1 line
2.25.1
Acked-by on v1 1/2
#2 lore raw

Re: [XEN PATCH 1/2] pci: add suffix 'U' to PCI_CONF_ADDRESS macro.

Quoted 7 lines · Alessandro Zucchelli

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

xen/arch/x86/x86_64/pci.c line 15

Quoted 11 lines
xen/arch/x86/x86_64/pci.c +1 -1
@@ -9,7 +9,7 @@
 #include <asm/io.h>
 
 #define PCI_CONF_ADDRESS(sbdf, reg) \
-    (0x80000000 | ((sbdf).bdf << 8) | ((reg) & ~3))
+    (0x80000000U | ((sbdf).bdf << 8) | ((reg) & ~3))
 
 uint8_t pci_conf_read8(pci_sbdf_t sbdf, unsigned int reg)
 {

This is x86'es PCI, so the subject prefix may ant to be "x86/pci:".

Jan

#3 lore raw

Re: [XEN PATCH 1/2] pci: add suffix 'U' to PCI_CONF_ADDRESS macro.

Quoted 16 lines · Jan Beulich
Quoted 7 lines · Alessandro Zucchelli

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

Quoted 5 lines
xen/arch/x86/x86_64/pci.c +0 -0
@@ -9,7 +9,7 @@
 #include <asm/io.h>
 
Quoted 8 lines

xen/arch/x86/x86_64/pci.c line 15

Quoted 6 lines
xen/arch/x86/x86_64/pci.c +1 -1
 #define PCI_CONF_ADDRESS(sbdf, reg) \
-    (0x80000000 | ((sbdf).bdf << 8) | ((reg) & ~3))
+    (0x80000000U | ((sbdf).bdf << 8) | ((reg) & ~3))
 
 uint8_t pci_conf_read8(pci_sbdf_t sbdf, unsigned int reg)
 {

This is x86'es PCI, so the subject prefix may ant to be "x86/pci:".

Noted, thanks.

Signature · 3 lines
Alessandro Zucchelli, B.Sc.

Software Engineer, BUGSENG (https://bugseng.com)
#4 lore raw

PATCH 2/2 x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

In reply to Alessandro Zucchelli

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

---
 xen/arch/x86/include/asm/msr-index.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/msr-index.h +1 -1
index 92dd9fa496..9cdb5b2625 100644
@@ -236,7 +236,7 @@
 
 #define MSR_VIRT_SPEC_CTRL                  _AC(0xc001011f, U) /* Layout matches MSR_SPEC_CTRL */
 
-#define MSR_AMD_CSTATE_CFG                  0xc0010296
+#define MSR_AMD_CSTATE_CFG                  0xc0010296U
 
 /*
  * Legacy MSR constants in need of cleanup.  No new MSRs below this comment.
Signature · 1 line
2.25.1
Acked-by on v1 2/2
#5 lore raw

Re: [XEN PATCH 2/2] x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

Quoted 5 lines · Alessandro Zucchelli

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

I'm inclined to suggest

Fixes 652683e1aeaa ("x86/hvm: address violations of MISRA C:2012 Rule 7.2")

as that change clearly should have taken care of this already. The line changed here is even visible in patch context there.

Quoted 1 line
#6 lore raw

Re: [XEN PATCH 2/2] x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

Quoted 5 lines · Jan Beulich
Quoted 4 lines · Alessandro Zucchelli

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

Quoted 10 lines
Quoted 1 line

No functional change.

I'm inclined to suggest

Fixes 652683e1aeaa ("x86/hvm: address violations of MISRA C:2012 Rule 7.2")

as that change clearly should have taken care of this already. The line changed here is even visible in patch context there.

Quoted 1 line

I expect it was a race condition.  MSR_AMD_CSTATE_CFG is a recent addition.

~Andrew

#7 lore raw

Re: [XEN PATCH 2/2] x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

In reply to Alessandro Zucchelli

Le 24/04/2024 à 14:11, Alessandro Zucchelli a écrit :

Quoted 16 lines

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

---
  xen/arch/x86/include/asm/msr-index.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/msr-index.h +0 -0
index 92dd9fa496..9cdb5b2625 100644

xen/arch/x86/include/asm/msr-index.h line 242

Quoted 8 lines
xen/arch/x86/include/asm/msr-index.h +1 -1
@@ -236,7 +236,7 @@
 
  #define MSR_VIRT_SPEC_CTRL                  _AC(0xc001011f, U) /* Layout matches MSR_SPEC_CTRL */
 
-#define MSR_AMD_CSTATE_CFG                  0xc0010296
+#define MSR_AMD_CSTATE_CFG                  0xc0010296U
 
  /*
   * Legacy MSR constants in need of cleanup.  No new MSRs below this comment.

Hello, thanks for the patches

I wonder if the same approach should be also taken for all the other MSR constants of this file that are similar ?

Teddy

Teddy Astie | Vates XCP-ng Intern

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

#8 lore raw

Re: [XEN PATCH 2/2] x86/msr: add suffix 'U' to MSR_AMD_CSTATE_CFG macro.

Quoted 24 lines · Teddy Astie

Le 24/04/2024 à 14:11, Alessandro Zucchelli a écrit :

Quoted 23 lines

This addresses violations of MISRA C:2012 Rule 7.2 which states as
following: A “u” or “U” suffix shall be applied to all integer constants that are represented in an unsigned type.

No functional change.

---
  xen/arch/x86/include/asm/msr-index.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/msr-index.h +0 -0
index 92dd9fa496..9cdb5b2625 100644
@@ -236,7 +236,7 @@
 
  #define MSR_VIRT_SPEC_CTRL                  _AC(0xc001011f, U) /* 

Layout matches MSR_SPEC_CTRL */

xen/arch/x86/include/asm/msr-index.h +1 -1
-#define MSR_AMD_CSTATE_CFG                  0xc0010296
+#define MSR_AMD_CSTATE_CFG                  0xc0010296U
Quoted 9 lines
Quoted 3 lines

/*
* Legacy MSR constants in need of cleanup. No new MSRs below this
comment.

Hello, thanks for the patches

I wonder if the same approach should be also taken for all the other MSR constants of this file that are similar ?

Hello,

from a (strict) point of view of Rule 7.2, the suffix is needed if the numeric constant cannot be represented using an int and it is therefore represented using an unsigned integer.
Every violation in the MSR file has already been addressed.

Signature · 3 lines
Alessandro Zucchelli, B.Sc.

Software Engineer, BUGSENG (https://bugseng.com)