|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/5] x86/cpu: Use U suffixes on integer constants
MISRA C Rule 7.2 requires a 'U' suffix on integer constants of unsigned
type, and Rule 7.3 forbids the lowercase 'l' in literal suffixes.
Add the 'U' suffix to the CPUID leaves, MSR indices and other constants
above INT_MAX in amd.c, centaur.c, common.c and hygon.c, and uppercase
the existing "ul" and "ull" suffixes. While at it, use MSR_K8_PSTATE0
rather than open-coding its value.
No functional change.
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
xen/arch/x86/cpu/amd.c | 48 +++++++++++++++++++-------------------
xen/arch/x86/cpu/centaur.c | 4 ++--
xen/arch/x86/cpu/common.c | 48 +++++++++++++++++++-------------------
xen/arch/x86/cpu/hygon.c | 8 +++----
4 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 21f82990db..fbbba0005c 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -58,7 +58,7 @@ static inline int rdmsr_amd_safe(unsigned int msr, unsigned
int *lo,
".previous\n"
_ASM_EXTABLE(1b, 3b)
: "=a" (*lo), "=d" (*hi), "=r" (err)
- : "c" (msr), "D" (0x9c5a203a), "2" (0), "i" (-EFAULT) );
+ : "c" (msr), "D" (0x9c5a203aU), "2" (0), "i" (-EFAULT) );
return err;
#endif
@@ -71,7 +71,7 @@ static inline int wrmsr_amd_safe(unsigned int msr, unsigned
int lo,
"1: wrmsr\n\t"
_ASM_EXTABLE(1b, %l[fault])
:
- : "c" (msr), "a" (lo), "d" (hi), "D" (0x9c5a203a)
+ : "c" (msr), "a" (lo), "d" (hi), "D" (0x9c5a203aU)
:
: fault );
@@ -85,7 +85,7 @@ static void wrmsr_amd(unsigned int msr, uint64_t val)
{
asm volatile("wrmsr" ::
"c" (msr), "a" ((uint32_t)val),
- "d" (val >> 32), "D" (0x9c5a203a));
+ "d" (val >> 32), "D" (0x9c5a203aU));
}
/*
@@ -263,7 +263,7 @@ static void __init noinline amd_init_levelling(void)
if (levelling_caps & LCAP_e1cd) {
uint32_t ecx, edx, tmp;
- cpuid(0x80000001, &tmp, &tmp, &ecx, &edx);
+ cpuid(0x80000001U, &tmp, &tmp, &ecx, &edx);
/* Fast-forward bits - Must be set. */
edx |= cpufeat_mask(X86_FEATURE_APIC);
@@ -444,7 +444,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
* distingush the cores.
*/
cpu = smp_processor_id();
- bits = (cpuid_ecx(0x80000008) >> 12) & 0xf;
+ bits = (cpuid_ecx(0x80000008U) >> 12) & 0xf;
if (bits == 0) {
while ((1 << bits) < c->x86_max_cores)
@@ -459,7 +459,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
if (cpu_has(c, X86_FEATURE_TOPOEXT)) {
u32 eax, ebx, ecx, edx;
- cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
+ cpuid(0x8000001eU, &eax, &ebx, &ecx, &edx);
c->x86_num_siblings = ((ebx >> 8) & 0xff) + 1;
if (c->family < 0x17)
@@ -531,13 +531,13 @@ void amd_process_freq(const struct cpuinfo_x86 *c,
* Make an attempt at determining the node ID, but assume
* symmetric setup (using node 0) if this fails.
*/
- if (c->extended_cpuid_level >= 0x8000001e &&
+ if (c->extended_cpuid_level >= 0x8000001eU &&
cpu_has(c, X86_FEATURE_TOPOEXT)) {
- node = cpuid_ecx(0x8000001e) & 0xff;
+ node = cpuid_ecx(0x8000001eU) & 0xff;
if (node > 7)
node = 0;
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
- rdmsrl(0xC001100C, val);
+ rdmsrl(0xC001100CU, val);
node = val & 7;
}
@@ -549,14 +549,14 @@ void amd_process_freq(const struct cpuinfo_x86 *c,
wrmsrl(MSR_AMD64_NB_CFG,
nbcfg | (1ULL << AMD64_NB_CFG_CF8_EXT_ENABLE_BIT));
#define PCI_ECS_ADDRESS(sbdf, reg) \
- (0x80000000 | ((sbdf).bdf << 8) | ((reg) & 0xfc) | (((reg) & 0xf00) << 16))
+ (0x80000000U | ((sbdf).bdf << 8) | ((reg) & 0xfc) | (((reg) & 0xf00) <<
16))
for ( ; ; ) {
pci_sbdf_t sbdf = PCI_SBDF(0, 0, 0x18 | node, 4);
switch (pci_conf_read32(sbdf, PCI_VENDOR_ID)) {
case 0x00000000:
- case 0xffffffff:
+ case 0xffffffffU:
/* No device at this SBDF. */
if (!node)
break;
@@ -594,21 +594,21 @@ void amd_process_freq(const struct cpuinfo_x86 *c,
lo = 0; /* gcc may not recognize the loop having at least 5 iterations
*/
for (h = c->family == 0x10 ? 5 : 8; h--; )
- if (!rdmsr_safe(0xC0010064 + h, &lo) && (lo >> 63))
+ if (!rdmsr_safe(MSR_K8_PSTATE0 + h, &lo) && (lo >> 63))
break;
if (!(lo >> 63))
return;
if (idx && idx < h &&
- !rdmsr_safe(0xC0010064 + idx, &val) && (val >> 63) &&
- !rdmsr_safe(0xC0010064, &hi) && (hi >> 63)) {
+ !rdmsr_safe(MSR_K8_PSTATE0 + idx, &val) && (val >> 63) &&
+ !rdmsr_safe(MSR_K8_PSTATE0, &hi) && (hi >> 63)) {
if (nom_mhz)
*nom_mhz = amd_parse_freq(c->family, val);
if (low_mhz)
*low_mhz = amd_parse_freq(c->family, lo);
if (hi_mhz)
*hi_mhz = amd_parse_freq(c->family, hi);
- } else if (h && !rdmsr_safe(0xC0010064, &hi) && (hi >> 63)) {
+ } else if (h && !rdmsr_safe(MSR_K8_PSTATE0, &hi) && (hi >> 63)) {
if (low_mhz)
*low_mhz = amd_parse_freq(c->family, lo);
if (hi_mhz)
@@ -662,7 +662,7 @@ static bool set_legacy_ssbd(const struct cpuinfo_x86 *c,
bool enable)
}
if (bit >= 0) {
- uint64_t val, mask = 1ull << bit;
+ uint64_t val, mask = 1ULL << bit;
if (rdmsr_safe(MSR_AMD64_LS_CFG, &val) ||
({
@@ -728,8 +728,8 @@ bool __init amd_setup_legacy_ssbd(void)
* c->cpu_core_id is sparse on all but the top end CPUs. Derive
* max_cpus from ApicIdCoreIdSize which will cover any sparseness.
*/
- if (boot_cpu_data.extended_cpuid_level >= 0x80000008) {
- ssbd_max_cores = 1u << MASK_EXTR(cpuid_ecx(0x80000008), 0xf000);
+ if (boot_cpu_data.extended_cpuid_level >= 0x80000008U) {
+ ssbd_max_cores = 1u << MASK_EXTR(cpuid_ecx(0x80000008U),
0xf000);
ssbd_max_cores /= boot_cpu_data.x86_num_siblings;
}
if (!ssbd_max_cores)
@@ -838,7 +838,7 @@ void __init detect_zen2_null_seg_behaviour(void)
static void cf_check fam17_disable_c6(void *arg)
{
/* Disable C6 by clearing the CCR{0,1,2}_CC6EN bits. */
- const uint64_t mask = ~((1ul << 6) | (1ul << 14) | (1ul << 22));
+ const uint64_t mask = ~((1UL << 6) | (1UL << 14) | (1UL << 22));
uint64_t val;
if (!fam17_c6_disabled) {
@@ -1095,8 +1095,8 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
* (AMD Erratum #110, docId: 25759).
*/
__clear_bit(X86_FEATURE_LAHF_LM, c->x86_capability);
- if (!rdmsr_amd_safe(0xc001100d, &l, &h))
- wrmsr_amd_safe(0xc001100d, l, h & ~1);
+ if (!rdmsr_amd_safe(0xc001100dU, &l, &h))
+ wrmsr_amd_safe(0xc001100dU, l, h & ~1);
}
/*
@@ -1180,11 +1180,11 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
display_cacheinfo(c);
- if (c->extended_cpuid_level >= 0x80000008) {
- c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
+ if (c->extended_cpuid_level >= 0x80000008U) {
+ c->x86_max_cores = (cpuid_ecx(0x80000008U) & 0xff) + 1;
}
- if (c->extended_cpuid_level >= 0x80000007) {
+ if (c->extended_cpuid_level >= 0x80000007U) {
if (cpu_has(c, X86_FEATURE_ITSC)) {
__set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
__set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
diff --git a/xen/arch/x86/cpu/centaur.c b/xen/arch/x86/cpu/centaur.c
index 9123b05dc1..1e756d6c36 100644
--- a/xen/arch/x86/cpu/centaur.c
+++ b/xen/arch/x86/cpu/centaur.c
@@ -21,8 +21,8 @@ static void init_c3(struct cpuinfo_x86 *c)
uint64_t msr_content;
/* Test for Centaur Extended Feature Flags presence */
- if (cpuid_eax(0xC0000000) >= 0xC0000001) {
- u32 tmp = cpuid_edx(0xC0000001);
+ if (cpuid_eax(0xC0000000U) >= 0xC0000001U) {
+ u32 tmp = cpuid_edx(0xC0000001U);
/* enable ACE unit, if present and disabled */
if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) {
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 54e3a02dd1..78f26105c5 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -226,13 +226,13 @@ int get_model_name(struct cpuinfo_x86 *c)
unsigned int *v;
char *p, *q;
- if (c->extended_cpuid_level < 0x80000004)
+ if (c->extended_cpuid_level < 0x80000004U)
return 0;
v = (unsigned int *) c->x86_model_id;
- cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
- cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
- cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
+ cpuid(0x80000002U, &v[0], &v[1], &v[2], &v[3]);
+ cpuid(0x80000003U, &v[4], &v[5], &v[6], &v[7]);
+ cpuid(0x80000004U, &v[8], &v[9], &v[10], &v[11]);
c->x86_model_id[48] = 0;
/* Intel chips right-justify this string for some dumb reason;
@@ -255,8 +255,8 @@ void display_cacheinfo(struct cpuinfo_x86 *c)
{
unsigned int dummy, ecx, edx, size;
- if (c->extended_cpuid_level >= 0x80000005) {
- cpuid(0x80000005, &dummy, &dummy, &ecx, &edx);
+ if (c->extended_cpuid_level >= 0x80000005U) {
+ cpuid(0x80000005U, &dummy, &dummy, &ecx, &edx);
if ((edx | ecx) >> 24) {
if (opt_cpu_info)
printk("CPU: L1 I cache %uK (%u bytes/line),"
@@ -266,10 +266,10 @@ void display_cacheinfo(struct cpuinfo_x86 *c)
}
}
- if (c->extended_cpuid_level < 0x80000006) /* Some chips just has
a large L1. */
+ if (c->extended_cpuid_level < 0x80000006U) /* Some chips just has
a large L1. */
return;
- cpuid(0x80000006, &dummy, &dummy, &ecx, &edx);
+ cpuid(0x80000006U, &dummy, &dummy, &ecx, &edx);
size = ecx >> 16;
if (size) {
@@ -413,10 +413,10 @@ void __init early_cpu_init(bool verbose)
&c->x86_capability[FEATURESET_7d1]);
}
- eax = cpuid_eax(0x80000000);
- if ((eax >> 16) == 0x8000 && eax >= 0x80000008) {
- ebx = eax >= 0x8000001f ? cpuid_ebx(0x8000001f) : 0;
- eax = cpuid_eax(0x80000008);
+ eax = cpuid_eax(0x80000000U);
+ if ((eax >> 16) == 0x8000 && eax >= 0x80000008U) {
+ ebx = eax >= 0x8000001fU ? cpuid_ebx(0x8000001fU) : 0;
+ eax = cpuid_eax(0x80000008U);
paddr_bits = eax & 0xff;
if (paddr_bits > PADDR_BITS)
@@ -530,7 +530,7 @@ void identify_cpu(struct cpuinfo_x86 *c)
c->x86_capability[FEATURESET_1c] = ecx;
c->x86_capability[FEATURESET_1d] = edx;
- eax = cpuid_eax(0x80000000);
+ eax = cpuid_eax(0x80000000U);
if ((eax >> 16) == 0x8000)
c->extended_cpuid_level = eax;
@@ -538,8 +538,8 @@ void identify_cpu(struct cpuinfo_x86 *c)
* These AMD-defined flags are out of place, but we need
* them early for the CPUID faulting probe code
*/
- if (c->extended_cpuid_level >= 0x80000021)
- c->x86_capability[FEATURESET_e21a] = cpuid_eax(0x80000021);
+ if (c->extended_cpuid_level >= 0x80000021U)
+ c->x86_capability[FEATURESET_e21a] = cpuid_eax(0x80000021U);
if (actual_cpu.c_early_init)
alternative_vcall(actual_cpu.c_early_init, c);
@@ -554,19 +554,19 @@ void identify_cpu(struct cpuinfo_x86 *c)
c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
/* AMD-defined flags: level 0x80000001 */
- if (c->extended_cpuid_level >= 0x80000001)
- cpuid(0x80000001, &tmp, &tmp,
+ if (c->extended_cpuid_level >= 0x80000001U)
+ cpuid(0x80000001U, &tmp, &tmp,
&c->x86_capability[FEATURESET_e1c],
&c->x86_capability[FEATURESET_e1d]);
- if (c->extended_cpuid_level >= 0x80000004)
+ if (c->extended_cpuid_level >= 0x80000004U)
get_model_name(c); /* Default name */
- if (c->extended_cpuid_level >= 0x80000007)
- c->x86_capability[FEATURESET_e7d] = cpuid_edx(0x80000007);
- if (c->extended_cpuid_level >= 0x80000008)
- c->x86_capability[FEATURESET_e8b] = cpuid_ebx(0x80000008);
- if (c->extended_cpuid_level >= 0x80000021)
- cpuid(0x80000021,
+ if (c->extended_cpuid_level >= 0x80000007U)
+ c->x86_capability[FEATURESET_e7d] = cpuid_edx(0x80000007U);
+ if (c->extended_cpuid_level >= 0x80000008U)
+ c->x86_capability[FEATURESET_e8b] = cpuid_ebx(0x80000008U);
+ if (c->extended_cpuid_level >= 0x80000021U)
+ cpuid(0x80000021U,
&c->x86_capability[FEATURESET_e21a], &tmp,
&c->x86_capability[FEATURESET_e21c], &tmp);
diff --git a/xen/arch/x86/cpu/hygon.c b/xen/arch/x86/cpu/hygon.c
index ef19c2b367..1f88275ce2 100644
--- a/xen/arch/x86/cpu/hygon.c
+++ b/xen/arch/x86/cpu/hygon.c
@@ -17,7 +17,7 @@ static void hygon_get_topology(struct cpuinfo_x86 *c)
/* Socket ID is ApicId[6] for Hygon processors. */
c->phys_proc_id >>= APICID_SOCKET_ID_BIT;
- ebx = cpuid_ebx(0x8000001e);
+ ebx = cpuid_ebx(0x8000001eU);
c->x86_num_siblings = ((ebx >> 8) & 0x3) + 1;
c->x86_max_cores /= c->x86_num_siblings;
c->cpu_core_id = ebx & 0xff;
@@ -66,10 +66,10 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c)
display_cacheinfo(c);
- if (c->extended_cpuid_level >= 0x80000008)
- c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
+ if (c->extended_cpuid_level >= 0x80000008U)
+ c->x86_max_cores = (cpuid_ecx(0x80000008U) & 0xff) + 1;
- if (c->extended_cpuid_level >= 0x80000007) {
+ if (c->extended_cpuid_level >= 0x80000007U) {
if (cpu_has(c, X86_FEATURE_ITSC)) {
__set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
__set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |