thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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