From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: vkuznets@redhat.com, liran.alon@oracle.com
Subject: [PATCH 3/3] target/i386: kvm: initialize microcode revision from KVM
Date: Mon, 20 Jan 2020 19:21:44 +0100 [thread overview]
Message-ID: <1579544504-3616-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1579544504-3616-1-git-send-email-pbonzini@redhat.com>
KVM can return the host microcode revision as a feature MSR.
Use it as the default value for -cpu host.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.c | 4 ++++
target/i386/kvm.c | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 05ce64c..1f731c1 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6416,6 +6416,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
&cpu->mwait.ecx, &cpu->mwait.edx);
env->features[FEAT_1_ECX] |= CPUID_EXT_MONITOR;
}
+ if (kvm_enabled() && cpu->ucode_rev == 0) {
+ cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state,
+ MSR_IA32_UCODE_REV);
+ }
}
if (cpu->ucode_rev == 0) {
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index f6dd6b7..26c1e78 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -2696,6 +2696,11 @@ static void kvm_init_msrs(X86CPU *cpu)
env->features[FEAT_CORE_CAPABILITY]);
}
+ if (kvm_arch_get_supported_msr_feature(kvm_state,
+ MSR_IA32_UCODE_REV)) {
+ kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev);
+ }
+
/*
* Older kernels do not include VMX MSRs in KVM_GET_MSR_INDEX_LIST, but
* all kernels with MSR features should have them.
--
1.8.3.1
next prev parent reply other threads:[~2020-01-20 18:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 18:21 [PATCH 0/3] target/i386: early MSR initialization + pass down host microcode revision for "-cpu host" Paolo Bonzini
2020-01-20 18:21 ` [PATCH 1/3] target/i386: kvm: initialize feature MSRs very early Paolo Bonzini
2020-01-20 18:21 ` [PATCH 2/3] target/i386: add a ucode-rev property Paolo Bonzini
2020-01-20 18:21 ` Paolo Bonzini [this message]
2020-01-20 18:40 ` [PATCH 0/3] target/i386: early MSR initialization + pass down host microcode revision for "-cpu host" no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1579544504-3616-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=liran.alon@oracle.com \
--cc=qemu-devel@nongnu.org \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).