hv: add fast string enhanced rep movsb/stosb check on initial

The ACRN suppose the CPU support fast string enhanced rep.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1
2018-12-17 22:21:58 +08:00
committed by wenlingz
parent 3515ca1e65
commit 78e9a84f39
3 changed files with 27 additions and 0 deletions

View File

@@ -78,6 +78,24 @@ static inline bool get_monitor_cap(void)
return false;
}
static inline bool is_fast_string_erms_supported_and_enabled(void)
{
bool ret = false;
uint32_t misc_enable = (uint32_t)msr_read(MSR_IA32_MISC_ENABLE);
if ((misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) == 0U) {
pr_fatal("%s, fast string is not enabled\n", __func__);
} else {
if (!cpu_has_cap(X86_FEATURE_ERMS)) {
pr_fatal("%s, enhanced rep movsb/stosb not supported\n", __func__);
} else {
ret = true;
}
}
return ret;
}
static uint64_t get_address_mask(uint8_t limit)
{
return ((1UL << limit) - 1UL) & PAGE_MASK;
@@ -222,6 +240,11 @@ static int32_t hardware_detect_support(void)
return -ENODEV;
}
if (!is_fast_string_erms_supported_and_enabled()) {
return -ENODEV;
}
if (!cpu_has_vmx_unrestricted_guest_cap()) {
pr_fatal("%s, unrestricted guest not supported\n", __func__);
return -ENODEV;