Skip to content

Commit 21aa190

Browse files
binbinwu1wenlingz
authored andcommitted
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 <binbin.wu@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
1 parent 2d3f510 commit 21aa190

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hypervisor/arch/x86/guest/vcpuid.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static void init_vcpuid_entry(uint32_t leaf, uint32_t subleaf,
106106
switch (leaf) {
107107
case 0x07U:
108108
if (subleaf == 0U) {
109-
cpuid(leaf,
109+
cpuid_subleaf(leaf, subleaf,
110110
&entry->eax, &entry->ebx,
111111
&entry->ecx, &entry->edx);
112112
/* mask invpcid */
@@ -117,6 +117,9 @@ static void init_vcpuid_entry(uint32_t leaf, uint32_t subleaf,
117117
/* mask SGX and SGX_LC */
118118
entry->ebx &= ~CPUID_EBX_SGX;
119119
entry->ecx &= ~CPUID_ECX_SGX_LC;
120+
121+
/* mask Intel Processor Trace, since 14h is disabled */
122+
entry->ebx &= ~CPUID_EBX_PROC_TRC;
120123
} else {
121124
entry->eax = 0U;
122125
entry->ebx = 0U;
@@ -224,6 +227,14 @@ int32_t set_vcpuid_entries(struct acrn_vm *vm)
224227
}
225228
}
226229
break;
230+
case 0x07U:
231+
init_vcpuid_entry(i, 0U, CPUID_CHECK_SUBLEAF, &entry);
232+
if (entry.eax != 0U) {
233+
pr_warn("vcpuid: only support subleaf 0 for cpu leaf 07h");
234+
entry.eax = 0U;
235+
}
236+
result = set_vcpuid_entry(vm, &entry);
237+
break;
227238

228239
/* These features are disabled */
229240
/* PMU is not supported */

hypervisor/include/arch/x86/cpuid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
#define CPUID_EBX_PQM (1U<<12U)
8989
/* CPUID.07H:EBX.PQE */
9090
#define CPUID_EBX_PQE (1U<<15U)
91+
/* CPUID.07H:EBX.INTEL_PROCESSOR_TRACE */
92+
#define CPUID_EBX_PROC_TRC (1U<<25U)
9193
/* CPUID.01H:ECX.PCID*/
9294
#define CPUID_ECX_PCID (1U<<17U)
9395

0 commit comments

Comments
 (0)