Fix Misra C violation in cpu_caps.c and security.c

Fixed below violations:
filename:/hypervisor/arch/x86/cpu_caps.c  function:None  offset:35:
       reason:Variable should be declared static. : cpu_caps
filename:/hypervisor/arch/x86/cpu_caps.c  function:is_vmx_disabled  offset:299:
       reason:Logical conjunctions need brackets.
filename:/hypervisor/arch/x86/cpu_caps.c  function:is_vmx_disabled  offset:300:
       reason:Logical conjunctions need brackets.
filename:/hypervisor/arch/x86/security.c  function:None  offset:18:
       reason:Scope of variable could be reduced. : x86_arch_capabilities
filename:/hypervisor/arch/x86/security.c  function:check_cpu_security_cap  offset:64:
       reason:Logical conjunctions need brackets.
filename:/hypervisor/arch/x86/security.c  function:check_cpu_security_cap  offset:65:
       reason:Logical conjunctions need brackets.

Tracked-On: #861
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ 2018-12-18 14:09:45 +08:00 committed by wenlingz
parent 689c1c28c5
commit 55cce7e4ca
2 changed files with 7 additions and 6 deletions

View File

@ -26,7 +26,7 @@
#define VAPIC_FEATURE_POST_INTR (1U << 4U)
#define VAPIC_FEATURE_VX2APIC_MODE (1U << 5U)
struct cpu_capability {
static struct cpu_capability {
uint8_t apicv_features;
uint8_t ept_features;
@ -314,8 +314,8 @@ static inline bool is_vmx_disabled(void)
msr_val = msr_read(MSR_IA32_FEATURE_CONTROL);
/* Check if feature control is locked and vmx cannot be enabled */
if ((msr_val & MSR_IA32_FEATURE_CONTROL_LOCK) != 0U &&
(msr_val & MSR_IA32_FEATURE_CONTROL_VMX_NO_SMX) == 0U) {
if (((msr_val & MSR_IA32_FEATURE_CONTROL_LOCK) != 0U) &&
((msr_val & MSR_IA32_FEATURE_CONTROL_VMX_NO_SMX) == 0U)) {
return true;
}
return false;

View File

@ -15,7 +15,6 @@
#include <logmsg.h>
static bool skip_l1dfl_vmentry;
static uint64_t x86_arch_capabilities;
int32_t ibrs_type;
static void detect_ibrs(void)
@ -47,6 +46,8 @@ static void detect_ibrs(void)
bool check_cpu_security_cap(void)
{
uint64_t x86_arch_capabilities;
detect_ibrs();
if (cpu_has_cap(X86_FEATURE_ARCH_CAP)) {
@ -61,8 +62,8 @@ bool check_cpu_security_cap(void)
return false;
}
if (!cpu_has_cap(X86_FEATURE_IBRS_IBPB) &&
!cpu_has_cap(X86_FEATURE_STIBP)) {
if ((!cpu_has_cap(X86_FEATURE_IBRS_IBPB)) &&
(!cpu_has_cap(X86_FEATURE_STIBP))) {
return false;
}