From 21aa1907fda41c168faa82eb975b07266fa786ec Mon Sep 17 00:00:00 2001 From: Binbin Wu Date: Sat, 22 Dec 2018 22:35:46 +0800 Subject: [PATCH] hv: vcpuid: cpuid leaf 07h has subleaf Two changes: 1. cpuid leaf 07h has subleaf: According to SDM 3-194 Vol.2A, Table 3-8, cpuid leaf 07h has sub-leaves. cpuid.07.eax reports the maximum input for sub-leaves. Since there is no definition for subleaf > 0 in SDM, hv only supports subleaf 0. 2. In currently hv code, cpuid leaf function 14h is disabled, CPUID.07H:EBX.INTEL_PROCESSOR_TRACE should be disabled as well. Tracked-On: #2198 Signed-off-by: Binbin Wu Reviewed-by: Li, Fei1 Reviewed-by: Eddie Dong --- hypervisor/arch/x86/guest/vcpuid.c | 13 ++++++++++++- hypervisor/include/arch/x86/cpuid.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hypervisor/arch/x86/guest/vcpuid.c b/hypervisor/arch/x86/guest/vcpuid.c index 17fe25dfb..370e41681 100644 --- a/hypervisor/arch/x86/guest/vcpuid.c +++ b/hypervisor/arch/x86/guest/vcpuid.c @@ -106,7 +106,7 @@ static void init_vcpuid_entry(uint32_t leaf, uint32_t subleaf, switch (leaf) { case 0x07U: if (subleaf == 0U) { - cpuid(leaf, + cpuid_subleaf(leaf, subleaf, &entry->eax, &entry->ebx, &entry->ecx, &entry->edx); /* mask invpcid */ @@ -117,6 +117,9 @@ static void init_vcpuid_entry(uint32_t leaf, uint32_t subleaf, /* mask SGX and SGX_LC */ entry->ebx &= ~CPUID_EBX_SGX; entry->ecx &= ~CPUID_ECX_SGX_LC; + + /* mask Intel Processor Trace, since 14h is disabled */ + entry->ebx &= ~CPUID_EBX_PROC_TRC; } else { entry->eax = 0U; entry->ebx = 0U; @@ -224,6 +227,14 @@ int32_t set_vcpuid_entries(struct acrn_vm *vm) } } break; + case 0x07U: + init_vcpuid_entry(i, 0U, CPUID_CHECK_SUBLEAF, &entry); + if (entry.eax != 0U) { + pr_warn("vcpuid: only support subleaf 0 for cpu leaf 07h"); + entry.eax = 0U; + } + result = set_vcpuid_entry(vm, &entry); + break; /* These features are disabled */ /* PMU is not supported */ diff --git a/hypervisor/include/arch/x86/cpuid.h b/hypervisor/include/arch/x86/cpuid.h index ea7ea7043..9bca32149 100644 --- a/hypervisor/include/arch/x86/cpuid.h +++ b/hypervisor/include/arch/x86/cpuid.h @@ -88,6 +88,8 @@ #define CPUID_EBX_PQM (1U<<12U) /* CPUID.07H:EBX.PQE */ #define CPUID_EBX_PQE (1U<<15U) +/* CPUID.07H:EBX.INTEL_PROCESSOR_TRACE */ +#define CPUID_EBX_PROC_TRC (1U<<25U) /* CPUID.01H:ECX.PCID*/ #define CPUID_ECX_PCID (1U<<17U)