Blame SOURCES/kvm-x86-Data-structure-changes-to-support-MSR-based-feat.patch

8b1478
From d3ceeb5294b3dfec6fc86cc1111f12923b62e50c Mon Sep 17 00:00:00 2001
8b1478
From: "plai@redhat.com" <plai@redhat.com>
8b1478
Date: Tue, 4 Jun 2019 21:47:23 +0200
8b1478
Subject: [PATCH 04/23] x86: Data structure changes to support MSR based
8b1478
 features
8b1478
8b1478
RH-Author: plai@redhat.com
8b1478
Message-id: <1559684847-10889-5-git-send-email-plai@redhat.com>
8b1478
Patchwork-id: 88535
8b1478
O-Subject: [RHEL7.7 qemu-kvm-rhev PATCH v4 4/8] x86: Data structure changes to support MSR based features
8b1478
Bugzilla: 1709972
8b1478
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
8b1478
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
8b1478
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
8b1478
8b1478
From: Robert Hoo <robert.hu@linux.intel.com>
8b1478
8b1478
Add FeatureWordType indicator in struct FeatureWordInfo.
8b1478
Change feature_word_info[] accordingly.
8b1478
Change existing functions that refer to feature_word_info[] accordingly.
8b1478
8b1478
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
8b1478
Message-Id: <1539578845-37944-3-git-send-email-robert.hu@linux.intel.com>
8b1478
[ehabkost: fixed hvf_enabled() case]
8b1478
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
8b1478
(cherry picked from commit 07585923485952bf4cb7da563c9f91fecc85d09c)
8b1478
Signed-off-by: Paul Lai <plai@redhat.com>
8b1478
8b1478
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8b1478
---
8b1478
 target/i386/cpu.c | 197 +++++++++++++++++++++++++++++++++++++++---------------
8b1478
 1 file changed, 142 insertions(+), 55 deletions(-)
8b1478
8b1478
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
8b1478
index 4c7364b..3a06d37 100644
8b1478
--- a/target/i386/cpu.c
8b1478
+++ b/target/i386/cpu.c
8b1478
@@ -773,17 +773,36 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
8b1478
           /* missing:
8b1478
           CPUID_XSAVE_XSAVEC, CPUID_XSAVE_XSAVES */
8b1478
 
8b1478
+typedef enum FeatureWordType {
8b1478
+   CPUID_FEATURE_WORD,
8b1478
+   MSR_FEATURE_WORD,
8b1478
+} FeatureWordType;
8b1478
+
8b1478
 typedef struct FeatureWordInfo {
8b1478
+    FeatureWordType type;
8b1478
     /* feature flags names are taken from "Intel Processor Identification and
8b1478
      * the CPUID Instruction" and AMD's "CPUID Specification".
8b1478
      * In cases of disagreement between feature naming conventions,
8b1478
      * aliases may be added.
8b1478
      */
8b1478
     const char *feat_names[32];
8b1478
-    uint32_t cpuid_eax;   /* Input EAX for CPUID */
8b1478
-    bool cpuid_needs_ecx; /* CPUID instruction uses ECX as input */
8b1478
-    uint32_t cpuid_ecx;   /* Input ECX value for CPUID */
8b1478
-    int cpuid_reg;        /* output register (R_* constant) */
8b1478
+    union {
8b1478
+        /* If type==CPUID_FEATURE_WORD */
8b1478
+        struct {
8b1478
+            uint32_t eax;   /* Input EAX for CPUID */
8b1478
+            bool needs_ecx; /* CPUID instruction uses ECX as input */
8b1478
+            uint32_t ecx;   /* Input ECX value for CPUID */
8b1478
+            int reg;        /* output register (R_* constant) */
8b1478
+        } cpuid;
8b1478
+        /* If type==MSR_FEATURE_WORD */
8b1478
+        struct {
8b1478
+            uint32_t index;
8b1478
+            struct {   /*CPUID that enumerate this MSR*/
8b1478
+                FeatureWord cpuid_class;
8b1478
+                uint32_t    cpuid_flag;
8b1478
+            } cpuid_dep;
8b1478
+        } msr;
8b1478
+    };
8b1478
     uint32_t tcg_features; /* Feature flags supported by TCG */
8b1478
     uint32_t unmigratable_flags; /* Feature flags known to be unmigratable */
8b1478
     uint32_t migratable_flags; /* Feature flags known to be migratable */
8b1478
@@ -793,6 +812,7 @@ typedef struct FeatureWordInfo {
8b1478
 
8b1478
 static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
     [FEAT_1_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "fpu", "vme", "de", "pse",
8b1478
             "tsc", "msr", "pae", "mce",
8b1478
@@ -803,10 +823,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             "fxsr", "sse", "sse2", "ss",
8b1478
             "ht" /* Intel htt */, "tm", "ia64", "pbe",
8b1478
         },
8b1478
-        .cpuid_eax = 1, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = {.eax = 1, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_FEATURES,
8b1478
     },
8b1478
     [FEAT_1_ECX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "pni" /* Intel,AMD sse3 */, "pclmulqdq", "dtes64", "monitor",
8b1478
             "ds-cpl", "vmx", "smx", "est",
8b1478
@@ -817,7 +838,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             "tsc-deadline", "aes", "xsave", "osxsave",
8b1478
             "avx", "f16c", "rdrand", "hypervisor",
8b1478
         },
8b1478
-        .cpuid_eax = 1, .cpuid_reg = R_ECX,
8b1478
+        .cpuid = { .eax = 1, .reg = R_ECX, },
8b1478
         .tcg_features = TCG_EXT_FEATURES,
8b1478
     },
8b1478
     /* Feature names that are already defined on feature_name[] but
8b1478
@@ -826,6 +847,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
      * to features[FEAT_8000_0001_EDX] if and only if CPU vendor is AMD.
8b1478
      */
8b1478
     [FEAT_8000_0001_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL /* fpu */, NULL /* vme */, NULL /* de */, NULL /* pse */,
8b1478
             NULL /* tsc */, NULL /* msr */, NULL /* pae */, NULL /* mce */,
8b1478
@@ -836,10 +858,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL /* fxsr */, "fxsr-opt", "pdpe1gb", "rdtscp",
8b1478
             NULL, "lm", "3dnowext", "3dnow",
8b1478
         },
8b1478
-        .cpuid_eax = 0x80000001, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = 0x80000001, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_EXT2_FEATURES,
8b1478
     },
8b1478
     [FEAT_8000_0001_ECX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "lahf-lm", "cmp-legacy", "svm", "extapic",
8b1478
             "cr8legacy", "abm", "sse4a", "misalignsse",
8b1478
@@ -850,7 +873,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             "perfctr-nb", NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x80000001, .cpuid_reg = R_ECX,
8b1478
+        .cpuid = { .eax = 0x80000001, .reg = R_ECX, },
8b1478
         .tcg_features = TCG_EXT3_FEATURES,
8b1478
         /*
8b1478
          * TOPOEXT is always allowed but can't be enabled blindly by
8b1478
@@ -860,6 +883,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
         .no_autoenable_flags = CPUID_EXT3_TOPOEXT,
8b1478
     },
8b1478
     [FEAT_C000_0001_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, NULL, "xstore", "xstore-en",
8b1478
             NULL, NULL, "xcrypt", "xcrypt-en",
8b1478
@@ -870,10 +894,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0xC0000001, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = 0xC0000001, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_EXT4_FEATURES,
8b1478
     },
8b1478
     [FEAT_KVM] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock",
8b1478
             "kvm-asyncpf", "kvm-steal-time", "kvm-pv-eoi", "kvm-pv-unhalt",
8b1478
@@ -884,10 +909,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             "kvmclock-stable-bit", NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
8b1478
+        .cpuid = { .eax = KVM_CPUID_FEATURES, .reg = R_EAX, },
8b1478
         .tcg_features = TCG_KVM_FEATURES,
8b1478
     },
8b1478
     [FEAT_KVM_HINTS] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "kvm-hint-dedicated", NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -898,7 +924,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = KVM_CPUID_FEATURES, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_KVM_FEATURES,
8b1478
         /*
8b1478
          * KVM hints aren't auto-enabled by -cpu host, they need to be
8b1478
@@ -907,6 +933,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
         .no_autoenable_flags = ~0U,
8b1478
     },
8b1478
     [FEAT_HYPERV_EAX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refcount_access */,
8b1478
             NULL /* hv_msr_synic_access */, NULL /* hv_msr_stimer_access */,
8b1478
@@ -920,9 +947,10 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x40000003, .cpuid_reg = R_EAX,
8b1478
+        .cpuid = { .eax = 0x40000003, .reg = R_EAX, },
8b1478
     },
8b1478
     [FEAT_HYPERV_EBX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL /* hv_create_partitions */, NULL /* hv_access_partition_id */,
8b1478
             NULL /* hv_access_memory_pool */, NULL /* hv_adjust_message_buffers */,
8b1478
@@ -936,9 +964,10 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x40000003, .cpuid_reg = R_EBX,
8b1478
+        .cpuid = { .eax = 0x40000003, .reg = R_EBX, },
8b1478
     },
8b1478
     [FEAT_HYPERV_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL /* hv_mwait */, NULL /* hv_guest_debugging */,
8b1478
             NULL /* hv_perf_monitor */, NULL /* hv_cpu_dynamic_part */,
8b1478
@@ -951,9 +980,10 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x40000003, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = 0x40000003, .reg = R_EDX, },
8b1478
     },
8b1478
     [FEAT_SVM] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "npt", "lbrv", "svm-lock", "nrip-save",
8b1478
             "tsc-scale", "vmcb-clean",  "flushbyasid", "decodeassists",
8b1478
@@ -964,10 +994,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x8000000A, .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = 0x8000000A, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_SVM_FEATURES,
8b1478
     },
8b1478
     [FEAT_7_0_EBX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "fsgsbase", "tsc-adjust", NULL, "bmi1",
8b1478
             "hle", "avx2", NULL, "smep",
8b1478
@@ -978,12 +1009,15 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             "clwb", "intel-pt", "avx512pf", "avx512er",
8b1478
             "avx512cd", "sha-ni", "avx512bw", "avx512vl",
8b1478
         },
8b1478
-        .cpuid_eax = 7,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 0,
8b1478
-        .cpuid_reg = R_EBX,
8b1478
+        .cpuid = {
8b1478
+            .eax = 7,
8b1478
+            .needs_ecx = true, .ecx = 0,
8b1478
+            .reg = R_EBX,
8b1478
+        },
8b1478
         .tcg_features = TCG_7_0_EBX_FEATURES,
8b1478
     },
8b1478
     [FEAT_7_0_ECX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, "avx512vbmi", "umip", "pku",
8b1478
             "ospke", NULL, "avx512vbmi2", NULL,
8b1478
@@ -994,12 +1028,15 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, "cldemote", NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 7,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 0,
8b1478
-        .cpuid_reg = R_ECX,
8b1478
+        .cpuid = {
8b1478
+            .eax = 7,
8b1478
+            .needs_ecx = true, .ecx = 0,
8b1478
+            .reg = R_ECX,
8b1478
+        },
8b1478
         .tcg_features = TCG_7_0_ECX_FEATURES,
8b1478
     },
8b1478
     [FEAT_7_0_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, NULL, "avx512-4vnniw", "avx512-4fmaps",
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -1010,13 +1047,16 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, "spec-ctrl", "stibp",
8b1478
             NULL, "arch-capabilities", NULL, "ssbd",
8b1478
         },
8b1478
-        .cpuid_eax = 7,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 0,
8b1478
-        .cpuid_reg = R_EDX,
8b1478
+        .cpuid = {
8b1478
+            .eax = 7,
8b1478
+            .needs_ecx = true, .ecx = 0,
8b1478
+            .reg = R_EDX,
8b1478
+        },
8b1478
         .tcg_features = TCG_7_0_EDX_FEATURES,
8b1478
         .unmigratable_flags = CPUID_7_0_EDX_ARCH_CAPABILITIES,
8b1478
     },
8b1478
     [FEAT_8000_0007_EDX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -1027,12 +1067,12 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x80000007,
8b1478
-        .cpuid_reg = R_EDX,
8b1478
+        .cpuid = { .eax = 0x80000007, .reg = R_EDX, },
8b1478
         .tcg_features = TCG_APM_FEATURES,
8b1478
         .unmigratable_flags = CPUID_APM_INVTSC,
8b1478
     },
8b1478
     [FEAT_8000_0008_EBX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -1043,12 +1083,12 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, "virt-ssbd", NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0x80000008,
8b1478
-        .cpuid_reg = R_EBX,
8b1478
+        .cpuid = { .eax = 0x80000008, .reg = R_EBX, },
8b1478
         .tcg_features = 0,
8b1478
         .unmigratable_flags = 0,
8b1478
     },
8b1478
     [FEAT_XSAVE] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             "xsaveopt", "xsavec", "xgetbv1", "xsaves",
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -1059,12 +1099,15 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 0xd,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 1,
8b1478
-        .cpuid_reg = R_EAX,
8b1478
+        .cpuid = {
8b1478
+            .eax = 0xd,
8b1478
+            .needs_ecx = true, .ecx = 1,
8b1478
+            .reg = R_EAX,
8b1478
+        },
8b1478
         .tcg_features = TCG_XSAVE_FEATURES,
8b1478
     },
8b1478
     [FEAT_6_EAX] = {
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
         .feat_names = {
8b1478
             NULL, NULL, "arat", NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
@@ -1075,13 +1118,16 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             NULL, NULL, NULL, NULL,
8b1478
             NULL, NULL, NULL, NULL,
8b1478
         },
8b1478
-        .cpuid_eax = 6, .cpuid_reg = R_EAX,
8b1478
+        .cpuid = { .eax = 6, .reg = R_EAX, },
8b1478
         .tcg_features = TCG_6_EAX_FEATURES,
8b1478
     },
8b1478
     [FEAT_XSAVE_COMP_LO] = {
8b1478
-        .cpuid_eax = 0xD,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 0,
8b1478
-        .cpuid_reg = R_EAX,
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
+        .cpuid = {
8b1478
+            .eax = 0xD,
8b1478
+            .needs_ecx = true, .ecx = 0,
8b1478
+            .reg = R_EAX,
8b1478
+        },
8b1478
         .tcg_features = ~0U,
8b1478
         .migratable_flags = XSTATE_FP_MASK | XSTATE_SSE_MASK |
8b1478
             XSTATE_YMM_MASK | XSTATE_BNDREGS_MASK | XSTATE_BNDCSR_MASK |
8b1478
@@ -1089,9 +1135,12 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8b1478
             XSTATE_PKRU_MASK,
8b1478
     },
8b1478
     [FEAT_XSAVE_COMP_HI] = {
8b1478
-        .cpuid_eax = 0xD,
8b1478
-        .cpuid_needs_ecx = true, .cpuid_ecx = 0,
8b1478
-        .cpuid_reg = R_EDX,
8b1478
+        .type = CPUID_FEATURE_WORD,
8b1478
+        .cpuid = {
8b1478
+            .eax = 0xD,
8b1478
+            .needs_ecx = true, .ecx = 0,
8b1478
+            .reg = R_EDX,
8b1478
+        },
8b1478
         .tcg_features = ~0U,
8b1478
     },
8b1478
 };
8b1478
@@ -2846,21 +2895,41 @@ static const TypeInfo host_x86_cpu_type_info = {
8b1478
 
8b1478
 #endif
8b1478
 
8b1478
+static char *feature_word_description(FeatureWordInfo *f, uint32_t bit)
8b1478
+{
8b1478
+    assert(f->type == CPUID_FEATURE_WORD || f->type == MSR_FEATURE_WORD);
8b1478
+
8b1478
+    switch (f->type) {
8b1478
+    case CPUID_FEATURE_WORD:
8b1478
+        {
8b1478
+            const char *reg = get_register_name_32(f->cpuid.reg);
8b1478
+            assert(reg);
8b1478
+            return g_strdup_printf("CPUID.%02XH:%s",
8b1478
+                                   f->cpuid.eax, reg);
8b1478
+        }
8b1478
+    case MSR_FEATURE_WORD:
8b1478
+        return g_strdup_printf("MSR(%02XH)",
8b1478
+                               f->msr.index);
8b1478
+    }
8b1478
+
8b1478
+    return NULL;
8b1478
+}
8b1478
+
8b1478
 static void report_unavailable_features(FeatureWord w, uint32_t mask)
8b1478
 {
8b1478
     FeatureWordInfo *f = &feature_word_info[w];
8b1478
     int i;
8b1478
+    char *feat_word_str;
8b1478
 
8b1478
     for (i = 0; i < 32; ++i) {
8b1478
         if ((1UL << i) & mask) {
8b1478
-            const char *reg = get_register_name_32(f->cpuid_reg);
8b1478
-            assert(reg);
8b1478
-            warn_report("%s doesn't support requested feature: "
8b1478
-                        "CPUID.%02XH:%s%s%s [bit %d]",
8b1478
+            feat_word_str = feature_word_description(f, i);
8b1478
+            warn_report("%s doesn't support requested feature: %s%s%s [bit %d]",
8b1478
                         accel_uses_host_cpuid() ? "host" : "TCG",
8b1478
-                        f->cpuid_eax, reg,
8b1478
+                        feat_word_str,
8b1478
                         f->feat_names[i] ? "." : "",
8b1478
                         f->feat_names[i] ? f->feat_names[i] : "", i);
8b1478
+            g_free(feat_word_str);
8b1478
         }
8b1478
     }
8b1478
 }
8b1478
@@ -3104,11 +3173,18 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
8b1478
 
8b1478
     for (w = 0; w < FEATURE_WORDS; w++) {
8b1478
         FeatureWordInfo *wi = &feature_word_info[w];
8b1478
+        /*
8b1478
+                * We didn't have MSR features when "feature-words" was
8b1478
+                *  introduced. Therefore skipped other type entries.
8b1478
+                */
8b1478
+        if (wi->type != CPUID_FEATURE_WORD) {
8b1478
+            continue;
8b1478
+        }
8b1478
         X86CPUFeatureWordInfo *qwi = &word_infos[w];
8b1478
-        qwi->cpuid_input_eax = wi->cpuid_eax;
8b1478
-        qwi->has_cpuid_input_ecx = wi->cpuid_needs_ecx;
8b1478
-        qwi->cpuid_input_ecx = wi->cpuid_ecx;
8b1478
-        qwi->cpuid_register = x86_reg_info_32[wi->cpuid_reg].qapi_enum;
8b1478
+        qwi->cpuid_input_eax = wi->cpuid.eax;
8b1478
+        qwi->has_cpuid_input_ecx = wi->cpuid.needs_ecx;
8b1478
+        qwi->cpuid_input_ecx = wi->cpuid.ecx;
8b1478
+        qwi->cpuid_register = x86_reg_info_32[wi->cpuid.reg].qapi_enum;
8b1478
         qwi->features = array[w];
8b1478
 
8b1478
         /* List will be in reverse order, but order shouldn't matter */
8b1478
@@ -3464,16 +3540,26 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
8b1478
                                                    bool migratable_only)
8b1478
 {
8b1478
     FeatureWordInfo *wi = &feature_word_info[w];
8b1478
-    uint32_t r;
8b1478
+    uint32_t r = 0;
8b1478
 
8b1478
     if (kvm_enabled()) {
8b1478
-        r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
8b1478
-                                                    wi->cpuid_ecx,
8b1478
-                                                    wi->cpuid_reg);
8b1478
+        switch (wi->type) {
8b1478
+        case CPUID_FEATURE_WORD:
8b1478
+            r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid.eax,
8b1478
+                                                        wi->cpuid.ecx,
8b1478
+                                                        wi->cpuid.reg);
8b1478
+            break;
8b1478
+        case MSR_FEATURE_WORD:
8b1478
+            r = kvm_arch_get_supported_msr_feature(kvm_state, wi->msr.index);
8b1478
+            break;
8b1478
+        }
8b1478
     } else if (hvf_enabled()) {
8b1478
-        r = hvf_get_supported_cpuid(wi->cpuid_eax,
8b1478
-                                    wi->cpuid_ecx,
8b1478
-                                    wi->cpuid_reg);
8b1478
+        if (wi->type != CPUID_FEATURE_WORD) {
8b1478
+            return 0;
8b1478
+        }
8b1478
+        r = hvf_get_supported_cpuid(wi->cpuid.eax,
8b1478
+                                    wi->cpuid.ecx,
8b1478
+                                    wi->cpuid.reg);
8b1478
     } else if (tcg_enabled()) {
8b1478
         r = wi->tcg_features;
8b1478
     } else {
8b1478
@@ -4534,9 +4620,10 @@ static void x86_cpu_adjust_feat_level(X86CPU *cpu, FeatureWord w)
8b1478
 {
8b1478
     CPUX86State *env = &cpu->env;
8b1478
     FeatureWordInfo *fi = &feature_word_info[w];
8b1478
-    uint32_t eax = fi->cpuid_eax;
8b1478
+    uint32_t eax = fi->cpuid.eax;
8b1478
     uint32_t region = eax & 0xF0000000;
8b1478
 
8b1478
+    assert(feature_word_info[w].type == CPUID_FEATURE_WORD);
8b1478
     if (!env->features[w]) {
8b1478
         return;
8b1478
     }
8b1478
-- 
8b1478
1.8.3.1
8b1478