From: Paolo Bonzini <pbonzini@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Arthur Chunqi Li <yzt356@gmail.com>,
kvm@vger.kernel.org, jan.kiszka@web.de
Subject: Re: [PATCH] KVM : Fix read/write to IA32_FEATURE_CONTROL MSR in nested virt
Date: Thu, 04 Jul 2013 13:01:15 +0200 [thread overview]
Message-ID: <51D555FB.10305@redhat.com> (raw)
In-Reply-To: <20130704071034.GI32123@redhat.com>
Il 04/07/2013 09:10, Gleb Natapov ha scritto:
> On Thu, Jul 04, 2013 at 09:00:09AM +0200, Paolo Bonzini wrote:
>> Il 03/07/2013 15:41, Arthur Chunqi Li ha scritto:
>>> Fix read/write to IA32_FEATURE_CONTROL MSR in nested environment.
>>> Simply return 0x5 when read and generate #GP(0) when write.
>>> Delete handling codes in vmx_set_vmx_msr() and generate #GP(0) in
>>> handle_wrmsr().
>>>
>>> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
>>> ---
>>> arch/x86/kvm/vmx.c | 5 +----
>>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>>> index 260a919..e125f94 100644
>>> --- a/arch/x86/kvm/vmx.c
>>> +++ b/arch/x86/kvm/vmx.c
>>> @@ -2277,7 +2277,7 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
>>>
>>> switch (msr_index) {
>>> case MSR_IA32_FEATURE_CONTROL:
>>> - *pdata = 0;
>>> + *pdata = 0x5;
>>> break;
>>
>> This is not in the MSR_IA32_VMX_BASIC..MSR_IA32_VMX_TRUE_ENTRY_CTLS
>> range, so you must check nested_vmx_allowed and return 0 if it is false.
>
> Or 1?
"Return 0 from the whole function" and hence #GP(0) on reads. The MSR
doesn't exist if VMX=SMX=0.
>> Otherwise looks good.
>>
>> Paolo
>>
>>> case MSR_IA32_VMX_BASIC:
>>> /*
>>> @@ -2356,9 +2356,6 @@ static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
> Also this function is no longer needed. You can drop it.
>
> And what about Nadav's patch Bandan pointed too? It is not entirely
> correct, but it is close to real HW.
I don't like that it requires a firmware change in order to use nested
VMX (at least for hypervisors that read the MSR). "Worse emulation" and
"better emulation + new firmware" are indistiguishable from the point of
view of anyone except the firmware.
IMO there is no reason for a better emulation that no one would care
about _and_ could look like a regression when updating to a newer kernel.
Paolo
>>> if (!nested_vmx_allowed(vcpu))
>>> return 0;
>>>
>>> - if (msr_index == MSR_IA32_FEATURE_CONTROL)
>>> - /* TODO: the right thing. */
>>> - return 1;
>>> /*
>>> * No need to treat VMX capability MSRs specially: If we don't handle
>>> * them, handle_wrmsr will #GP(0), which is correct (they are readonly)
>>>
>
> --
> Gleb.
>
next prev parent reply other threads:[~2013-07-04 11:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 13:41 [PATCH] KVM : Fix read/write to IA32_FEATURE_CONTROL MSR in nested virt Arthur Chunqi Li
2013-07-04 7:00 ` Paolo Bonzini
2013-07-04 7:10 ` Gleb Natapov
2013-07-04 7:21 ` Arthur Chunqi Li
2013-07-04 7:24 ` Gleb Natapov
2013-07-04 8:16 ` Gmail
2013-07-04 10:43 ` Gleb Natapov
2013-07-04 11:01 ` Paolo Bonzini [this message]
2013-07-04 11:12 ` Gleb Natapov
2013-07-04 11:21 ` Paolo Bonzini
2013-07-04 11:31 ` Gleb Natapov
2013-07-04 12:34 ` Paolo Bonzini
2013-07-04 12:43 ` Gleb Natapov
2013-07-05 3:26 ` Arthur Chunqi Li
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=51D555FB.10305@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=yzt356@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.