From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nadav Har'El" Subject: Re: [PATCH 13/24] Implement VMREAD and VMWRITE Date: Wed, 4 Aug 2010 16:42:42 +0300 Message-ID: <20100804134242.GB15156@fermat.math.technion.ac.il> References: <1276431753-nyh@il.ibm.com> <201006131229.o5DCTDhk013030@rice.haifa.ibm.com> <4C15F802.7060106@redhat.com> <20100616144821.GD523@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mailgw13.technion.ac.il ([132.68.225.13]:7346 "EHLO mailgw13.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757813Ab0HDNmq (ORCPT ); Wed, 4 Aug 2010 09:42:46 -0400 Content-Disposition: inline In-Reply-To: <20100616144821.GD523@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |The message above is just this http://nadav.harel.org.il |signature's way of propagating itself.