HV:CPU: Add 'U/UL' for unsigned const value

According to MISRA C:2012, suffix 'U/UL' shall be for
unsigned const value, the member of enum variable should
not be used to compare with integer variable.

Add 'U/UL' for unsigned const value in the CPU module;
Use Macro insteading of enum feature_word since the member
of feature_word is used to compare with integer variable;
Use hex number insteading of Macro in the assembly code.

V1-->V2:

        Update the suffix of some constant value as 'UL'
        according to its'storage variable;
        Split MACRO updates used in the assembly code
	in other patch.

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Xiangyang Wu
2018-07-06 13:49:41 +08:00
committed by wenlingz
parent 21f0bddff8
commit 474e9af216
8 changed files with 191 additions and 194 deletions

View File

@@ -67,25 +67,25 @@
#define CR3_PCD (1U<<4) /* page-level cache disable */
/* CR4 register definitions */
#define CR4_VME (1U<<0) /* virtual 8086 mode extensions */
#define CR4_PVI (1U<<1) /* protected mode virtual interrupts */
#define CR4_TSD (1U<<2) /* time stamp disable */
#define CR4_DE (1U<<3) /* debugging extensions */
#define CR4_PSE (1U<<4) /* page size extensions */
#define CR4_PAE (1U<<5) /* physical address extensions */
#define CR4_MCE (1U<<6) /* machine check enable */
#define CR4_PGE (1U<<7) /* page global enable */
#define CR4_PCE (1U<<8)
#define CR4_VME (1UL<<0) /* virtual 8086 mode extensions */
#define CR4_PVI (1UL<<1) /* protected mode virtual interrupts */
#define CR4_TSD (1UL<<2) /* time stamp disable */
#define CR4_DE (1UL<<3) /* debugging extensions */
#define CR4_PSE (1UL<<4) /* page size extensions */
#define CR4_PAE (1UL<<5) /* physical address extensions */
#define CR4_MCE (1UL<<6) /* machine check enable */
#define CR4_PGE (1UL<<7) /* page global enable */
#define CR4_PCE (1UL<<8)
/* performance monitoring counter enable */
#define CR4_OSFXSR (1U<<9) /* OS support for FXSAVE/FXRSTOR */
#define CR4_OSXMMEXCPT (1U<<10)
#define CR4_OSFXSR (1UL<<9) /* OS support for FXSAVE/FXRSTOR */
#define CR4_OSXMMEXCPT (1UL<<10)
/* OS support for unmasked SIMD floating point exceptions */
#define CR4_VMXE (1U<<13) /* VMX enable */
#define CR4_SMXE (1U<<14) /* SMX enable */
#define CR4_PCIDE (1U<<17) /* PCID enable */
#define CR4_OSXSAVE (1U<<18)
#define CR4_SMEP (1U<<20)
#define CR4_SMAP (1U<<21)
#define CR4_VMXE (1UL<<13) /* VMX enable */
#define CR4_SMXE (1UL<<14) /* SMX enable */
#define CR4_PCIDE (1UL<<17) /* PCID enable */
#define CR4_OSXSAVE (1UL<<18)
#define CR4_SMEP (1UL<<20)
#define CR4_SMAP (1UL<<21)
/* XSAVE and Processor Extended States enable bit */
@@ -197,18 +197,15 @@ extern spinlock_t trampoline_spinlock;
((uint64_t)_ld_cpu_data_end - (uint64_t)(_ld_cpu_data_start))
/* CPUID feature words */
enum feature_word {
FEAT_1_ECX = 0, /* CPUID[1].ECX */
FEAT_1_EDX, /* CPUID[1].EDX */
FEAT_7_0_EBX, /* CPUID[EAX=7,ECX=0].EBX */
FEAT_7_0_ECX, /* CPUID[EAX=7,ECX=0].ECX */
FEAT_7_0_EDX, /* CPUID[EAX=7,ECX=0].EDX */
FEAT_8000_0001_ECX, /* CPUID[8000_0001].ECX */
FEAT_8000_0001_EDX, /* CPUID[8000_0001].EDX */
FEAT_8000_0008_EBX, /* CPUID[8000_0008].EAX */
FEATURE_WORDS,
};
#define FEAT_1_ECX 0U /* CPUID[1].ECX */
#define FEAT_1_EDX 1U /* CPUID[1].EDX */
#define FEAT_7_0_EBX 2U /* CPUID[EAX=7,ECX=0].EBX */
#define FEAT_7_0_ECX 3U /* CPUID[EAX=7,ECX=0].ECX */
#define FEAT_7_0_EDX 4U /* CPUID[EAX=7,ECX=0].EDX */
#define FEAT_8000_0001_ECX 5U /* CPUID[8000_0001].ECX */
#define FEAT_8000_0001_EDX 6U /* CPUID[8000_0001].EDX */
#define FEAT_8000_0008_EBX 7U /* CPUID[8000_0008].EAX */
#define FEATURE_WORDS 8U
/**
*The invalid cpu_id (INVALID_CPU_ID) is error
*code for error handling, this means that

View File

@@ -8,79 +8,79 @@
#define __X86_CPUFEATURES_H__
/* Intel-defined CPU features, CPUID level 0x00000001 (ECX)*/
#define X86_FEATURE_SSE3 ((FEAT_1_ECX << 5) + 0)
#define X86_FEATURE_PCLMUL ((FEAT_1_ECX << 5) + 1)
#define X86_FEATURE_DTES64 ((FEAT_1_ECX << 5) + 2)
#define X86_FEATURE_MONITOR ((FEAT_1_ECX << 5) + 3)
#define X86_FEATURE_DS_CPL ((FEAT_1_ECX << 5) + 4)
#define X86_FEATURE_VMX ((FEAT_1_ECX << 5) + 5)
#define X86_FEATURE_SMX ((FEAT_1_ECX << 5) + 6)
#define X86_FEATURE_EST ((FEAT_1_ECX << 5) + 7)
#define X86_FEATURE_TM2 ((FEAT_1_ECX << 5) + 8)
#define X86_FEATURE_SSSE3 ((FEAT_1_ECX << 5) + 9)
#define X86_FEATURE_CID ((FEAT_1_ECX << 5) + 10)
#define X86_FEATURE_FMA ((FEAT_1_ECX << 5) + 12)
#define X86_FEATURE_CX16 ((FEAT_1_ECX << 5) + 13)
#define X86_FEATURE_ETPRD ((FEAT_1_ECX << 5) + 14)
#define X86_FEATURE_PDCM ((FEAT_1_ECX << 5) + 15)
#define X86_FEATURE_PCID ((FEAT_1_ECX << 5) + 17)
#define X86_FEATURE_DCA ((FEAT_1_ECX << 5) + 18)
#define X86_FEATURE_SSE4_1 ((FEAT_1_ECX << 5) + 19)
#define X86_FEATURE_SSE4_2 ((FEAT_1_ECX << 5) + 20)
#define X86_FEATURE_x2APIC ((FEAT_1_ECX << 5) + 21)
#define X86_FEATURE_MOVBE ((FEAT_1_ECX << 5) + 22)
#define X86_FEATURE_POPCNT ((FEAT_1_ECX << 5) + 23)
#define X86_FEATURE_TSC_DEADLINE ((FEAT_1_ECX << 5) + 24)
#define X86_FEATURE_AES ((FEAT_1_ECX << 5) + 25)
#define X86_FEATURE_XSAVE ((FEAT_1_ECX << 5) + 26)
#define X86_FEATURE_OSXSAVE ((FEAT_1_ECX << 5) + 27)
#define X86_FEATURE_AVX ((FEAT_1_ECX << 5) + 28)
#define X86_FEATURE_SSE3 ((FEAT_1_ECX << 5U) + 0U)
#define X86_FEATURE_PCLMUL ((FEAT_1_ECX << 5U) + 1U)
#define X86_FEATURE_DTES64 ((FEAT_1_ECX << 5U) + 2U)
#define X86_FEATURE_MONITOR ((FEAT_1_ECX << 5U) + 3U)
#define X86_FEATURE_DS_CPL ((FEAT_1_ECX << 5U) + 4U)
#define X86_FEATURE_VMX ((FEAT_1_ECX << 5U) + 5U)
#define X86_FEATURE_SMX ((FEAT_1_ECX << 5U) + 6U)
#define X86_FEATURE_EST ((FEAT_1_ECX << 5U) + 7U)
#define X86_FEATURE_TM2 ((FEAT_1_ECX << 5U) + 8U)
#define X86_FEATURE_SSSE3 ((FEAT_1_ECX << 5U) + 9U)
#define X86_FEATURE_CID ((FEAT_1_ECX << 5U) + 10U)
#define X86_FEATURE_FMA ((FEAT_1_ECX << 5U) + 12U)
#define X86_FEATURE_CX16 ((FEAT_1_ECX << 5U) + 13U)
#define X86_FEATURE_ETPRD ((FEAT_1_ECX << 5U) + 14U)
#define X86_FEATURE_PDCM ((FEAT_1_ECX << 5U) + 15U)
#define X86_FEATURE_PCID ((FEAT_1_ECX << 5U) + 17U)
#define X86_FEATURE_DCA ((FEAT_1_ECX << 5U) + 18U)
#define X86_FEATURE_SSE4_1 ((FEAT_1_ECX << 5U) + 19U)
#define X86_FEATURE_SSE4_2 ((FEAT_1_ECX << 5U) + 20U)
#define X86_FEATURE_x2APIC ((FEAT_1_ECX << 5U) + 21U)
#define X86_FEATURE_MOVBE ((FEAT_1_ECX << 5U) + 22U)
#define X86_FEATURE_POPCNT ((FEAT_1_ECX << 5U) + 23U)
#define X86_FEATURE_TSC_DEADLINE ((FEAT_1_ECX << 5U) + 24U)
#define X86_FEATURE_AES ((FEAT_1_ECX << 5U) + 25U)
#define X86_FEATURE_XSAVE ((FEAT_1_ECX << 5U) + 26U)
#define X86_FEATURE_OSXSAVE ((FEAT_1_ECX << 5U) + 27U)
#define X86_FEATURE_AVX ((FEAT_1_ECX << 5U) + 28U)
/* Intel-defined CPU features, CPUID level 0x00000001 (EDX)*/
#define X86_FEATURE_FPU ((FEAT_1_EDX << 5) + 0)
#define X86_FEATURE_VME ((FEAT_1_EDX << 5) + 1)
#define X86_FEATURE_DE ((FEAT_1_EDX << 5) + 2)
#define X86_FEATURE_PSE ((FEAT_1_EDX << 5) + 3)
#define X86_FEATURE_TSC ((FEAT_1_EDX << 5) + 4)
#define X86_FEATURE_MSR ((FEAT_1_EDX << 5) + 5)
#define X86_FEATURE_PAE ((FEAT_1_EDX << 5) + 6)
#define X86_FEATURE_MCE ((FEAT_1_EDX << 5) + 7)
#define X86_FEATURE_CX8 ((FEAT_1_EDX << 5) + 8)
#define X86_FEATURE_APIC ((FEAT_1_EDX << 5) + 9)
#define X86_FEATURE_SEP ((FEAT_1_EDX << 5) + 11)
#define X86_FEATURE_MTRR ((FEAT_1_EDX << 5) + 12)
#define X86_FEATURE_PGE ((FEAT_1_EDX << 5) + 13)
#define X86_FEATURE_MCA ((FEAT_1_EDX << 5) + 14)
#define X86_FEATURE_CMOV ((FEAT_1_EDX << 5) + 15)
#define X86_FEATURE_PAT ((FEAT_1_EDX << 5) + 16)
#define X86_FEATURE_PSE36 ((FEAT_1_EDX << 5) + 17)
#define X86_FEATURE_PSN ((FEAT_1_EDX << 5) + 18)
#define X86_FEATURE_CLF ((FEAT_1_EDX << 5) + 19)
#define X86_FEATURE_DTES ((FEAT_1_EDX << 5) + 21)
#define X86_FEATURE_ACPI ((FEAT_1_EDX << 5) + 22)
#define X86_FEATURE_MMX ((FEAT_1_EDX << 5) + 23)
#define X86_FEATURE_FXSR ((FEAT_1_EDX << 5) + 24)
#define X86_FEATURE_SSE ((FEAT_1_EDX << 5) + 25)
#define X86_FEATURE_SSE2 ((FEAT_1_EDX << 5) + 26)
#define X86_FEATURE_SS ((FEAT_1_EDX << 5) + 27)
#define X86_FEATURE_HTT ((FEAT_1_EDX << 5) + 28)
#define X86_FEATURE_TM1 ((FEAT_1_EDX << 5) + 29)
#define X86_FEATURE_IA64 ((FEAT_1_EDX << 5) + 30)
#define X86_FEATURE_PBE ((FEAT_1_EDX << 5) + 31)
#define X86_FEATURE_FPU ((FEAT_1_EDX << 5U) + 0U)
#define X86_FEATURE_VME ((FEAT_1_EDX << 5U) + 1U)
#define X86_FEATURE_DE ((FEAT_1_EDX << 5U) + 2U)
#define X86_FEATURE_PSE ((FEAT_1_EDX << 5U) + 3U)
#define X86_FEATURE_TSC ((FEAT_1_EDX << 5U) + 4U)
#define X86_FEATURE_MSR ((FEAT_1_EDX << 5U) + 5U)
#define X86_FEATURE_PAE ((FEAT_1_EDX << 5U) + 6U)
#define X86_FEATURE_MCE ((FEAT_1_EDX << 5U) + 7U)
#define X86_FEATURE_CX8 ((FEAT_1_EDX << 5U) + 8U)
#define X86_FEATURE_APIC ((FEAT_1_EDX << 5U) + 9U)
#define X86_FEATURE_SEP ((FEAT_1_EDX << 5U) + 11U)
#define X86_FEATURE_MTRR ((FEAT_1_EDX << 5U) + 12U)
#define X86_FEATURE_PGE ((FEAT_1_EDX << 5U) + 13U)
#define X86_FEATURE_MCA ((FEAT_1_EDX << 5U) + 14U)
#define X86_FEATURE_CMOV ((FEAT_1_EDX << 5U) + 15U)
#define X86_FEATURE_PAT ((FEAT_1_EDX << 5U) + 16U)
#define X86_FEATURE_PSE36 ((FEAT_1_EDX << 5U) + 17U)
#define X86_FEATURE_PSN ((FEAT_1_EDX << 5U) + 18U)
#define X86_FEATURE_CLF ((FEAT_1_EDX << 5U) + 19U)
#define X86_FEATURE_DTES ((FEAT_1_EDX << 5U) + 21U)
#define X86_FEATURE_ACPI ((FEAT_1_EDX << 5U) + 22U)
#define X86_FEATURE_MMX ((FEAT_1_EDX << 5U) + 23U)
#define X86_FEATURE_FXSR ((FEAT_1_EDX << 5U) + 24U)
#define X86_FEATURE_SSE ((FEAT_1_EDX << 5U) + 25U)
#define X86_FEATURE_SSE2 ((FEAT_1_EDX << 5U) + 26U)
#define X86_FEATURE_SS ((FEAT_1_EDX << 5U) + 27U)
#define X86_FEATURE_HTT ((FEAT_1_EDX << 5U) + 28U)
#define X86_FEATURE_TM1 ((FEAT_1_EDX << 5U) + 29U)
#define X86_FEATURE_IA64 ((FEAT_1_EDX << 5U) + 30U)
#define X86_FEATURE_PBE ((FEAT_1_EDX << 5U) + 31U)
/* Intel-defined CPU features, CPUID level 0x00000007 (EBX)*/
#define X86_FEATURE_TSC_ADJ ((FEAT_7_0_EBX << 5) + 1)
#define X86_FEATURE_SMEP ((FEAT_7_0_EBX << 5) + 7)
#define X86_FEATURE_INVPCID ((FEAT_7_0_EBX << 5) + 10)
#define X86_FEATURE_SMAP ((FEAT_7_0_EBX << 5) + 20)
#define X86_FEATURE_TSC_ADJ ((FEAT_7_0_EBX << 5U) + 1U)
#define X86_FEATURE_SMEP ((FEAT_7_0_EBX << 5U) + 7U)
#define X86_FEATURE_INVPCID ((FEAT_7_0_EBX << 5U) + 10U)
#define X86_FEATURE_SMAP ((FEAT_7_0_EBX << 5U) + 20U)
/* Intel-defined CPU features, CPUID level 0x00000007 (EDX)*/
#define X86_FEATURE_IBRS_IBPB ((FEAT_7_0_EDX << 5) + 26)
#define X86_FEATURE_STIBP ((FEAT_7_0_EDX << 5) + 27)
#define X86_FEATURE_IBRS_IBPB ((FEAT_7_0_EDX << 5U) + 26U)
#define X86_FEATURE_STIBP ((FEAT_7_0_EDX << 5U) + 27U)
/* Intel-defined CPU features, CPUID level 0x80000001 (EDX)*/
#define X86_FEATURE_NX ((FEAT_8000_0001_EDX << 5) + 20)
#define X86_FEATURE_PAGE1GB ((FEAT_8000_0001_EDX << 5) + 26)
#define X86_FEATURE_LM ((FEAT_8000_0001_EDX << 5) + 29)
#define X86_FEATURE_NX ((FEAT_8000_0001_EDX << 5U) + 20U)
#define X86_FEATURE_PAGE1GB ((FEAT_8000_0001_EDX << 5U) + 26U)
#define X86_FEATURE_LM ((FEAT_8000_0001_EDX << 5U) + 29U)
#endif /*__X86_CPUFEATURES_H__*/

View File

@@ -89,12 +89,12 @@
#define CPUID_TLB 2
#define CPUID_SERIALNUM 3
#define CPUID_EXTEND_FEATURE 7
#define CPUID_MAX_EXTENDED_FUNCTION 0x80000000
#define CPUID_EXTEND_FUNCTION_1 0x80000001
#define CPUID_EXTEND_FUNCTION_2 0x80000002
#define CPUID_EXTEND_FUNCTION_3 0x80000003
#define CPUID_EXTEND_FUNCTION_4 0x80000004
#define CPUID_EXTEND_ADDRESS_SIZE 0x80000008
#define CPUID_MAX_EXTENDED_FUNCTION 0x80000000U
#define CPUID_EXTEND_FUNCTION_1 0x80000001U
#define CPUID_EXTEND_FUNCTION_2 0x80000002U
#define CPUID_EXTEND_FUNCTION_3 0x80000003U
#define CPUID_EXTEND_FUNCTION_4 0x80000004U
#define CPUID_EXTEND_ADDRESS_SIZE 0x80000008U
static inline void __cpuid(uint32_t *eax, uint32_t *ebx,
@@ -112,7 +112,7 @@ static inline void cpuid(uint32_t leaf,
uint32_t *ecx, uint32_t *edx)
{
*eax = leaf;
*ecx = 0;
*ecx = 0U;
__cpuid(eax, ebx, ecx, edx);
}

View File

@@ -48,29 +48,29 @@
#define CPU_CONTEXT_OFFSET_R15 104U
#define CPU_CONTEXT_OFFSET_RDI 112U
#define CPU_CONTEXT_OFFSET_CR0 120U
#define CPU_CONTEXT_OFFSET_RIP 152
#define CPU_CONTEXT_OFFSET_TSC_OFFSET 184
#define CPU_CONTEXT_OFFSET_IA32_STAR 200
#define CPU_CONTEXT_OFFSET_IA32_LSTAR 208
#define CPU_CONTEXT_OFFSET_IA32_FMASK 216
#define CPU_CONTEXT_OFFSET_IA32_KERNEL_GS_BASE 224
#define CPU_CONTEXT_OFFSET_CS 280
#define CPU_CONTEXT_OFFSET_DS 344
#define CPU_CONTEXT_OFFSET_ES 376
#define CPU_CONTEXT_OFFSET_FS 408
#define CPU_CONTEXT_OFFSET_GS 440
#define CPU_CONTEXT_OFFSET_TR 472
#define CPU_CONTEXT_OFFSET_GDTR 568
#define CPU_CONTEXT_OFFSET_FXSTORE_GUEST_AREA 608
#define CPU_CONTEXT_OFFSET_CR2 128U
#define CPU_CONTEXT_OFFSET_CR3 136U
#define CPU_CONTEXT_OFFSET_CR4 144U
#define CPU_CONTEXT_OFFSET_RIP 152U
#define CPU_CONTEXT_OFFSET_RSP 160U
#define CPU_CONTEXT_OFFSET_RFLAGS 168U
#define CPU_CONTEXT_OFFSET_TSC_OFFSET 184U
#define CPU_CONTEXT_OFFSET_IA32_SPEC_CTRL 192U
#define CPU_CONTEXT_OFFSET_IA32_STAR 200U
#define CPU_CONTEXT_OFFSET_IA32_LSTAR 208U
#define CPU_CONTEXT_OFFSET_IA32_FMASK 216U
#define CPU_CONTEXT_OFFSET_IA32_KERNEL_GS_BASE 224U
#define CPU_CONTEXT_OFFSET_CS 280U
#define CPU_CONTEXT_OFFSET_SS 312U
#define CPU_CONTEXT_OFFSET_DS 344U
#define CPU_CONTEXT_OFFSET_ES 376U
#define CPU_CONTEXT_OFFSET_FS 408U
#define CPU_CONTEXT_OFFSET_GS 440U
#define CPU_CONTEXT_OFFSET_TR 472U
#define CPU_CONTEXT_OFFSET_IDTR 504U
#define CPU_CONTEXT_OFFSET_LDTR 536U
#define CPU_CONTEXT_OFFSET_GDTR 568U
#define CPU_CONTEXT_OFFSET_FXSTORE_GUEST_AREA 608U
/*sizes of various registers within the VCPU data structure */
#define VMX_CPU_S_FXSAVE_GUEST_AREA_SIZE GUEST_STATE_AREA_SIZE