Blame SOURCES/kvm-target-i386-kvm-initialize-microcode-revision-from-K.patch

902636
From 8f39b0c9523630efeb451e2298cf64b88cd2ac81 Mon Sep 17 00:00:00 2001
902636
From: Paolo Bonzini <pbonzini@redhat.com>
902636
Date: Mon, 17 Feb 2020 16:23:13 +0000
902636
Subject: [PATCH 3/9] target/i386: kvm: initialize microcode revision from KVM
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
902636
Message-id: <20200217162316.2464-4-pbonzini@redhat.com>
902636
Patchwork-id: 93897
902636
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 3/6] target/i386: kvm: initialize microcode revision from KVM
902636
Bugzilla: 1791648
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
902636
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
902636
KVM can return the host microcode revision as a feature MSR.
902636
Use it as the default value for -cpu host.
902636
902636
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
902636
Message-Id: <1579544504-3616-4-git-send-email-pbonzini@redhat.com>
902636
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
902636
(cherry picked from commit 32c87d70ff55b96741f08c35108935cac6f40fe4)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 target/i386/cpu.c | 4 ++++
902636
 target/i386/kvm.c | 5 +++++
902636
 2 files changed, 9 insertions(+)
902636
902636
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
902636
index e505d3e..5ac843d 100644
902636
--- a/target/i386/cpu.c
902636
+++ b/target/i386/cpu.c
902636
@@ -6323,6 +6323,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
902636
                        &cpu->mwait.ecx, &cpu->mwait.edx);
902636
             env->features[FEAT_1_ECX] |= CPUID_EXT_MONITOR;
902636
         }
902636
+        if (kvm_enabled() && cpu->ucode_rev == 0) {
902636
+            cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state,
902636
+                                                                MSR_IA32_UCODE_REV);
902636
+        }
902636
     }
902636
 
902636
     if (cpu->ucode_rev == 0) {
902636
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
902636
index f41605b..6c61aef 100644
902636
--- a/target/i386/kvm.c
902636
+++ b/target/i386/kvm.c
902636
@@ -2696,6 +2696,11 @@ static void kvm_init_msrs(X86CPU *cpu)
902636
                           env->features[FEAT_CORE_CAPABILITY]);
902636
     }
902636
 
902636
+    if (kvm_arch_get_supported_msr_feature(kvm_state,
902636
+                                           MSR_IA32_UCODE_REV)) {
902636
+        kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev);
902636
+    }
902636
+
902636
     /*
902636
      * Older kernels do not include VMX MSRs in KVM_GET_MSR_INDEX_LIST, but
902636
      * all kernels with MSR features should have them.
902636
-- 
902636
1.8.3.1
902636