From: Paolo Bonzini <pbonzini@redhat.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Gleb Natapov <gleb@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
Date: Mon, 19 Aug 2013 11:22:49 +0200 [thread overview]
Message-ID: <5211E3E9.7080507@redhat.com> (raw)
In-Reply-To: <DE8DF0795D48FD4CA783C40EC829233501338EA4@SHSMSX101.ccr.corp.intel.com>
Il 18/08/2013 20:23, Liu, Jinsong ha scritto:
> From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
> From: Liu Jinsong <jinsong.liu@intel.com>
> Date: Mon, 19 Aug 2013 09:33:30 +0800
> Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
>
> This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
>
> IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
> cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
> or kvm_get_msrs.
>
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
> ---
> target-i386/kvm.c | 16 ++++++++++++++--
> 1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 84ac00a..7facbfe 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -65,6 +65,7 @@ static bool has_msr_star;
> static bool has_msr_hsave_pa;
> static bool has_msr_tsc_adjust;
> static bool has_msr_tsc_deadline;
> +static bool has_msr_feature_control;
> static bool has_msr_async_pf_en;
> static bool has_msr_pv_eoi_en;
> static bool has_msr_misc_enable;
> @@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
>
> qemu_add_vm_change_state_handler(cpu_update_state, env);
>
> + c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
> + if (c)
> + has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
> + !!(c->ecx & CPUID_EXT_SMX);
> +
> cpuid_data.cpuid.padding = 0;
> r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
> if (r) {
> @@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
> if (hyperv_vapic_recommended()) {
> kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
> }
> - kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
> + if (has_msr_feature_control) {
> + kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
> + env->msr_ia32_feature_control);
> + }
> }
> if (env->mcg_cap) {
> int i;
> @@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
> if (has_msr_misc_enable) {
> msrs[n++].index = MSR_IA32_MISC_ENABLE;
> }
> - msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + if (has_msr_feature_control) {
> + msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + }
>
> if (!env->tsc_valid) {
> msrs[n++].index = MSR_IA32_TSC;
> @@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
> break;
> case MSR_IA32_FEATURE_CONTROL:
> env->msr_ia32_feature_control = msrs[i].data;
> + break;
> default:
> if (msrs[i].index >= MSR_MC0_CTL &&
> msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
>
The patch looks good. Please repost it with checkpatch.pl failures fixed.
Paolo
next prev parent reply other threads:[~2013-08-19 9:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-18 18:23 [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL Liu, Jinsong
2013-08-18 18:37 ` Stefan Weil
2013-08-19 9:22 ` Paolo Bonzini [this message]
2013-08-19 14:31 ` Liu, Jinsong
2013-08-19 14:59 ` Andreas Färber
2013-08-19 15:20 ` Paolo Bonzini
2013-08-20 6:10 ` Liu, Jinsong
2013-08-20 3:33 ` Liu, Jinsong
2013-08-20 16:43 ` Paolo Bonzini
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=5211E3E9.7080507@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@redhat.com \
--cc=jinsong.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).