hv: add hardware_detect_support to detect which hardware we support

Now just add some basic feature/capability detect (not all). Vapic
didn't add here for if we must support vapic then the code which
for vapic not supported must remove, like mmio apic r/w.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1
2018-04-17 11:40:01 +08:00
committed by Jack Ren
parent 10c3a98577
commit 1b1f723c7b
6 changed files with 114 additions and 38 deletions

View File

@@ -94,7 +94,7 @@ static inline bool cpu_has_vmx_vpid_cap(uint32_t bit_mask)
return !!(vmx_caps.vpid & bit_mask);
}
static void check_mmu_capability(void)
int check_vmx_mmu_cap(void)
{
uint64_t val;
@@ -103,8 +103,17 @@ static void check_mmu_capability(void)
vmx_caps.ept = (uint32_t) val;
vmx_caps.vpid = (uint32_t) (val >> 32);
if (!cpu_has_vmx_ept_cap(VMX_EPT_INVEPT))
panic("invept must be supported");
if (!cpu_has_vmx_ept_cap(VMX_EPT_INVEPT)) {
pr_fatal("%s, invept not supported\n", __func__);
return -ENODEV;
}
if (!cpu_has_vmx_vpid_cap(VMX_VPID_INVVPID)) {
pr_fatal("%s, invvpid not supported\n", __func__);
return -ENODEV;
}
return 0;
}
void invept(struct vcpu *vcpu)
@@ -495,8 +504,6 @@ void init_paging(void)
pr_dbg("HV MMU Initialization");
check_mmu_capability();
/* Allocate memory for Hypervisor PML4 table */
mmu_pml4_addr = alloc_paging_struct();