Re: [PATCH 13/24] Implement VMREAD and VMWRITE

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

 



On Wed, Jun 16, 2010, Gleb Natapov wrote about "Re: [PATCH 13/24] Implement VMREAD and VMWRITE":
> On Mon, Jun 14, 2010 at 12:36:02PM +0300, Avi Kivity wrote:
> > vmread doesn't support 64-bit writes to memory outside long mode, so
> > you'll have to truncate the write.
> > 
> > I think you'll be better off returning a 32-bit size in
> > vmcs_field_size() in these cases.
> > 
> Actually write should be always 32bit long outside IA-32e mode and
> 64bit long in 64 bit mode. Unused bits should be set to zero.

Thanks, good catch. Fixed.

The code now looks like:

        u64 field_value;
        if (!vmcs12_read_any(vcpu, field, &field_value))
                return 0;

        /* It's ok to use *_system, because handle_vmread verifies cpl=0 */
        kvm_write_guest_virt_system(gva, &field_value,
                             (is_long_mode(vcpu) ? 8 : 4), vcpu, NULL);
        return 1;

with vmcs12_read_any() reading the whatever-length of field into a 64-bit
integer (zero-padding if the field is shorter), and then the write is either
64 or 32 bits depending only on is_long_mode(), not on the field's length.
A write may end up truncating the field, or zero-padding it, as necessary.

-- 
Nadav Har'El                        |       Wednesday, Aug  4 2010, 24 Av 5770
nyh@xxxxxxxxxxxxxxxxxxx             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |The message above is just this
http://nadav.harel.org.il           |signature's way of propagating itself.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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