HV: add MTRR capability check when CPU boot

- to avoid reading operations on MTRR registers if
no MTRR feature support on current platform in "init_mtrr()".

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2018-06-26 16:37:46 +08:00 committed by Xie, nanlin
parent f67951bf17
commit 9beb1b92b5
2 changed files with 6 additions and 2 deletions

View File

@ -219,6 +219,11 @@ static int hardware_detect_support(void)
return -ENODEV;
}
if (!cpu_has_cap(X86_FEATURE_MTRR)) {
pr_fatal("%s, MTRR not supported\n", __func__);
return -ENODEV;
}
if (!cpu_has_cap(X86_FEATURE_VMX)) {
pr_fatal("%s, vmx not supported\n", __func__);
return -ENODEV;

View File

@ -103,9 +103,8 @@ void init_mtrr(struct vcpu *vcpu)
vcpu->mtrr.def_type.bits.fixed_enable = 1;
vcpu->mtrr.def_type.bits.type = MTRR_MEM_TYPE_UC;
if (is_vm0(vcpu->vm) && cpu_has_cap(X86_FEATURE_MTRR)) {
if (is_vm0(vcpu->vm))
cap.value = msr_read(MSR_IA32_MTRR_CAP);
}
for (i = 0; i < FIXED_RANGE_MTRR_NUM; i++) {
if (cap.bits.fix) {