Re: [PATCH 20/22] KVM: nVMX: Add util to create vmcs02 vmread/vmwrite bitmaps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, I am sure that nested_vmcs_fields_per_group(vmx) <= 64,
because I fall back to emulation otherwise. But I'd be happy if
someone wanted to make this better.

On Wed, Jul 18, 2018 at 2:02 AM, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
> On 23/06/2018 01:35, Liran Alon wrote:
>> +     for_each_clear_bit(bit, vmcs12_bitmap + offset,
>> +                        nested_vmcs_fields_per_group(vmx)) {
>
> You cannot be sure that nested_vmcs_fields_per_group(vmx) <= 64; the
> index spans bits 1 to 9, so it can be at most 1024.  In fact, even hough
> it is currently the case that it is less than 64, this code already
> breaks on 32-bit machines since guest interruptibility state is
> 00004824H for example.
>
> Here I think it's much better if we already do the optimization you
> mention in the cover letter, of computing vmcs_field_to_offset(field) >=
> 0 && cpu_has_vmcs_field(field) at startup.  Then this loop becomes just
> a word-by-word AND of vmcs12_bitmap with the bitmap you computed at
> startup; really just a single AND on 64-bit machines and two for 32-bits.
>
> Thanks,
>
> Paolo
>
>> +             unsigned long field = base + bit;
>> +
>> +             if (vmcs_field_to_offset(field) >= 0 &&
>> +                 cpu_has_vmcs_field(field))
>> +                     val &= ~(1ul << bit);
>> +     }
>> +
>> +     vmcs02_bitmap[offset] = val;
>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux