hv: coding style: refine cpu related function to one exit

2) Fix procedure has more than one exit point.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1
2018-12-20 23:29:02 +08:00
committed by wenlingz
parent 9672538c85
commit 738f2536fe
4 changed files with 86 additions and 118 deletions

View File

@@ -51,6 +51,7 @@ int32_t get_ibrs_type(void)
bool check_cpu_security_cap(void)
{
bool ret = true;
uint64_t x86_arch_capabilities;
detect_ibrs();
@@ -59,20 +60,18 @@ bool check_cpu_security_cap(void)
x86_arch_capabilities = msr_read(MSR_IA32_ARCH_CAPABILITIES);
skip_l1dfl_vmentry = ((x86_arch_capabilities
& IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY) != 0UL);
if ((!cpu_has_cap(X86_FEATURE_L1D_FLUSH)) && (!skip_l1dfl_vmentry)) {
ret = false;
} else if ((!cpu_has_cap(X86_FEATURE_IBRS_IBPB)) &&
(!cpu_has_cap(X86_FEATURE_STIBP))) {
ret = false;
}
} else {
return false;
ret = false;
}
if ((!cpu_has_cap(X86_FEATURE_L1D_FLUSH)) && (!skip_l1dfl_vmentry)) {
return false;
}
if ((!cpu_has_cap(X86_FEATURE_IBRS_IBPB)) &&
(!cpu_has_cap(X86_FEATURE_STIBP))) {
return false;
}
return true;
return ret;
}
void cpu_l1d_flush(void)