From 0742c15d40bf8b83abb2b5897ea5835191b3549b Mon Sep 17 00:00:00 2001 From: Hector Cao Date: Mon, 24 Nov 2025 14:40:29 +0100 Subject: [PATCH] cpu_map: fix sync script to extract correctly vmx-* features 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. 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. Signed-off-by: Hector Cao Reviewed-by: Jiri Denemark --- src/cpu_map/sync_qemu_features_i386.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/cpu_map/sync_qemu_features_i386.py b/src/cpu_map/sync_qemu_features_i386.py index b658b864f2..c99952fb86 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 @@ -202,6 +203,22 @@ def add_feature_cpuid(eax, ecx, reg, bit, name): _FEATURES["cpuid"][eax][ecx][reg][bit] = name +class VmxMsr(enum.Enum): + 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 + + +def is_vmx_msr(msr): + try: + VmxMsr(msr) + return True + except ValueError: + return False + + # add new msr feature bit def add_feature_msr(msr, bit, name): if not name: @@ -213,6 +230,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 -- 2.47.3