Skip to content

Commit

Permalink
HV: add MTRR capability check when CPU boot
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
yonghuah authored and NanlinXie committed Jun 28, 2018
1 parent f67951b commit 9beb1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions hypervisor/arch/x86/cpu.c
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions hypervisor/arch/x86/mtrr.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 9beb1b9

Please sign in to comment.