Address violations of MISRA C:2012 Rule 7.2
v8 cover Address violations of MISRA C:2012 Rule 7.2
The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
These violations are caused by the missing "u" or "U" suffix in unsigned integer constants, such as:
xen/arch/x86/hvm/hypercall.c:132.17-132.26
if ( (eax & 0x80000000) && is_viridian_domain(currd) )
If a rule is not met, changes are needed in order to achieve compliance. The patches in this series achieve compliance for MISRA C:2012 Rule 7.2 by adding the 'U' suffix to integers literals with unsigned type and also to other
literals used in the same contexts or near violations, when their positive nature is immediately clear. The latter changes are done for the sake of uniformity.
This series only adds an U suffix on a newly introduced macro in "x86/hvm: address violations of MISRA C:2012 Rule 7.2". No changes in the other commits.
Gianluca Luparini (1):
x86/vmx: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin (2):
x86/hvm: address violations of MISRA C:2012 Rule 7.2 xen/x86: address violations of MISRA C:2012 Rule 7.2
xen/arch/x86/apic.c | 2 +- xen/arch/x86/cpu-policy.c | 18 +-- xen/arch/x86/cpu/vpmu_intel.c | 2 +- xen/arch/x86/cpuid.c | 8 +- xen/arch/x86/extable.c | 2 +- xen/arch/x86/hvm/hypercall.c | 2 +- xen/arch/x86/hvm/pmtimer.c | 4 +- xen/arch/x86/hvm/stdvga.c | 32 ++--- xen/arch/x86/hvm/vlapic.c | 6 +- xen/arch/x86/hvm/vmx/vmcs.c | 6 +- xen/arch/x86/hvm/vmx/vvmx.c | 8 +- xen/arch/x86/include/asm/apicdef.h | 2 +- xen/arch/x86/include/asm/config.h | 2 +- xen/arch/x86/include/asm/hpet.h | 2 +- xen/arch/x86/include/asm/hvm/trace.h | 4 +- xen/arch/x86/include/asm/hvm/vioapic.h | 2 +- xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 84 +++++------ xen/arch/x86/include/asm/hvm/vmx/vmx.h | 16 +-- xen/arch/x86/include/asm/msi.h | 2 +- xen/arch/x86/include/asm/msr-index.h | 184 ++++++++++++------------ xen/arch/x86/include/asm/pci.h | 8 +- xen/arch/x86/include/asm/x86-defns.h | 22 +-- xen/arch/x86/percpu.c | 2 +- xen/arch/x86/psr.c | 2 +- xen/arch/x86/spec_ctrl.c | 12 +- 25 files changed, 217 insertions(+), 217 deletions(-)
Signature · 1 line
2.34.1
PATCH v8 1/3 x86/vmx: address violations of MISRA C:2012 Rule 7.2
From: Gianluca Luparini <[email protected]>
The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
Add the 'U' suffix to integers literals with unsigned type.
For the sake of uniformity, the following changes are made:
- add the 'U' suffix to macros near 'CPU_BASED_ACTIVATE_SECONDARY_CONTROLS' and 'SECONDARY_EXEC_NOTIFY_VM_EXITING' macros in 'vmcs.h'
- add the 'U' suffix to macros near 'INTR_INFO_VALID_MASK' macro in 'vmx.h'
---
No changes in v5, v6, v7 and v8.
Changes in v4:
- change commit headline
Changes in v3:
- change 'Signed-off-by' ordering
- change commit message
- remove unnecessary changes in 'vvmx.c'
- add 'uint32_t' casts in 'vvmx.c'
- add missing 'U' in 'vmcs.h' macros
- change macro to '(1u << 31)' in 'vmx.h'
- remove unnecessary changes to 'vmx.h'
Changes in v2:
- minor change to commit title
- change commit message
- remove unnecessary changes in 'vpmu_intel.c' and 'vmx.h'
- add 'ULL' suffix in 'vpmu_intel.c'
- add zero-padding to constants in 'vmx.h'
- add missing 'U' in 'vmx.h'
--- xen/arch/x86/cpu/vpmu_intel.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 6 +- xen/arch/x86/hvm/vmx/vvmx.c | 8 +-- xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 84 ++++++++++++------------- xen/arch/x86/include/asm/hvm/vmx/vmx.h | 16 ++--- 5 files changed, 58 insertions(+), 58 deletions(-)
xen/arch/x86/cpu/vpmu_intel.c +1 -1
@@ -945,7 +945,7 @@ const struct arch_vpmu_ops *__init core2_vpmu_init(void) fixed_counters_mask = ~((1ull <<core2_get_bitwidth_fix_count ()) -1 ); global_ctrl_mask = ~((((1ULL << fixed_pmc_cnt) -1 ) <<32 ) | ((1ULL << arch_pmc_cnt) -1 )); - global_ovf_ctrl_mask = ~(0xC000000000000000 | + global_ovf_ctrl_mask = ~(0xC000000000000000ULL | (((1ULL << fixed_pmc_cnt) -1 ) <<32 ) | ((1ULL << arch_pmc_cnt) -1 ));if ( version >2 )
xen/arch/x86/hvm/vmx/vmcs.c +3 -3
@@ -911,7 +911,7 @@ void vmx_clear_msr_intercept(struct vcpu *v, unsigned int msr,if ( type &VMX_MSR_W )clear_bit (msr, msr_bitmap->write_low); } -else if ( (msr >=0xc0000000 ) && (msr <=0xc0001fff ) ) +else if ( (msr >=0xc0000000U ) && (msr <=0xc0001fffU ) ) { msr &=0x1fff ;if ( type &VMX_MSR_R )
@@ -939,7 +939,7 @@ void vmx_set_msr_intercept(struct vcpu *v, unsigned int msr,if ( type &VMX_MSR_W )set_bit (msr, msr_bitmap->write_low); } -else if ( (msr >=0xc0000000 ) && (msr <=0xc0001fff ) ) +else if ( (msr >=0xc0000000U ) && (msr <=0xc0001fffU ) ) { msr &=0x1fff ;if ( type &VMX_MSR_R )
@@ -957,7 +957,7 @@ bool vmx_msr_is_intercepted(struct vmx_msr_bitmap *msr_bitmap,if ( msr <=0x1fff )return test_bit (msr, is_write ? msr_bitmap->write_low : msr_bitmap->read_low); -else if ( (msr >=0xc0000000 ) && (msr <=0xc0001fff ) ) +else if ( (msr >=0xc0000000U ) && (msr <=0xc0001fffU ) )return test_bit (msr &0x1fff , is_write ? msr_bitmap->write_high : msr_bitmap->read_high);else
xen/arch/x86/hvm/vmx/vvmx.c +4 -4
@@ -263,7 +263,7 @@ uint64_t get_vvmcs_virtual(void *vvmcs, uint32_t vmcs_encoding) res >>=32 ;break ;case VVMCS_WIDTH_32 : - res &=0xffffffff ; + res = (uint32_t )res;break ;case VVMCS_WIDTH_NATURAL :default :
@@ -315,14 +315,14 @@ void set_vvmcs_virtual(void *vvmcs, uint32_t vmcs_encoding, uint64_t val)case VVMCS_WIDTH_64 :if ( enc.access_type ) { - res &=0xffffffff ; + res = (uint32_t )res; res |= val <<32 ; }else res = val;break ;case VVMCS_WIDTH_32 : - res = val &0xffffffff ; + res = (uint32_t )val;break ;case VVMCS_WIDTH_NATURAL :default :
@@ -2306,7 +2306,7 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)break ;case MSR_IA32_VMX_CR0_FIXED1 :/* allow 0-settings for all bits */ - data =0xffffffff ; + data =0xffffffffU ;break ;case MSR_IA32_VMX_CR4_FIXED0 :/* VMXE bit must be 1 in VMX operation */
xen/arch/x86/include/asm/hvm/vmx/vmcs.h +42 -42
102 lines not on this page · raw message
xen/arch/x86/include/asm/hvm/vmx/vmx.h +8 -8
@@ -137,7 +137,7 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc)/* * Exit Reasons */ -#define VMX_EXIT_REASONS_FAILED_VMENTRY 0x80000000 +#define VMX_EXIT_REASONS_FAILED_VMENTRY (1u << 31)#define VMX_EXIT_REASONS_BUS_LOCK (1u << 26)#define EXIT_REASON_EXCEPTION_NMI 0
@@ -209,12 +209,12 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc)* Note INTR_INFO_NMI_UNBLOCKED_BY_IRET is also used with Exit Qualification * field for EPT violations, PML full and SPP-related event vmexits. */ -#define INTR_INFO_VECTOR_MASK 0xff/* 7:0 */ -#define INTR_INFO_INTR_TYPE_MASK 0x700/* 10:8 */ -#define INTR_INFO_DELIVER_CODE_MASK 0x800/* 11 */ -#define INTR_INFO_NMI_UNBLOCKED_BY_IRET 0x1000/* 12 */ -#define INTR_INFO_VALID_MASK 0x80000000/* 31 */ -#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000 +#define INTR_INFO_VECTOR_MASK 0x000000ffU/* 7:0 */ +#define INTR_INFO_INTR_TYPE_MASK 0x00000700U/* 10:8 */ +#define INTR_INFO_DELIVER_CODE_MASK 0x00000800U/* 11 */ +#define INTR_INFO_NMI_UNBLOCKED_BY_IRET 0x00001000U/* 12 */ +#define INTR_INFO_VALID_MASK 0x80000000U/* 31 */ +#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000U/* * Exit Qualifications for NOTIFY VM EXIT
@@ -607,7 +607,7 @@ static inline void vmx_pi_hooks_assign(struct domain *d) {}static inline void vmx_pi_hooks_deassign (struct domain *d) {}#endif -#define APIC_INVALID_DEST 0xffffffff +#define APIC_INVALID_DEST 0xffffffffU/* EPT violation qualifications definitions */ typedef union ept_qual {
Signature · 1 line
2.34.1
PATCH v8 2/3 x86/hvm: address violations of MISRA C:2012 Rule 7.2
In reply to Simone BallarinThe xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
Add the 'U' suffix to integers literals with unsigned type.
For the sake of uniformity, the following change is made:
- add 'U' suffixes to 'mask16' in 'stdvga.c'
---
Changes in v8:
- add U suffixes to macro MSR_AMD64_BP_CFG that has been introduced rebasing the patch
Changes in v7:
- add Reviewed-by: Stefano Stabellini <[email protected]>
- switch order of Signed-off-by tags
Changes in v6:
- new patch obtained by splitting HVM related changes from "xen/x86: address violations of MISRA C:2012 Rule 7.2 (v5)"
- fix inadvertent changes to "sr_mask"
--- xen/arch/x86/hvm/hypercall.c | 2 +- xen/arch/x86/hvm/pmtimer.c | 4 +- xen/arch/x86/hvm/stdvga.c | 32 ++--- xen/arch/x86/hvm/vlapic.c | 6 +- xen/arch/x86/include/asm/apicdef.h | 2 +- xen/arch/x86/include/asm/config.h | 2 +- xen/arch/x86/include/asm/hpet.h | 2 +- xen/arch/x86/include/asm/hvm/trace.h | 4 +- xen/arch/x86/include/asm/hvm/vioapic.h | 2 +- xen/arch/x86/include/asm/msi.h | 2 +- xen/arch/x86/include/asm/msr-index.h | 184 ++++++++++++------------- xen/arch/x86/include/asm/pci.h | 8 +- xen/arch/x86/include/asm/x86-defns.h | 22 +-- 13 files changed, 136 insertions(+), 136 deletions(-)
xen/arch/x86/hvm/hypercall.c +1 -1
@@ -129,7 +129,7 @@ int hvm_hypercall(struct cpu_user_regs *regs)break ; } -if ( (eax &0x80000000 ) &&is_viridian_domain (currd) ) +if ( (eax &0x80000000U ) &&is_viridian_domain (currd) ) {int ret;
xen/arch/x86/hvm/pmtimer.c +2 -2
@@ -40,8 +40,8 @@#define SCI_IRQ 9/* We provide a 32-bit counter (must match the TMR_VAL_EXT bit in the FADT) */ -#define TMR_VAL_MASK (0xffffffff) -#define TMR_VAL_MSB (0x80000000) +#define TMR_VAL_MASK (0xffffffffU) +#define TMR_VAL_MSB (0x80000000U)/* Dispatch SCIs based on the PM1a_STS and PM1a_EN registers */ static void pmt_update_sci (PMTState *s)
xen/arch/x86/hvm/stdvga.c +16 -16
@@ -39,22 +39,22 @@#define PAT (x) (x)static const uint32_t mask16[16 ] = { -PAT (0x00000000 ), -PAT (0x000000ff ), -PAT (0x0000ff00 ), -PAT (0x0000ffff ), -PAT (0x00ff0000 ), -PAT (0x00ff00ff ), -PAT (0x00ffff00 ), -PAT (0x00ffffff ), -PAT (0xff000000 ), -PAT (0xff0000ff ), -PAT (0xff00ff00 ), -PAT (0xff00ffff ), -PAT (0xffff0000 ), -PAT (0xffff00ff ), -PAT (0xffffff00 ), -PAT (0xffffffff ), +PAT (0x00000000U ), +PAT (0x000000ffU ), +PAT (0x0000ff00U ), +PAT (0x0000ffffU ), +PAT (0x00ff0000U ), +PAT (0x00ff00ffU ), +PAT (0x00ffff00U ), +PAT (0x00ffffffU ), +PAT (0xff000000U ), +PAT (0xff0000ffU ), +PAT (0xff00ff00U ), +PAT (0xff00ffffU ), +PAT (0xffff0000U ), +PAT (0xffff00ffU ), +PAT (0xffffff00U ), +PAT (0xffffffffU ), };/* force some bits to zero */
xen/arch/x86/hvm/vlapic.c +3 -3
@@ -237,7 +237,7 @@ bool_t vlapic_match_dest(case APIC_DEST_NOSHORT :if ( dest_mode )return vlapic_match_logical_addr (target, dest); -return (dest ==_VLAPIC_ID (target,0xffffffff )) || +return (dest ==_VLAPIC_ID (target,0xffffffffU )) || (dest ==VLAPIC_ID (target));case APIC_DEST_SELF :
@@ -467,7 +467,7 @@ static bool_t is_multicast_dest(struct vlapic *vlapic, unsigned int short_hand,return short_hand !=APIC_DEST_SELF ;if (vlapic_x2apic_mode (vlapic) ) -return dest_mode ?hweight16 (dest) >1 : dest ==0xffffffff ; +return dest_mode ?hweight16 (dest) >1 : dest ==0xffffffffU ;if ( dest_mode ) return hweight8(dest &
@@ -831,7 +831,7 @@ void vlapic_reg_write(struct vcpu *v, unsigned int reg, uint32_t val)break ;case APIC_ICR2 : -vlapic_set_reg (vlapic,APIC_ICR2 , val &0xff000000 ); +vlapic_set_reg (vlapic,APIC_ICR2 , val &0xff000000U );break ;case APIC_LVTT :/* LVT Timer Reg */
xen/arch/x86/include/asm/apicdef.h +1 -1
@@ -8,7 +8,7 @@* Ingo Molnar <[email protected]>, 1999, 2000 */ -#define APIC_DEFAULT_PHYS_BASE 0xfee00000 +#define APIC_DEFAULT_PHYS_BASE 0xfee00000U#define APIC_ID 0x20#define APIC_ID_MASK (0xFFu<<24)
xen/arch/x86/include/asm/config.h +1 -1
@@ -257,7 +257,7 @@ extern unsigned char boot_edid_info[128];#endif /* CONFIG_PV32 */ #define MACH2PHYS_COMPAT_VIRT_START HYPERVISOR_COMPAT_VIRT_START -#define MACH2PHYS_COMPAT_VIRT_END 0xFFE00000 +#define MACH2PHYS_COMPAT_VIRT_END 0xFFE00000U#define MACH2PHYS_COMPAT_NR_ENTRIES (d) \ ((MACH2PHYS_COMPAT_VIRT_END-MACH2PHYS_COMPAT_VIRT_START(d))>>2)
xen/arch/x86/include/asm/hpet.h +1 -1
@@ -41,7 +41,7 @@#define HPET_TN_ROUTE 0x3e00#define HPET_TN_FSB 0x4000#define HPET_TN_FSB_CAP 0x8000 -#define HPET_TN_RESERVED 0xffff0081 +#define HPET_TN_RESERVED 0xffff0081U#define HPET_TN_INT_ROUTE_CAP (0xffffffffULL << 32)
xen/arch/x86/include/asm/hvm/trace.h +2 -2
@@ -58,7 +58,7 @@#define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC -#define TRC_PAR_LONG (par) ((par)&0xFFFFFFFF),((par)>>32) +#define TRC_PAR_LONG (par) ((uint32_t)(par)), ((par) >> 32)#define TRACE_2_LONG_2D (_e, d1, d2, ...) \ TRACE_4D(_e, d1, d2)
@@ -93,7 +93,7 @@ HVMTRACE_ND(evt, 0, 0)#define HVMTRACE_LONG_1D (evt, d1) \ - HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32) + HVMTRACE_2D(evt ## 64, (uint32_t)(d1), (d1) >> 32)#define HVMTRACE_LONG_2D (evt, d1, d2, ...) \ HVMTRACE_3D(evt ## 64, d1, d2)#define HVMTRACE_LONG_3D (evt, d1, d2, d3, ...) \
xen/arch/x86/include/asm/hvm/vioapic.h +1 -1
@@ -32,7 +32,7 @@#define VIOAPIC_EDGE_TRIG 0#define VIOAPIC_LEVEL_TRIG 1 -#define VIOAPIC_DEFAULT_BASE_ADDRESS 0xfec00000 +#define VIOAPIC_DEFAULT_BASE_ADDRESS 0xfec00000U#define VIOAPIC_MEM_LENGTH 0x100/* Direct registers. */
xen/arch/x86/include/asm/msi.h +1 -1
@@ -37,7 +37,7 @@*/ #define MSI_ADDR_BASE_HI 0 -#define MSI_ADDR_BASE_LO 0xfee00000 +#define MSI_ADDR_BASE_LO 0xfee00000U#define MSI_ADDR_BASE_MASK (~0xfffff)#define MSI_ADDR_HEADER MSI_ADDR_BASE_LO
xen/arch/x86/include/asm/msr-index.h +92 -92
260 lines not on this page · raw message
xen/arch/x86/include/asm/pci.h +4 -4
@@ -3,10 +3,10 @@#include <xen/mm.h> -#define CF8_BDF (cf8) ( ((cf8) & 0x00ffff00) >> 8) -#define CF8_ADDR_LO (cf8) ( (cf8) & 0x000000fc) -#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16) -#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) +#define CF8_BDF (cf8) ( ((cf8) & 0x00ffff00U) >> 8) +#define CF8_ADDR_LO (cf8) ( (cf8) & 0x000000fcU) +#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000U) >> 16) +#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000U))#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \
xen/arch/x86/include/asm/x86-defns.h +11 -11
@@ -30,17 +30,17 @@/* * Intel CPU flags in CR0 */ -#define X86_CR0_PE 0x00000001/* Enable Protected Mode (RW) */ -#define X86_CR0_MP 0x00000002/* Monitor Coprocessor (RW) */ -#define X86_CR0_EM 0x00000004/* Require FPU Emulation (RO) */ -#define X86_CR0_TS 0x00000008/* Task Switched (RW) */ -#define X86_CR0_ET 0x00000010/* Extension type (RO) */ -#define X86_CR0_NE 0x00000020/* Numeric Error Reporting (RW) */ -#define X86_CR0_WP 0x00010000/* Supervisor Write Protect (RW) */ -#define X86_CR0_AM 0x00040000/* Alignment Checking (RW) */ -#define X86_CR0_NW 0x20000000/* Not Write-Through (RW) */ -#define X86_CR0_CD 0x40000000/* Cache Disable (RW) */ -#define X86_CR0_PG 0x80000000/* Paging (RW) */ +#define X86_CR0_PE _AC(0x00000001, UL)/* Enable Protected Mode (RW) */ +#define X86_CR0_MP _AC(0x00000002, UL)/* Monitor Coprocessor (RW) */ +#define X86_CR0_EM _AC(0x00000004, UL)/* Require FPU Emulation (RO) */ +#define X86_CR0_TS _AC(0x00000008, UL)/* Task Switched (RW) */ +#define X86_CR0_ET _AC(0x00000010, UL)/* Extension type (RO) */ +#define X86_CR0_NE _AC(0x00000020, UL)/* Numeric Error Reporting (RW) */ +#define X86_CR0_WP _AC(0x00010000, UL)/* Supervisor Write Protect (RW) */ +#define X86_CR0_AM _AC(0x00040000, UL)/* Alignment Checking (RW) */ +#define X86_CR0_NW _AC(0x20000000, UL)/* Not Write-Through (RW) */ +#define X86_CR0_CD _AC(0x40000000, UL)/* Cache Disable (RW) */ +#define X86_CR0_PG _AC(0x80000000, UL)/* Paging (RW) */ /* * Intel CPU flags in CR3
Signature · 1 line
2.34.1
Re: [XEN PATCH v8 2/3] x86/hvm: address violations of MISRA C:2012 Rule 7.2
Quoted 5 lines · Simone Ballarin
The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
Quoted 8 lines
Add the 'U' suffix to integers literals with unsigned type.
For the sake of uniformity, the following change is made:
- add 'U' suffixes to 'mask16' in 'stdvga.c'Signed-off-by Gianluca Luparini <[email protected]>Signed-off-by Simone Ballarin <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
albeit ...
xen/arch/x86/include/asm/msr-index.h line 25
Quoted 8 lines
xen/arch/x86/include/asm/msr-index.h +1
-1@@ -22,7 +22,7 @@#define APIC_BASE_BSP (_AC(1, ULL) << 8)#define APIC_BASE_EXTD (_AC(1, ULL) << 10)#define APIC_BASE_ENABLE (_AC(1, ULL) << 11) -#define APIC_BASE_ADDR_MASK 0x000ffffffffff000ULL +#define APIC_BASE_ADDR_MASK _AC(0x000ffffffffff000, ULL)
... this looks like an unrelated (but benign) change.
Jan
PATCH v8 3/3 xen/x86: address violations of MISRA C:2012 Rule 7.2
In reply to Simone BallarinThe xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
Add the 'U' suffix to integers literals with unsigned type.
For the sake of uniformity, the following change is made:
- add the 'U' suffix to switch cases in 'cpuid.c'
---
No changes in v8.
Changes in v7:
- change cast to long in a cast to unsigned long in INVALID_PERCPU_AREA to match the type of the first operand
- add missing Signed-off-by tags
Changes in v6:
- new patch obtained by splitting X86 related changes from "xen/x86: address violations of MISRA C:2012 Rule 7.2 (v5)"
--- xen/arch/x86/apic.c | 2 +- xen/arch/x86/cpu-policy.c | 18 +++++++++--------- xen/arch/x86/cpuid.c | 8 ++++---- xen/arch/x86/extable.c | 2 +- xen/arch/x86/percpu.c | 2 +- xen/arch/x86/psr.c | 2 +- xen/arch/x86/spec_ctrl.c | 12 ++++++------ 7 files changed, 23 insertions(+), 23 deletions(-)
xen/arch/x86/apic.c +1 -1
@@ -1191,7 +1191,7 @@ static void __init calibrate_APIC_clock(void)* Setup the APIC counter to maximum. There is no way the lapic * can underflow in the 100ms detection time frame. */ -__setup_APIC_LVTT (0xffffffff ); +__setup_APIC_LVTT (0xffffffffU ); bus_freq =calibrate_apic_timer ();if ( !bus_freq )
xen/arch/x86/cpu-policy.c +9 -9
@@ -321,7 +321,7 @@ static void recalculate_misc(struct cpu_policy *p) p->extd.vendor_edx = p->basic.vendor_edx; p->extd.raw_fms = p->basic.raw_fms; - p->extd.raw[0x1 ].b &=0xff00ffff ; + p->extd.raw[0x1 ].b &=0xff00ffffU ; p->extd.e1d |= p->basic._1d &CPUID_COMMON_1D_FEATURES ; p->extd.raw[0x8 ].a &=0x0000ffff ;/* GuestMaxPhysAddr hidden. */
@@ -378,10 +378,10 @@ static void __init calculate_host_policy(void)* this information. */ if ( cpu_has_lfence_dispatch ) - max_extd_leaf =max (max_extd_leaf,0x80000021 ); + max_extd_leaf =max (max_extd_leaf,0x80000021U ); - p->extd.max_leaf =0x80000000 |min_t (uint32_t, max_extd_leaf &0xffff , -ARRAY_SIZE (p->extd.raw) -1 ); + p->extd.max_leaf =0x80000000U |min_t (uint32_t, max_extd_leaf &0xffff , +ARRAY_SIZE (p->extd.raw) -1 );x86_cpu_featureset_to_policy (boot_cpu_data.x86_capability, p);recalculate_xstate (p);
@@ -793,11 +793,11 @@ void recalculate_cpuid_policy(struct domain *d) p->basic.max_leaf =min (p->basic.max_leaf, max->basic.max_leaf); p->feat.max_subleaf =min (p->feat.max_subleaf, max->feat.max_subleaf); - p->extd.max_leaf =0x80000000 |min (p->extd.max_leaf &0xffff , - ((p->x86_vendor & (X86_VENDOR_AMD | -X86_VENDOR_HYGON )) - ?CPUID_GUEST_NR_EXTD_AMD - :CPUID_GUEST_NR_EXTD_INTEL ) -1 ); + p->extd.max_leaf =0x80000000U |min (p->extd.max_leaf &0xffff , + ((p->x86_vendor & (X86_VENDOR_AMD | +X86_VENDOR_HYGON )) + ?CPUID_GUEST_NR_EXTD_AMD + :CPUID_GUEST_NR_EXTD_INTEL ) -1 );x86_cpu_policy_to_featureset (p, fs);x86_cpu_policy_to_featureset (max, max_fs);
xen/arch/x86/cpuid.c +4 -4
@@ -93,7 +93,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, }break ; - case 0x40000000 ... 0x400000ff: + case 0x40000000U ... 0x400000ffU:if (is_viridian_domain (d) )return cpuid_viridian_leaves (v, leaf, subleaf, res);
@@ -103,10 +103,10 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,* Intel reserve up until 0x4fffffff for hypervisor use. AMD reserve * only until 0x400000ff, but we already use double that. */ - case 0x40000100 ... 0x400001ff: + case 0x40000100U ... 0x400001ffU:return cpuid_hypervisor_leaves (v, leaf, subleaf, res); - case 0x80000000 ... 0x80000000 + CPUID_GUEST_NR_EXTD - 1: + case 0x80000000U ... 0x80000000U + CPUID_GUEST_NR_EXTD - 1:ASSERT ((p->extd.max_leaf &0xffff ) <ARRAY_SIZE (p->extd.raw));if ( (leaf &0xffff ) >min_t (uint32_t, p->extd.max_leaf &0xffff ,ARRAY_SIZE (p->extd.raw) -1 ) )
@@ -352,7 +352,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, }break ; -case 0x80000001 : +case 0x80000001U :/* SYSCALL is hidden outside of long mode on Intel. */ if ( p->x86_vendor ==X86_VENDOR_INTEL &&is_hvm_domain (d) && !hvm_long_mode_active (v) )
xen/arch/x86/extable.c +1 -1
@@ -141,7 +141,7 @@ static int __init cf_check stub_selftest(void) .rax = 0x0123456789abcdef, .res.fields.trapnr = X86_EXC_GP }, { .opc = { endbr64, 0x02, 0x04, 0x04, 0xc3 }, /* add (%rsp,%rax),%al */ - .rax = 0xfedcba9876543210, + .rax = 0xfedcba9876543210UL, .res.fields.trapnr = X86_EXC_SS }, { .opc = { endbr64, 0xcc, 0xc3, 0xc3, 0xc3 }, /* int3 */ .res.fields.trapnr = X86_EXC_BP },
xen/arch/x86/percpu.c +1 -1
@@ -12,7 +12,7 @@ unsigned long __per_cpu_offset[NR_CPUS];* possible #PF at (NULL + a little) which has security implications in the * context of PV guests. */ -#define INVALID_PERCPU_AREA (0x8000000000000000L - (long)__per_cpu_start) +#define INVALID_PERCPU_AREA (0x8000000000000000UL - (unsigned long)__per_cpu_start)#define PERCPU_ORDER get_order_from_bytes(__per_cpu_data_end - __per_cpu_start)void __init percpu_init_areas (void )
xen/arch/x86/psr.c +1 -1
@@ -191,7 +191,7 @@ static struct feat_node *feat_l2_cat;static struct feat_node *feat_mba;/* Common functions */ -#define cat_default_val (len) (0xffffffff >> (32 - (len))) +#define cat_default_val (len) (0xffffffffU >> (32 - (len)))/* * get_cdp_data - get DATA COS register value from input COS ID.
xen/arch/x86/spec_ctrl.c +6 -6
@@ -406,10 +406,10 @@ static void __init print_details(enum ind_thunk thunk)cpuid_count (7 ,0 , &max, &tmp, &tmp, &_7d0);if ( max >=2 )cpuid_count (7 ,2 , &tmp, &tmp, &tmp, &_7d2); -if ( boot_cpu_data.extended_cpuid_level >=0x80000008 ) -cpuid (0x80000008 , &tmp, &e8b, &tmp, &tmp); -if ( boot_cpu_data.extended_cpuid_level >=0x80000021 ) -cpuid (0x80000021 , &e21a, &tmp, &tmp, &tmp); +if ( boot_cpu_data.extended_cpuid_level >=0x80000008U ) +cpuid (0x80000008U , &tmp, &e8b, &tmp, &tmp); +if ( boot_cpu_data.extended_cpuid_level >=0x80000021U ) +cpuid (0x80000021U , &e21a, &tmp, &tmp, &tmp);if ( cpu_has_arch_caps )rdmsrl (MSR_ARCH_CAPABILITIES , caps);
@@ -1612,8 +1612,8 @@ void __init init_speculation_mitigations(void)* TODO: Adjust cpu_has_svm_spec_ctrl to be usable earlier on boot. */ if ( opt_msr_sc_hvm && - (boot_cpu_data.extended_cpuid_level >=0x8000000a ) && - (cpuid_edx (0x8000000a ) & (1u <<SVM_FEATURE_SPEC_CTRL )) ) + (boot_cpu_data.extended_cpuid_level >=0x8000000aU ) && + (cpuid_edx (0x8000000aU ) & (1u <<SVM_FEATURE_SPEC_CTRL )) )setup_force_cpu_cap (X86_FEATURE_SC_MSR_HVM ); }
Signature · 1 line
2.34.1
Re: [XEN PATCH v8 3/3] xen/x86: address violations of MISRA C:2012 Rule 7.2
Quoted 5 lines · Simone Ballarin
The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants that are represented in an unsigned type".
Quoted 7 lines
Add the 'U' suffix to integers literals with unsigned type.
For the sake of uniformity, the following change is made:
- add the 'U' suffix to switch cases in 'cpuid.c'Signed-off-by Gianluca Luparini <[email protected]>Signed-off-by Simone Ballarin <[email protected]>