From: "Jan Beulich" Subject: Re: [PATCH] x86/HVM: 32-bit IN result must be zero-extended to 64 bits Date: Tue, 05 Nov 2013 10:07:00 +0000 Message-ID: <5278D15402000078000FF6F2@nat28.tlf.novell.com> References: <5278BE8D02000078000FF631@nat28.tlf.novell.com> <5278C033.2000408@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VddXN-00064z-T6 for xen-devel@lists.xenproject.org; Tue, 05 Nov 2013 10:07:06 +0000 In-Reply-To: <5278C033.2000408@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org >>> On 05.11.13 at 10:53, Andrew Cooper wrote: > On 05/11/13 08:46, Jan Beulich wrote: >> @@ -237,7 +239,12 @@ int handle_pio(uint16_t port, int size, >> { >> case X86EMUL_OKAY: >> if ( dir == IOREQ_READ ) >> - memcpy(&guest_cpu_user_regs()->eax, &data, vio->io_size); >> + { >> + if ( size == 4 ) /* Needs zero extension. */ >> + guest_cpu_user_regs()->eax = (uint32_t)data; > > This would be a rather more clear as guest_cpu_user_regs()->rax, with > makes the 0-extension more obvious than remembering that eax is a 64bit > value in Xen. However, I guess consistency with the surrounding code is > important, and it is spelt out in a comment. In fact I agree - I coded it that way with backportability in mind, but am inclined to change _both_ instances to "rax" here (which will cause obvious build breakage if not adjusted accordingly for 4.2 and earlier). > Either way, > > Reviewed-by: Andrew Cooper Thanks. Jan