|
|
4636b8 |
From 3a740f27c76ccd7fa2c0ece979a480bece592674 Mon Sep 17 00:00:00 2001
|
|
|
4636b8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4636b8 |
Date: Mon, 17 Feb 2020 16:23:20 -0500
|
|
|
4636b8 |
Subject: [PATCH 05/12] target/i386: kvm: initialize microcode revision from
|
|
|
4636b8 |
KVM
|
|
|
4636b8 |
MIME-Version: 1.0
|
|
|
4636b8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
4636b8 |
Content-Transfer-Encoding: 8bit
|
|
|
4636b8 |
|
|
|
4636b8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4636b8 |
Message-id: <20200217162323.2572-4-pbonzini@redhat.com>
|
|
|
4636b8 |
Patchwork-id: 93900
|
|
|
4636b8 |
O-Subject: [RHEL7.9 qemu-kvm-rhev PATCH 3/6] target/i386: kvm: initialize microcode revision from KVM
|
|
|
4636b8 |
Bugzilla: 1791653
|
|
|
4636b8 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
4636b8 |
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
4636b8 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4636b8 |
|
|
|
4636b8 |
KVM can return the host microcode revision as a feature MSR.
|
|
|
4636b8 |
Use it as the default value for -cpu host.
|
|
|
4636b8 |
|
|
|
4636b8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4636b8 |
Message-Id: <1579544504-3616-4-git-send-email-pbonzini@redhat.com>
|
|
|
4636b8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4636b8 |
(cherry picked from commit 32c87d70ff55b96741f08c35108935cac6f40fe4)
|
|
|
4636b8 |
|
|
|
4636b8 |
[RHEL7: change kvm_arch_get_supported_msr_feature to return 64-bit
|
|
|
4636b8 |
value, originally done for VMX features; split "if" statement in
|
|
|
4636b8 |
two parts, originally done for upstream commit 2266d44311
|
|
|
4636b8 |
("i386/cpu: make -cpu host support monitor/mwait", 2018-06-29)]
|
|
|
4636b8 |
|
|
|
4636b8 |
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
|
|
|
4636b8 |
---
|
|
|
4636b8 |
include/sysemu/kvm.h | 2 +-
|
|
|
4636b8 |
target/i386/cpu.c | 17 ++++++++++++-----
|
|
|
4636b8 |
target/i386/kvm.c | 7 ++++++-
|
|
|
4636b8 |
3 files changed, 19 insertions(+), 7 deletions(-)
|
|
|
4636b8 |
|
|
|
4636b8 |
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
|
4636b8 |
index 3d8f294633..cd9a0206ce 100644
|
|
|
4636b8 |
--- a/include/sysemu/kvm.h
|
|
|
4636b8 |
+++ b/include/sysemu/kvm.h
|
|
|
4636b8 |
@@ -464,7 +464,7 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension);
|
|
|
4636b8 |
|
|
|
4636b8 |
uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
|
|
|
4636b8 |
uint32_t index, int reg);
|
|
|
4636b8 |
-uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
|
|
|
4636b8 |
+uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
|
|
|
4636b8 |
|
|
|
4636b8 |
|
|
|
4636b8 |
void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
|
|
|
4636b8 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
4636b8 |
index ad905d6f8c..3579bd53c5 100644
|
|
|
4636b8 |
--- a/target/i386/cpu.c
|
|
|
4636b8 |
+++ b/target/i386/cpu.c
|
|
|
4636b8 |
@@ -4936,11 +4936,18 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
|
|
|
4636b8 |
Error *local_err = NULL;
|
|
|
4636b8 |
static bool ht_warned;
|
|
|
4636b8 |
|
|
|
4636b8 |
- if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
|
|
|
4636b8 |
- char *name = x86_cpu_class_get_model_name(xcc);
|
|
|
4636b8 |
- error_setg(&local_err, "CPU model '%s' requires KVM", name);
|
|
|
4636b8 |
- g_free(name);
|
|
|
4636b8 |
- goto out;
|
|
|
4636b8 |
+ if (xcc->host_cpuid_required) {
|
|
|
4636b8 |
+ if (!accel_uses_host_cpuid()) {
|
|
|
4636b8 |
+ char *name = x86_cpu_class_get_model_name(xcc);
|
|
|
4636b8 |
+ error_setg(&local_err, "CPU model '%s' requires KVM", name);
|
|
|
4636b8 |
+ g_free(name);
|
|
|
4636b8 |
+ goto out;
|
|
|
4636b8 |
+ }
|
|
|
4636b8 |
+
|
|
|
4636b8 |
+ if (kvm_enabled() && cpu->ucode_rev == 0) {
|
|
|
4636b8 |
+ cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state,
|
|
|
4636b8 |
+ MSR_IA32_UCODE_REV);
|
|
|
4636b8 |
+ }
|
|
|
4636b8 |
}
|
|
|
4636b8 |
|
|
|
4636b8 |
if (cpu->ucode_rev == 0) {
|
|
|
4636b8 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
4636b8 |
index d8a4dbfde3..4d43fba716 100644
|
|
|
4636b8 |
--- a/target/i386/kvm.c
|
|
|
4636b8 |
+++ b/target/i386/kvm.c
|
|
|
4636b8 |
@@ -419,7 +419,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
|
|
4636b8 |
return ret;
|
|
|
4636b8 |
}
|
|
|
4636b8 |
|
|
|
4636b8 |
-uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
|
|
|
4636b8 |
+uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
|
|
|
4636b8 |
{
|
|
|
4636b8 |
struct {
|
|
|
4636b8 |
struct kvm_msrs info;
|
|
|
4636b8 |
@@ -1828,6 +1828,11 @@ static void kvm_init_msrs(X86CPU *cpu)
|
|
|
4636b8 |
env->features[FEAT_ARCH_CAPABILITIES]);
|
|
|
4636b8 |
}
|
|
|
4636b8 |
|
|
|
4636b8 |
+ if (kvm_arch_get_supported_msr_feature(kvm_state,
|
|
|
4636b8 |
+ MSR_IA32_UCODE_REV)) {
|
|
|
4636b8 |
+ kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev);
|
|
|
4636b8 |
+ }
|
|
|
4636b8 |
+
|
|
|
4636b8 |
assert(kvm_buf_set_msrs(cpu) == 0);
|
|
|
4636b8 |
}
|
|
|
4636b8 |
|
|
|
4636b8 |
--
|
|
|
4636b8 |
2.18.2
|
|
|
4636b8 |
|