On Mon, Nov 24, 2025 at 14:40:29 +0100, Hector Cao wrote: > The src/cpu_map/x86_features.xml file contains the definition > of all x86 CPU features, these definitions specify how we can > decode the feature support fom the CPUID or MSR values. > > The helper script sync_qemu_features_i386.py builds the > x86_features.xml file from QEMU source code to be in sync > with supported features in QEMU. This helper script parses > QEMU target/i386/cpu.c file looking for CPU feature definitions > and convert them into x86_features.xml contents. > > This is the resulting definition for the vmx-intr-exit feature > encoded in the MSR 0x48d. > > <!-- msr 0x0000048d --> > <feature name='vmx-intr-exit'> > <msr index='0x0000048d' edx='0x00000000' eax='0x00000001'/> > </feature> > > EAX holds the 32 lower bits of the MSRE 64-bits value and should > not be used to detect the VMX-* features. Indeed, VMX-* bit > position should be parsed from QEMU source code in the 32 higher > bits of the corresponding MSR value. > > This commit fixes this issue by using the 32 higher bits (EDX) > to represent VMX-* features. > --- > src/cpu_map/sync_qemu_features_i386.py | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/src/cpu_map/sync_qemu_features_i386.py > b/src/cpu_map/sync_qemu_features_i386.py > index b658b864f2..ed65d9966a 100755 > --- a/src/cpu_map/sync_qemu_features_i386.py > +++ b/src/cpu_map/sync_qemu_features_i386.py > @@ -1,6 +1,7 @@ > #!/usr/bin/env python3 > > import argparse > +import enum > import os > import re > > @@ -201,6 +202,19 @@ def add_feature_cpuid(eax, ecx, reg, bit, name): > > _FEATURES["cpuid"][eax][ecx][reg][bit] = name > > +class VmxMsr(enum.Enum):
Syntax-check complains there should be two empty lines above VmxMsr class definition. > + MSR_IA32_VMX_PROCBASED_CTLS2 = 0x0000048b > + MSR_IA32_VMX_TRUE_PINBASED_CTLS = 0x0000048d > + MSR_IA32_VMX_TRUE_PROCBASED_CTLS = 0x0000048e > + MSR_IA32_VMX_TRUE_ENTRY_CTLS = 0x00000490 > + MSR_IA32_VMX_TRUE_EXIT_CTLS = 0x0000048f > + Two empty lines here as well. > +def is_vmx_msr(msr): > + try: > + VmxMsr(msr) > + return True > + except ValueError: > + return False > And here. > # add new msr feature bit > def add_feature_msr(msr, bit, name): > @@ -213,6 +227,11 @@ def add_feature_msr(msr, bit, name): > if msr not in _FEATURES["msr"]: > _FEATURES["msr"][msr] = dict() > > + # VMX-* features are specified in the 32 higher bits > + # of the MSR value > + if is_vmx_msr(msr): > + bit += 32 > + > _FEATURES["msr"][msr][bit] = name Jirka
