From: Paolo Bonzini <pbonzini@redhat.com>
To: Catherine Ho <catherine.hecx@gmail.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
kvm@vger.kernel.org, "Zhong, Yang" <yang.zhong@intel.com>
Subject: Re: [PATCH] target/i386: skip kvm_msr_entry_add when kvm_vmx_basic is 0
Date: Fri, 6 Dec 2019 12:30:48 +0100 [thread overview]
Message-ID: <9c86f277-f13c-b33d-41e5-0ed32aaf75d7@redhat.com> (raw)
In-Reply-To: <1575627817-24625-1-git-send-email-catherine.hecx@gmail.com>
On 06/12/19 11:23, Catherine Ho wrote:
> Commit 1389309c811b ("KVM: nVMX: expose VMX capabilities for nested
> hypervisors to userspace") expands the msr_based_features with
> MSR_IA32_VMX_BASIC and others. Then together with an old kernel before
> 1389309c811b, the qemu call KVM_GET_MSR_FEATURE_INDEX_LIST and got the
> smaller kvm_feature_msrs. Then in kvm_arch_get_supported_msr_feature(),
> searching VMX_BASIC will be failed and return 0. At last kvm_vmx_basic
> will be assigned to 0.
>
> Without this patch, it will cause a qemu crash (host kernel 4.15
> ubuntu 18.04+qemu 4.1):
> qemu-system-x86_64: error: failed to set MSR 0x480 to 0x0
> target/i386/kvm.c:2932: kvm_put_msrs: Assertion `ret ==
> cpu->kvm_msr_buf->nmsrs' failed.
>
> This fixes it by skipping kvm_msr_entry_add when kvm_vmx_basic is 0
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Catherine Ho <catherine.hecx@gmail.com>
> ---
> target/i386/kvm.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index a8c44bf..8cf84a2 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -2632,8 +2632,13 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f)
> f[FEAT_VMX_SECONDARY_CTLS]));
> kvm_msr_entry_add(cpu, MSR_IA32_VMX_EPT_VPID_CAP,
> f[FEAT_VMX_EPT_VPID_CAPS] | fixed_vmx_ept_vpid);
> - kvm_msr_entry_add(cpu, MSR_IA32_VMX_BASIC,
> +
> + if (kvm_vmx_basic) {
> + /* Only add the entry when host supports it */
> + kvm_msr_entry_add(cpu, MSR_IA32_VMX_BASIC,
> f[FEAT_VMX_BASIC] | fixed_vmx_basic);
> + }
> +
> kvm_msr_entry_add(cpu, MSR_IA32_VMX_MISC,
> f[FEAT_VMX_MISC] | fixed_vmx_misc);
> if (has_msr_vmx_vmfunc) {
>
Yang Zhong from Intel also sent a similar patch. Thanks very much to
both of you.
Paolo
next prev parent reply other threads:[~2019-12-06 11:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 8:50 [PATCH] target/i386: relax assert when old host kernels don't include msrs Catherine Ho
2019-12-04 11:22 ` Paolo Bonzini
[not found] ` <CAEn6zmFex9WJ9jr5-0br7YzQZ=jA5bQn314OM+U=Q6ZGPiCRAg@mail.gmail.com>
2019-12-04 13:53 ` Paolo Bonzini
2019-12-04 15:07 ` Catherine Ho
2019-12-04 15:34 ` Paolo Bonzini
2019-12-04 15:47 ` Eduardo Habkost
2019-12-04 16:23 ` Paolo Bonzini
2019-12-06 10:23 ` [PATCH] target/i386: skip kvm_msr_entry_add when kvm_vmx_basic is 0 Catherine Ho
2019-12-06 10:28 ` Catherine Ho
2019-12-06 11:30 ` Paolo Bonzini [this message]
2019-12-06 23:48 ` 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=9c86f277-f13c-b33d-41e5-0ed32aaf75d7@redhat.com \
--to=pbonzini@redhat.com \
--cc=catherine.hecx@gmail.com \
--cc=ehabkost@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=yang.zhong@intel.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).