Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1459447
| From | Yang Zhang <yang.zhang.wz@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC |
| Date | 2016-08-10 20:40 +0200 |
| Message-ID | <s4GA2-f8-11@gated-at.bofh.it> (permalink) |
| References | <s3Xjz-4So-7@gated-at.bofh.it> <s3Xjz-4So-15@gated-at.bofh.it> <s4bFU-5HW-11@gated-at.bofh.it> <s4ekq-7uJ-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2016/8/9 20:23, Radim Krčmář wrote:
> 2016-08-09 17:32+0800, Yang Zhang:
>> On 2016/8/9 2:16, Radim Krčmář wrote:
>>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>>> @@ -6995,16 +6982,21 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
>>> return 1;
>>> }
>>>
>>> + if (cpu_has_vmx_msr_bitmap()) {
>>> + vmx->nested.msr_bitmap =
>>> + (unsigned long *)__get_free_page(GFP_KERNEL);
>>> + if (!vmx->nested.msr_bitmap)
>>> + goto out_msr_bitmap;
>>> + }
>>> +
>>
>> We export msr_bitmap to guest even it is not supported by hardware. So we
>> need to allocate msr_bitmap for L1 unconditionally.
>
> We do emulate the feature, but the vmx->nested.msr_bitmap is used only
> if VMX supports it to avoid some VM exits:
>
>>> @@ -9957,10 +9938,10 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
>>> }
>>>
>>> if (cpu_has_vmx_msr_bitmap() &&
>>> - exec_control & CPU_BASED_USE_MSR_BITMAPS) {
>>> - nested_vmx_merge_msr_bitmap(vcpu, vmcs12);
>>> - /* MSR_BITMAP will be set by following vmx_set_efer. */
>>> - } else
>>> + exec_control & CPU_BASED_USE_MSR_BITMAPS &&
>>> + nested_vmx_merge_msr_bitmap(vcpu, vmcs12))
>>> + ; /* MSR_BITMAP will be set by following vmx_set_efer. */
>>> + else
>>> exec_control &= ~CPU_BASED_USE_MSR_BITMAPS;
>
> The else branch is taken if !cpu_has_vmx_msr_bitmap() and disables msr
> bitmaps. Similar check for vmx_set_msr_bitmap(), so the NULL doesn't
> even get written to VMCS.
>
> KVM always uses L1's msr bitmaps when emulating the feature.
>
Yes, you are right. I forget the bitmap only used by hardware.:(
--
Yang
Alibaba Cloud Computing
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Radim Krčmář <rkrcmar@redhat.com> - 2016-08-08 20:20 +0200
Re: [PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Yang Zhang <yang.zhang.wz@gmail.com> - 2016-08-09 11:40 +0200
Re: [PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Wincy Van <fanwenyi0529@gmail.com> - 2016-08-09 12:20 +0200
Re: [PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Radim Krčmář <rkrcmar@redhat.com> - 2016-08-09 14:30 +0200
Re: [PATCH 1/2] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Yang Zhang <yang.zhang.wz@gmail.com> - 2016-08-10 20:40 +0200
csiph-web