From: "Jan Beulich" Subject: Re: [PATCH v3 05/18] x86/hvm: remove multiple open coded 'chunking' loops Date: Wed, 24 Jun 2015 11:27:28 +0100 Message-ID: <558AA2300200007800088C92@mail.emea.novell.com> References: <1435055997-30017-1-git-send-email-paul.durrant@citrix.com> <1435055997-30017-6-git-send-email-paul.durrant@citrix.com> <558A96B00200007800088BD9@mail.emea.novell.com> <9AAE0902D5BC7E449B7C8E4E778ABCD0259692EE@AMSPEX01CL02.citrite.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z7hu0-0003UI-Ku for xen-devel@lists.xenproject.org; Wed, 24 Jun 2015 10:27:32 +0000 In-Reply-To: <9AAE0902D5BC7E449B7C8E4E778ABCD0259692EE@AMSPEX01CL02.citrite.net> 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: Paul Durrant Cc: Andrew Cooper , "Keir(Xen.org)" , "xen-devel@lists.xenproject.org" List-Id: xen-devel@lists.xenproject.org >>> On 24.06.15 at 12:10, wrote: >> From: Jan Beulich [mailto:JBeulich@suse.com] >> Sent: 24 June 2015 10:38 >> >>> On 23.06.15 at 12:39, wrote: >> > --- a/xen/arch/x86/hvm/emulate.c >> > +++ b/xen/arch/x86/hvm/emulate.c >> > @@ -540,6 +540,115 @@ static int hvmemul_virtual_to_linear( >> > return X86EMUL_EXCEPTION; >> > } >> > >> > +static int hvmemul_phys_mmio_access( >> > + paddr_t gpa, unsigned int size, uint8_t dir, uint8_t *buffer, >> > + unsigned int *off) >> >> Why this (buffer, off) pair? The caller can easily adjust buffer as >> necessary, avoiding the other parameter altogether. And buffer >> itself can be void * just like it is in some of the callers (and the >> others should follow suit). >> > > It actually becomes necessary in a later patch, but I'll make the change > there instead. As for incrementing a void *, I know that MSVC disallows this. > I believe it is a gcc-ism which I guess clang must tolerate, but I don't think > it is standard C. That's correct. >> Also, considering instruction characteristics (as explained in the >> original comment) I think the old way of determining the chunk >> size may have been cheaper than yours using fls(). >> > > I thought fls() was generally implemented using inline assembler and was > pretty fast. I didn't actually check how Xen implements it; I just assumed it > would be optimal. It uses BSR, which I remember to generally be (perhaps much) slower than "ordinary" logical operations. But maybe that's not the case anymore on recent CPUs... Jan